diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs index aada7f6f4ad..4ed5eb6245a 100644 --- a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs @@ -89,34 +89,11 @@ public async Task Download_GraphQL_Schema_Slicing_Args_Enabled(string path) // assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); +#if NET7_0_OR_GREATER response.MatchMarkdownSnapshot(); - } - - [Theory] - [InlineData("/graphql?sdl")] - [InlineData("/graphql/schema/")] - [InlineData("/graphql/schema.graphql")] - [InlineData("/graphql/schema")] - public async Task Download_GraphQL_Schema_Slicing_Args_Enabled(string path) - { - // arrange - var server = CreateStarWarsServer( - configureServices: sp => - sp - .RemoveAll() - .AddSingleton() - .AddGraphQL() - .ModifyPagingOptions(o => o.RequirePagingBoundaries = true)); - var url = TestServerExtensions.CreateUrl(path); - var request = new HttpRequestMessage(HttpMethod.Get, url); - - // act - var response = await server.CreateClient().SendAsync(request); - - // assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - - response.MatchMarkdownSnapshot(); +#else + response.MatchMarkdownSnapshot("NET6"); +#endif } [Theory] diff --git a/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema_Slicing_Args_Enabled_NET6.md b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema_Slicing_Args_Enabled_NET6.md new file mode 100644 index 00000000000..8959905adf8 --- /dev/null +++ b/src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema_Slicing_Args_Enabled_NET6.md @@ -0,0 +1,145 @@ +# Download_GraphQL_Schema_Slicing_Args_Enabled + +```text +Headers: +ETag: "1-kBEjhe2t+jfqbeZRxnezu0WDQFYAc0qzjLF1RlHs428=" +Cache-Control: public, must-revalidate, max-age=3600 +Content-Type: application/graphql; charset=utf-8 +Content-Disposition: attachment; filename="schema.graphql" +Last-Modified: Fri, 01 Jan 2021 00:00:00 GMT +Content-Length: 5070 +--------------------------> +Status Code: OK +--------------------------> +schema { + query: Query + mutation: Mutation + subscription: Subscription +} + +interface Character { + id: ID! + name: String! + friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection + appearsIn: [Episode] + traits: JSON + height(unit: Unit): Float +} + +type Droid implements Character { + id: ID! + name: String! + appearsIn: [Episode] + friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection + height(unit: Unit): Float + primaryFunction: String + traits: JSON +} + +"A connection to a list of items." +type FriendsConnection { + "Information to aid in pagination." + pageInfo: PageInfo! + "A list of edges." + edges: [FriendsEdge!] + "A flattened list of the nodes." + nodes: [Character] +} + +"An edge in a connection." +type FriendsEdge { + "A cursor for use in pagination." + cursor: String! + "The item at the end of the edge." + node: Character +} + +type Human implements Character { + id: ID! + name: String! + appearsIn: [Episode] + friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection + otherHuman: Human + height(unit: Unit): Float + homePlanet: String + traits: JSON +} + +type Mutation { + createReview(episode: Episode! review: ReviewInput!): Review! + complete(episode: Episode!): Boolean! +} + +"Information about pagination in a connection." +type PageInfo { + "Indicates whether more edges exist following the set defined by the clients arguments." + hasNextPage: Boolean! + "Indicates whether more edges exist prior the set defined by the clients arguments." + hasPreviousPage: Boolean! + "When paginating backwards, the cursor to continue." + startCursor: String + "When paginating forwards, the cursor to continue." + endCursor: String +} + +type Query { + hero(episode: Episode! = NEW_HOPE): Character + heroByTraits(traits: JSON!): Character + heroes(episodes: [Episode!]!): [Character!] + character(characterIds: [String!]!): [Character!]! + search(text: String!): [SearchResult] + human(id: String!): Human + droid(id: String!): Droid + time: Long! + evict: Boolean! + wait(m: Int!): Boolean! + someDeprecatedField(deprecatedArg: String! = "foo" @deprecated(reason: "use something else")): String! @deprecated(reason: "use something else") +} + +type Review { + commentary: String + stars: Int! +} + +type Starship { + id: ID! + name: String! + length(unit: Unit): Float! +} + +type Subscription { + onReview(episode: Episode!): Review! + onNext: String! + onException: String! + delay(delay: Int! count: Int!): String! +} + +union SearchResult = Starship | Human | Droid + +input ReviewInput { + stars: Int! + commentary: String +} + +enum Episode { + NEW_HOPE + EMPIRE + JEDI +} + +enum Unit { + FOOT + METERS +} + +"The `@defer` directive may be provided for fragment spreads and inline fragments to inform the executor to delay the execution of the current fragment to indicate deprioritization of the current fragment. A query with `@defer` directive will cause the request to potentially return multiple responses, where non-deferred data is delivered in the initial response and data deferred is delivered in a subsequent response. `@include` and `@skip` take precedence over `@defer`." +directive @defer("If this argument label has a value other than null, it will be passed on to the result of this defer directive. This label is intended to give client applications a way to identify to which fragment a deferred result belongs to." label: String "Deferred when true." if: Boolean) on FRAGMENT_SPREAD | INLINE_FRAGMENT + +"The `@stream` directive may be provided for a field of `List` type so that the backend can leverage technology such as asynchronous iterators to provide a partial list in the initial response, and additional list items in subsequent responses. `@include` and `@skip` take precedence over `@stream`." +directive @stream("If this argument label has a value other than null, it will be passed on to the result of this stream directive. This label is intended to give client applications a way to identify to which fragment a streamed result belongs to." label: String "The initial elements that shall be send down to the consumer." initialCount: Int! = 0 "Streamed when true." if: Boolean) on FIELD + +scalar JSON + +"The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1." +scalar Long +``` diff --git a/src/HotChocolate/Core/src/Types/Types/Relay/Serialization/OptimizedNodeIdSerializer.cs b/src/HotChocolate/Core/src/Types/Types/Relay/Serialization/OptimizedNodeIdSerializer.cs index b2ffa737f85..6eb58166633 100644 --- a/src/HotChocolate/Core/src/Types/Types/Relay/Serialization/OptimizedNodeIdSerializer.cs +++ b/src/HotChocolate/Core/src/Types/Types/Relay/Serialization/OptimizedNodeIdSerializer.cs @@ -118,7 +118,7 @@ public unsafe NodeId Parse(string formattedId, INodeIdRuntimeTypeLookup runtimeT } } - Base64.DecodeFromUtf8InPlace(span, out var written); + var status = Base64.DecodeFromUtf8InPlace(span, out var written); span = span.Slice(0, written); var delimiterIndex = FindDelimiterIndex(span); diff --git a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs index 64ef4ccfe24..79c48dad239 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderTests.cs @@ -67,8 +67,8 @@ public async Task FetchMultipleNodesDataLoader() await ExpectValid( """ { - a: node(id: "RW50aXR5OjE==") { ... on Entity { id } } - b: node(id: "RW50aXR5OjI==") { ... on Entity { id } } + a: node(id: "RW50aXR5OjE=") { ... on Entity { id } } + b: node(id: "RW50aXR5OjI=") { ... on Entity { id } } } """, configure: b => b diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/ResolverTests.cs b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ResolverTests.cs index b5d475335f1..09fe7c8d33b 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/ResolverTests.cs +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/ResolverTests.cs @@ -21,7 +21,7 @@ public static int GetTest([LocalState("Test")] int test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } @@ -44,7 +44,7 @@ public static int GetTest([ScopedState("Test")] int test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } @@ -67,7 +67,7 @@ public static int GetTest([GlobalState("Test")] int test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } @@ -91,7 +91,7 @@ public static int GetTest([LocalState] SetState test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } @@ -115,7 +115,7 @@ public static int GetTest([ScopedState] SetState test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } @@ -139,7 +139,7 @@ public static int GetTest([GlobalState] SetState test) } } - internal class Test; + internal class Test { } """).MatchMarkdownAsync(); } } diff --git a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/DataLoaderTests.Generate_Without_Interface.md b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/DataLoaderTests.Generate_Without_Interface.md index cebdeb21888..bc544f391ca 100644 --- a/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/DataLoaderTests.Generate_Without_Interface.md +++ b/src/HotChocolate/Core/test/Types.Analyzers.Tests/__snapshots__/DataLoaderTests.Generate_Without_Interface.md @@ -94,26 +94,3 @@ namespace Microsoft.Extensions.DependencyInjection ``` -## Compilation Diagnostics - -```json -[ - { - "Id": "GD0002", - "Title": "Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", - "Severity": "Error", - "WarningLevel": 0, - "Location": ": (15,8)-(15,47)", - "HelpLinkUri": "https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS9204)", - "MessageFormat": "'{0}' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", - "Message": "'GreenDonut.Predicates.IPredicateBuilder' is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.", - "Category": "Compiler", - "CustomTags": [ - "Compiler", - "Telemetry", - "CustomObsolete" - ] - } -] -``` - diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs index fba12ca83ff..be388c8a146 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/DurationTypeTests.cs @@ -14,14 +14,19 @@ public class Query { public Duration PositiveWithDecimals => Duration.FromTimeSpan(new TimeSpan(123, 7, 53, 10, 19)); + public Duration NegativeWithDecimals => -Duration.FromTimeSpan(new TimeSpan(123, 7, 53, 10, 19)); + public Duration PositiveWithoutDecimals => Duration.FromTimeSpan(new TimeSpan(123, 7, 53, 10)); + public Duration PositiveWithoutSeconds => Duration.FromTimeSpan(new TimeSpan(123, 7, 53, 0)); + public Duration PositiveWithoutMinutes => Duration.FromTimeSpan(new TimeSpan(123, 7, 0, 0)); + public Duration PositiveWithRoundtrip => Duration.FromTimeSpan(new TimeSpan(123, 26, 0, 70)); } @@ -86,10 +91,15 @@ public void QueryReturnsSerializedDataWithRoundtrip() public void MutationParsesInputWithDecimals() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "09:22:01:00.019" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "09:22:01:00.019" }, + }) + .Build()); Assert.Equal("9:22:11:00.019", result.ExpectOperationResult().Data!["test"]); } @@ -97,10 +107,15 @@ public void MutationParsesInputWithDecimals() public void MutationParsesInputWithoutDecimals() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "09:22:01:00" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "09:22:01:00" }, + }) + .Build()); Assert.Equal("9:22:11:00", result.ExpectOperationResult().Data!["test"]); } @@ -108,10 +123,15 @@ public void MutationParsesInputWithoutDecimals() public void MutationParsesInputWithoutLeadingZero() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "9:22:01:00" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "9:22:01:00" }, + }) + .Build()); Assert.Equal("9:22:11:00", result.ExpectOperationResult().Data!["test"]); } @@ -119,10 +139,15 @@ public void MutationParsesInputWithoutLeadingZero() public void MutationParsesInputWithNegativeValue() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "-9:22:01:00" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "-9:22:01:00" }, + }) + .Build()); Assert.Equal("-9:21:51:00", result.ExpectOperationResult().Data!["test"]); } @@ -130,10 +155,15 @@ public void MutationParsesInputWithNegativeValue() public void MutationDoesntParseInputWithPlusSign() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "+09:22:01:00" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "+09:22:01:00" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); } @@ -142,10 +172,15 @@ public void MutationDoesntParseInputWithPlusSign() public void MutationDoesntParseInputWithOverflownHours() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "9:26:01:00" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Duration!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "9:26:01:00" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); } @@ -154,9 +189,10 @@ public void MutationDoesntParseInputWithOverflownHours() public void MutationParsesLiteralWithDecimals() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"09:22:01:00.019\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"09:22:01:00.019\") }") + .Build()); Assert.Equal("9:22:11:00.019", result.ExpectOperationResult().Data!["test"]); } @@ -165,9 +201,10 @@ public void MutationParsesLiteralWithDecimals() public void MutationParsesLiteralWithoutDecimals() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"09:22:01:00\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"09:22:01:00\") }") + .Build()); Assert.Equal("9:22:11:00", result.ExpectOperationResult().Data!["test"]); } @@ -176,9 +213,10 @@ public void MutationParsesLiteralWithoutDecimals() public void MutationParsesLiteralWithoutLeadingZero() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"09:22:01:00\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"09:22:01:00\") }") + .Build()); Assert.Equal("9:22:11:00", result.ExpectOperationResult().Data!["test"]); } @@ -187,9 +225,10 @@ public void MutationParsesLiteralWithoutLeadingZero() public void MutationParsesLiteralWithNegativeValue() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"-9:22:01:00\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"-9:22:01:00\") }") + .Build()); Assert.Equal("-9:21:51:00", result.ExpectOperationResult().Data!["test"]); } @@ -198,9 +237,10 @@ public void MutationParsesLiteralWithNegativeValue() public void MutationDoesntParseLiteralWithPlusSign() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"+09:22:01:00\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"+09:22:01:00\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -210,9 +250,10 @@ public void MutationDoesntParseLiteralWithPlusSign() public void MutationDoesntParseLiteralWithOverflownHours() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"9:26:01:00\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"9:26:01:00\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -224,36 +265,36 @@ public void PatternEmpty_ThrowSchemaException() static object Call() => new DurationType([]); Assert.Throws(Call); } - } - [Fact] - public void DurationType_DescriptionKnownPatterns_MatchesSnapshot() - { - var durationType = new DurationType( - DurationPattern.Roundtrip, - DurationPattern.JsonRoundtrip); - - durationType.Description.MatchInlineSnapshot( - """ - Represents a fixed (and calendar-independent) length of time. - - Allowed patterns: - - `-D:hh:mm:ss.sssssssss` - - `-hh:mm:ss.sssssssss` - - Examples: - - `-1:20:00:00.999999999` - - `-44:00:00.999999999` - """); - } + [Fact] + public void DurationType_DescriptionKnownPatterns_MatchesSnapshot() + { + var durationType = new DurationType( + DurationPattern.Roundtrip, + DurationPattern.JsonRoundtrip); + + durationType.Description.MatchInlineSnapshot( + """ + Represents a fixed (and calendar-independent) length of time. + + Allowed patterns: + - `-D:hh:mm:ss.sssssssss` + - `-hh:mm:ss.sssssssss` + + Examples: + - `-1:20:00:00.999999999` + - `-44:00:00.999999999` + """); + } - [Fact] - public void DurationType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var durationType = new DurationType( - DurationPattern.Create("mm", CultureInfo.InvariantCulture)); + [Fact] + public void DurationType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var durationType = new DurationType( + DurationPattern.Create("mm", CultureInfo.InvariantCulture)); - durationType.Description.MatchInlineSnapshot( - "Represents a fixed (and calendar-independent) length of time."); + durationType.Description.MatchInlineSnapshot( + "Represents a fixed (and calendar-independent) length of time."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs index c3085bf7222..623366bdb60 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/InstantTypeTests.cs @@ -46,10 +46,15 @@ public void QueryReturnsUtc() public void ParsesVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-02-21T17:42:59.000001234Z" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-02-21T17:42:59.000001234Z" }, + }) + .Build()); Assert.Equal( "2020-02-21T17:52:59.000001234Z", @@ -60,10 +65,15 @@ public void ParsesVariable() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Instant!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-02-20T17:42:59" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -73,9 +83,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59.000001234Z\") }") + .Build()); Assert.Equal( "2020-02-20T17:52:59.000001234Z", @@ -86,9 +97,10 @@ public void ParsesLiteral() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -104,34 +116,35 @@ public void PatternEmpty_ThrowSchemaException() static object Call() => new InstantType([]); Assert.Throws(Call); } - } - [Fact] - public void InstantType_DescriptionKnownPatterns_MatchesSnapshot() - { - var instantType = new InstantType(InstantPattern.General, InstantPattern.ExtendedIso); - instantType.Description.MatchInlineSnapshot( - """ - Represents an instant on the global timeline, with nanosecond resolution. + [Fact] + public void InstantType_DescriptionKnownPatterns_MatchesSnapshot() + { + var instantType = new InstantType(InstantPattern.General, InstantPattern.ExtendedIso); - Allowed patterns: - - `YYYY-MM-DDThh:mm:ss±hh:mm` - - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm` + instantType.Description.MatchInlineSnapshot( + """ + Represents an instant on the global timeline, with nanosecond resolution. - Examples: - - `2000-01-01T20:00:00Z` - - `2000-01-01T20:00:00.999999999Z` - """); - } + Allowed patterns: + - `YYYY-MM-DDThh:mm:ss±hh:mm` + - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm` - [Fact] - public void InstantType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var instantType = new InstantType( - InstantPattern.Create("MM", CultureInfo.InvariantCulture)); + Examples: + - `2000-01-01T20:00:00Z` + - `2000-01-01T20:00:00.999999999Z` + """); + } - instantType.Description.MatchInlineSnapshot( - "Represents an instant on the global timeline, with nanosecond resolution."); + [Fact] + public void InstantType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var instantType = new InstantType( + InstantPattern.Create("MM", CultureInfo.InvariantCulture)); + + instantType.Description.MatchInlineSnapshot( + "Represents an instant on the global timeline, with nanosecond resolution."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs index 611eda2d32d..c8fc98addaa 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTimeTypeTests.cs @@ -52,7 +52,10 @@ public void ParsesVariable() OperationRequestBuilder.New() .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") .SetVariableValues( - new Dictionary { { "arg", "2020-02-21T17:42:59.000001234" }, }) + new Dictionary + { + { "arg", "2020-02-21T17:42:59.000001234" }, + }) .Build()); Assert.Equal("2020-02-21T17:52:59.000001234", result.ExpectOperationResult().Data!["test"]); @@ -66,7 +69,10 @@ public void DoesntParseAnIncorrectVariable() OperationRequestBuilder.New() .SetDocument("mutation($arg: LocalDateTime!) { test(arg: $arg) }") .SetVariableValues( - new Dictionary { { "arg", "2020-02-20T17:42:59.000001234Z" }, }) + new Dictionary + { + { "arg", "2020-02-20T17:42:59.000001234Z" }, + }) .Build()); Assert.Null(result.ExpectOperationResult().Data); @@ -108,36 +114,37 @@ public void PatternEmpty_ThrowSchemaException() static object Call() => new LocalDateTimeType([]); Assert.Throws(Call); } - } - [Fact] - public void LocalDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() - { - var localDateTimeType = new LocalDateTimeType( - LocalDateTimePattern.ExtendedIso, - LocalDateTimePattern.FullRoundtrip); - - localDateTimeType.Description.MatchInlineSnapshot( - """ - A date and time in a particular calendar system. - - Allowed patterns: - - `YYYY-MM-DDThh:mm:ss.sssssssss` - - `YYYY-MM-DDThh:mm:ss.sssssssss (calendar)` - - Examples: - - `2000-01-01T20:00:00.999` - - `2000-01-01T20:00:00.999999999 (ISO)` - """); - } - [Fact] - public void LocalDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var localDateTimeType = new LocalDateTimeType( - LocalDateTimePattern.Create("MM", CultureInfo.InvariantCulture)); + [Fact] + public void LocalDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() + { + var localDateTimeType = new LocalDateTimeType( + LocalDateTimePattern.ExtendedIso, + LocalDateTimePattern.FullRoundtrip); + + localDateTimeType.Description.MatchInlineSnapshot( + """ + A date and time in a particular calendar system. + + Allowed patterns: + - `YYYY-MM-DDThh:mm:ss.sssssssss` + - `YYYY-MM-DDThh:mm:ss.sssssssss (calendar)` + + Examples: + - `2000-01-01T20:00:00.999` + - `2000-01-01T20:00:00.999999999 (ISO)` + """); + } - localDateTimeType.Description.MatchInlineSnapshot( - "A date and time in a particular calendar system."); + [Fact] + public void LocalDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var localDateTimeType = new LocalDateTimeType( + LocalDateTimePattern.Create("MM", CultureInfo.InvariantCulture)); + + localDateTimeType.Description.MatchInlineSnapshot( + "A date and time in a particular calendar system."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs index 2657f36a3f3..82488662077 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalDateTypeTests.cs @@ -13,8 +13,8 @@ public static class Schema public class Query { public LocalDate One => LocalDate.FromDateTime( - new DateTime(2020, 02, 20, 17, 42, 59)) - .WithCalendar(CalendarSystem.HebrewCivil); + new DateTime(2020, 02, 20, 17, 42, 59)) + .WithCalendar(CalendarSystem.HebrewCivil); } public class Mutation @@ -46,10 +46,15 @@ public void QueryReturns() public void ParsesVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-02-21" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-02-21" }, + }) + .Build()); Assert.Equal("2020-02-24", result.ExpectOperationResult().Data!["test"]); } @@ -58,10 +63,15 @@ public void ParsesVariable() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-02-20T17:42:59" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: LocalDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-02-20T17:42:59" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -71,9 +81,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-02-20\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-02-20\") }") + .Build()); Assert.Equal("2020-02-23", result.ExpectOperationResult().Data!["test"]); } @@ -82,9 +93,10 @@ public void ParsesLiteral() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-02-20T17:42:59\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -100,34 +112,34 @@ public void PatternEmpty_ThrowSchemaException() static object Call() => new LocalDateType([]); Assert.Throws(Call); } - } - [Fact] - public void LocalDateType_DescriptionKnownPatterns_MatchesSnapshot() - { - var localDateType = new LocalDateType(LocalDatePattern.Iso, LocalDatePattern.FullRoundtrip); + [Fact] + public void LocalDateType_DescriptionKnownPatterns_MatchesSnapshot() + { + var localDateType = new LocalDateType(LocalDatePattern.Iso, LocalDatePattern.FullRoundtrip); - localDateType.Description.MatchInlineSnapshot( - """ - LocalDate represents a date within the calendar, with no reference to a particular time zone or time of day. + localDateType.Description.MatchInlineSnapshot( + """ + LocalDate represents a date within the calendar, with no reference to a particular time zone or time of day. - Allowed patterns: - - `YYYY-MM-DD` - - `YYYY-MM-DD (calendar)` + Allowed patterns: + - `YYYY-MM-DD` + - `YYYY-MM-DD (calendar)` - Examples: - - `2000-01-01` - - `2000-01-01 (ISO)` - """); - } + Examples: + - `2000-01-01` + - `2000-01-01 (ISO)` + """); + } - [Fact] - public void LocalDateType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var localDateType = new LocalDateType( - LocalDatePattern.Create("MM", CultureInfo.InvariantCulture)); + [Fact] + public void LocalDateType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var localDateType = new LocalDateType( + LocalDatePattern.Create("MM", CultureInfo.InvariantCulture)); - localDateType.Description.MatchInlineSnapshot( - "LocalDate represents a date within the calendar, with no reference to a particular time zone or time of day."); + localDateType.Description.MatchInlineSnapshot( + "LocalDate represents a date within the calendar, with no reference to a particular time zone or time of day."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs index ee6f6b774fa..185d68747bb 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/LocalTimeTypeTests.cs @@ -49,7 +49,11 @@ public void ParsesVariable() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "12:42:13.031011234" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "12:42:13.031011234" }, + }) .Build()); Assert.Equal("12:52:13.031011234", result.ExpectOperationResult().Data!["test"]); @@ -62,7 +66,11 @@ public void ParsesVariableWithoutTicks() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "12:42:13" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "12:42:13" }, + }) .Build()); Assert.Equal("12:52:13", result.ExpectOperationResult().Data!["test"]); @@ -75,7 +83,11 @@ public void DoesntParseAnIncorrectVariable() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: LocalTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "12:42" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "12:42" }, + }) .Build()); Assert.Null(result.ExpectOperationResult().Data); @@ -129,36 +141,36 @@ public void PatternEmptyThrowSchemaException() static object Call() => new LocalTimeType([]); Assert.Throws(Call); } - } - [Fact] - public void LocalTimeType_DescriptionKnownPatterns_MatchesSnapshot() - { - var localTimeType = new LocalTimeType( - LocalTimePattern.GeneralIso, - LocalTimePattern.ExtendedIso); - - localTimeType.Description.MatchInlineSnapshot( - """ - LocalTime represents a time of day, with no reference to a particular calendar, time zone, or date. - - Allowed patterns: - - `hh:mm:ss` - - `hh:mm:ss.sssssssss` - - Examples: - - `20:00:00` - - `20:00:00.999` - """); - } + [Fact] + public void LocalTimeType_DescriptionKnownPatterns_MatchesSnapshot() + { + var localTimeType = new LocalTimeType( + LocalTimePattern.GeneralIso, + LocalTimePattern.ExtendedIso); + + localTimeType.Description.MatchInlineSnapshot( + """ + LocalTime represents a time of day, with no reference to a particular calendar, time zone, or date. + + Allowed patterns: + - `hh:mm:ss` + - `hh:mm:ss.sssssssss` + + Examples: + - `20:00:00` + - `20:00:00.999` + """); + } - [Fact] - public void LocalTimeType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var localTimeType = new LocalTimeType( - LocalTimePattern.Create("mm", CultureInfo.InvariantCulture)); + [Fact] + public void LocalTimeType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var localTimeType = new LocalTimeType( + LocalTimePattern.Create("mm", CultureInfo.InvariantCulture)); - localTimeType.Description.MatchInlineSnapshot( - "LocalTime represents a time of day, with no reference to a particular calendar, time zone, or date."); + localTimeType.Description.MatchInlineSnapshot( + "LocalTime represents a time of day, with no reference to a particular calendar, time zone, or date."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs index a372e0ecd21..c5d6bdc4e95 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTimeTypeTests.cs @@ -79,7 +79,11 @@ public void ParsesVariable() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T18:30:13+02" }, + }) .Build()); Assert.Equal("2020-12-31T18:40:13+02", result.ExpectOperationResult().Data!["test"]); @@ -92,7 +96,11 @@ public void ParsesVariableWithMinutes() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13+02:35" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T18:30:13+02:35" }, + }) .Build()); Assert.Equal("2020-12-31T18:40:13+02:35", result.ExpectOperationResult().Data!["test"]); @@ -105,7 +113,11 @@ public void DoesntParseAnIncorrectVariable() .Execute( OperationRequestBuilder.New() .SetDocument("mutation($arg: OffsetDateTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { { "arg", "2020-12-31T18:30:13" }, }) + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31T18:30:13" }, + }) .Build()); Assert.Null(result.ExpectOperationResult().Data); @@ -159,36 +171,36 @@ public void PatternEmptyThrowSchemaException() static object Call() => new OffsetDateTimeType([]); Assert.Throws(Call); } - } - [Fact] - public void OffsetDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() - { - var offsetDateTimeType = new OffsetDateTimeType( - OffsetDateTimePattern.ExtendedIso, - OffsetDateTimePattern.FullRoundtrip); - - offsetDateTimeType.Description.MatchInlineSnapshot( - """ - A local date and time in a particular calendar system, combined with an offset from UTC. - - Allowed patterns: - - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm` - - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm (calendar)` - - Examples: - - `2000-01-01T20:00:00.999Z` - - `2000-01-01T20:00:00.999Z (ISO)` - """); - } + [Fact] + public void OffsetDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() + { + var offsetDateTimeType = new OffsetDateTimeType( + OffsetDateTimePattern.ExtendedIso, + OffsetDateTimePattern.FullRoundtrip); + + offsetDateTimeType.Description.MatchInlineSnapshot( + """ + A local date and time in a particular calendar system, combined with an offset from UTC. + + Allowed patterns: + - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm` + - `YYYY-MM-DDThh:mm:ss.sssssssss±hh:mm (calendar)` + + Examples: + - `2000-01-01T20:00:00.999Z` + - `2000-01-01T20:00:00.999Z (ISO)` + """); + } - [Fact] - public void OffsetDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var offsetDateTimeType = new OffsetDateTimeType( - OffsetDateTimePattern.Create("MM", CultureInfo.InvariantCulture, new OffsetDateTime())); + [Fact] + public void OffsetDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var offsetDateTimeType = new OffsetDateTimeType( + OffsetDateTimePattern.Create("MM", CultureInfo.InvariantCulture, new OffsetDateTime())); - offsetDateTimeType.Description.MatchInlineSnapshot( - "A local date and time in a particular calendar system, combined with an offset from UTC."); + offsetDateTimeType.Description.MatchInlineSnapshot( + "A local date and time in a particular calendar system, combined with an offset from UTC."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs index 193ed353e05..36b77fb6828 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetDateTypeTests.cs @@ -55,10 +55,15 @@ public void QueryReturnsWithMinutes() public void ParsesVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31+02" }, + }) + .Build()); Assert.Equal("2020-12-31+02", result.ExpectOperationResult().Data!["test"]); } @@ -66,10 +71,15 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-12-31+02:35" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31+02:35" }, + }) + .Build()); Assert.Equal("2020-12-31+02:35", result.ExpectOperationResult().Data!["test"]); } @@ -77,10 +87,15 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "2020-12-31" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetDate!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "2020-12-31" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); } @@ -89,9 +104,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-12-31+02\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-12-31+02\") }") + .Build()); Assert.Equal("2020-12-31+02", result.ExpectOperationResult().Data!["test"]); } @@ -99,9 +115,10 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-12-31+02:35\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-12-31+02:35\") }") + .Build()); Assert.Equal("2020-12-31+02:35", result.ExpectOperationResult().Data!["test"]); } @@ -109,9 +126,10 @@ public void ParsesLiteralWithMinutes() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"2020-12-31\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"2020-12-31\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); Assert.Null(result.ExpectOperationResult().Errors![0].Code); @@ -126,36 +144,36 @@ public void PatternEmptyThrowSchemaException() static object Call() => new OffsetDateType([]); Assert.Throws(Call); } - } - [Fact] - public void OffsetDateType_DescriptionKnownPatterns_MatchesSnapshot() - { - var offsetDateType = new OffsetDateType( - OffsetDatePattern.GeneralIso, - OffsetDatePattern.FullRoundtrip); - - offsetDateType.Description.MatchInlineSnapshot( - """ - A combination of a LocalDate and an Offset, to represent a date at a specific offset from UTC but without any time-of-day information. - - Allowed patterns: - - `YYYY-MM-DD±hh:mm` - - `YYYY-MM-DD±hh:mm (calendar)` - - Examples: - - `2000-01-01Z` - - `2000-01-01Z (ISO)` - """); - } + [Fact] + public void OffsetDateType_DescriptionKnownPatterns_MatchesSnapshot() + { + var offsetDateType = new OffsetDateType( + OffsetDatePattern.GeneralIso, + OffsetDatePattern.FullRoundtrip); + + offsetDateType.Description.MatchInlineSnapshot( + """ + A combination of a LocalDate and an Offset, to represent a date at a specific offset from UTC but without any time-of-day information. + + Allowed patterns: + - `YYYY-MM-DD±hh:mm` + - `YYYY-MM-DD±hh:mm (calendar)` + + Examples: + - `2000-01-01Z` + - `2000-01-01Z (ISO)` + """); + } - [Fact] - public void OffsetDateType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var offsetDateType = new OffsetDateType( - OffsetDatePattern.Create("MM", CultureInfo.InvariantCulture, new OffsetDate())); + [Fact] + public void OffsetDateType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var offsetDateType = new OffsetDateType( + OffsetDatePattern.Create("MM", CultureInfo.InvariantCulture, new OffsetDate())); - offsetDateType.Description.MatchInlineSnapshot( - "A combination of a LocalDate and an Offset, to represent a date at a specific offset from UTC but without any time-of-day information."); + offsetDateType.Description.MatchInlineSnapshot( + "A combination of a LocalDate and an Offset, to represent a date at a specific offset from UTC but without any time-of-day information."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs index b49caf6ea47..23d9d6d98b7 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTimeTypeTests.cs @@ -59,10 +59,15 @@ public void QueryReturnsWithMinutes() public void ParsesVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "18:30:13+02" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "18:30:13+02" }, + }) + .Build()); Assert.Equal("18:30:13+02", result.ExpectOperationResult().Data!["test"]); } @@ -70,10 +75,15 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "18:30:13+02:35" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "18:30:13+02:35" }, + }) + .Build()); Assert.Equal("18:30:13+02:35", result.ExpectOperationResult().Data!["test"]); } @@ -81,10 +91,15 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "18:30:13" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: OffsetTime!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "18:30:13" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); } @@ -93,9 +108,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"18:30:13+02\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"18:30:13+02\") }") + .Build()); Assert.Equal("18:30:13+02", result.ExpectOperationResult().Data!["test"]); } @@ -103,9 +119,10 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"18:30:13+02:35\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"18:30:13+02:35\") }") + .Build()); Assert.Equal("18:30:13+02:35", result.ExpectOperationResult().Data!["test"]); } @@ -113,9 +130,10 @@ public void ParsesLiteralWithMinutes() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"18:30:13\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"18:30:13\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); @@ -131,36 +149,36 @@ public void PatternEmptyThrowSchemaException() static object Call() => new OffsetTimeType([]); Assert.Throws(Call); } - } - [Fact] - public void OffsetTimeType_DescriptionKnownPatterns_MatchesSnapshot() - { - var offsetTimeType = new OffsetTimeType( - OffsetTimePattern.GeneralIso, - OffsetTimePattern.ExtendedIso); - - offsetTimeType.Description.MatchInlineSnapshot( - """ - A combination of a LocalTime and an Offset, to represent a time-of-day at a specific offset from UTC but without any date information. - - Allowed patterns: - - `hh:mm:ss±hh:mm` - - `hh:mm:ss.sssssssss±hh:mm` - - Examples: - - `20:00:00Z` - - `20:00:00.999Z` - """); - } + [Fact] + public void OffsetTimeType_DescriptionKnownPatterns_MatchesSnapshot() + { + var offsetTimeType = new OffsetTimeType( + OffsetTimePattern.GeneralIso, + OffsetTimePattern.ExtendedIso); + + offsetTimeType.Description.MatchInlineSnapshot( + """ + A combination of a LocalTime and an Offset, to represent a time-of-day at a specific offset from UTC but without any date information. + + Allowed patterns: + - `hh:mm:ss±hh:mm` + - `hh:mm:ss.sssssssss±hh:mm` + + Examples: + - `20:00:00Z` + - `20:00:00.999Z` + """); + } - [Fact] - public void OffsetTimeType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var offsetTimeType = new OffsetTimeType( - OffsetTimePattern.Create("mm", CultureInfo.InvariantCulture, new OffsetTime())); + [Fact] + public void OffsetTimeType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var offsetTimeType = new OffsetTimeType( + OffsetTimePattern.Create("mm", CultureInfo.InvariantCulture, new OffsetTime())); - offsetTimeType.Description.MatchInlineSnapshot( - "A combination of a LocalTime and an Offset, to represent a time-of-day at a specific offset from UTC but without any date information."); + offsetTimeType.Description.MatchInlineSnapshot( + "A combination of a LocalTime and an Offset, to represent a time-of-day at a specific offset from UTC but without any date information."); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs index fef1d43d205..2d04c39cd4e 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/OffsetTypeTests.cs @@ -56,10 +56,15 @@ public void QueryReturnsWithZ() public void ParsesVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "+02" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "+02" }, + }) + .Build()); Assert.Equal("+03:05", result.ExpectOperationResult().Data!["test"]); } @@ -67,10 +72,15 @@ public void ParsesVariable() public void ParsesVariableWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "+02:35" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "+02:35" }, + }) + .Build()); Assert.Equal("+03:40", result.ExpectOperationResult().Data!["test"]); } @@ -78,10 +88,15 @@ public void ParsesVariableWithMinutes() public void DoesntParseAnIncorrectVariable() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") - .SetVariableValues(new Dictionary { {"arg", "18:30:13+02" }, }) - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation($arg: Offset!) { test(arg: $arg) }") + .SetVariableValues( + new Dictionary + { + { "arg", "18:30:13+02" }, + }) + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); } @@ -90,9 +105,10 @@ public void DoesntParseAnIncorrectVariable() public void ParsesLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"+02\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"+02\") }") + .Build()); Assert.Equal("+03:05", result.ExpectOperationResult().Data!["test"]); } @@ -100,9 +116,10 @@ public void ParsesLiteral() public void ParsesLiteralWithMinutes() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"+02:35\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"+02:35\") }") + .Build()); Assert.Equal("+03:40", result.ExpectOperationResult().Data!["test"]); } @@ -110,9 +127,10 @@ public void ParsesLiteralWithMinutes() public void ParsesLiteralWithZ() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"Z\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"Z\") }") + .Build()); Assert.Equal("+01:05", result.ExpectOperationResult().Data!["test"]); } @@ -120,9 +138,10 @@ public void ParsesLiteralWithZ() public void DoesntParseIncorrectLiteral() { var result = _testExecutor - .Execute(OperationRequestBuilder.New() - .SetDocument("mutation { test(arg: \"18:30:13+02\") }") - .Build()); + .Execute( + OperationRequestBuilder.New() + .SetDocument("mutation { test(arg: \"18:30:13+02\") }") + .Build()); Assert.Null(result.ExpectOperationResult().Data); Assert.Single(result.ExpectOperationResult().Errors!); Assert.Null(result.ExpectOperationResult().Errors![0].Code); @@ -137,40 +156,40 @@ public void PatternEmptyThrowSchemaException() static object Call() => new OffsetType([]); Assert.Throws(Call); } - } - [Fact] - public void OffsetType_DescriptionKnownPatterns_MatchesSnapshot() - { - var offsetType = new OffsetType( - OffsetPattern.GeneralInvariant, - OffsetPattern.GeneralInvariantWithZ); - - offsetType.Description.MatchInlineSnapshot( - """ - An offset from UTC in seconds. - A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America). - - Allowed patterns: - - `±hh:mm:ss` - - `Z` - - Examples: - - `+02:30:00` - - `Z` - """); - } + [Fact] + public void OffsetType_DescriptionKnownPatterns_MatchesSnapshot() + { + var offsetType = new OffsetType( + OffsetPattern.GeneralInvariant, + OffsetPattern.GeneralInvariantWithZ); + + offsetType.Description.MatchInlineSnapshot( + """ + An offset from UTC in seconds. + A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America). + + Allowed patterns: + - `±hh:mm:ss` + - `Z` + + Examples: + - `+02:30:00` + - `Z` + """); + } - [Fact] - public void OffsetType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var offsetType = new OffsetType( - OffsetPattern.Create("mm", CultureInfo.InvariantCulture)); - - offsetType.Description.MatchInlineSnapshot( - """ - An offset from UTC in seconds. - A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America). - """); + [Fact] + public void OffsetType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var offsetType = new OffsetType( + OffsetPattern.Create("mm", CultureInfo.InvariantCulture)); + + offsetType.Description.MatchInlineSnapshot( + """ + An offset from UTC in seconds. + A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America). + """); + } } } diff --git a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs index 4ed8ddb89fb..9d9d682030a 100644 --- a/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs +++ b/src/HotChocolate/Core/test/Types.NodaTime.Tests/ZonedDateTimeTypeTests.cs @@ -86,10 +86,7 @@ public void ParsesVariableWithUtc() OperationRequestBuilder.New() .SetDocument("mutation($arg: ZonedDateTime!) { test(arg: $arg) }") .SetVariableValues( - new Dictionary - { - { "arg", "2020-12-31T19:30:13 UTC +00" } - }) + new Dictionary { { "arg", "2020-12-31T19:30:13 UTC +00" } }) .Build()); Assert.Equal( "2020-12-31T19:40:13 UTC +00", @@ -159,45 +156,45 @@ public void PatternEmpty_ThrowSchemaException() static object Call() => new ZonedDateTimeType([]); Assert.Throws(Call); } - } - [Fact] - public void ZonedDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() - { - var zonedDateTimeType = new ZonedDateTimeType( - ZonedDateTimePattern.GeneralFormatOnlyIso, - ZonedDateTimePattern.ExtendedFormatOnlyIso); - - zonedDateTimeType.Description.MatchInlineSnapshot( - """ - A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants. - A ZonedDateTime is global, in that it maps to a single Instant. - - Allowed patterns: - - `YYYY-MM-DDThh:mm:ss z (±hh:mm)` - - `YYYY-MM-DDThh:mm:ss.sssssssss z (±hh:mm)` - - Examples: - - `2000-01-01T20:00:00 Europe/Zurich (+01)` - - `2000-01-01T20:00:00.999999999 Europe/Zurich (+01)` - """); - } + [Fact] + public void ZonedDateTimeType_DescriptionKnownPatterns_MatchesSnapshot() + { + var zonedDateTimeType = new ZonedDateTimeType( + ZonedDateTimePattern.GeneralFormatOnlyIso, + ZonedDateTimePattern.ExtendedFormatOnlyIso); + + zonedDateTimeType.Description.MatchInlineSnapshot( + """ + A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants. + A ZonedDateTime is global, in that it maps to a single Instant. + + Allowed patterns: + - `YYYY-MM-DDThh:mm:ss z (±hh:mm)` + - `YYYY-MM-DDThh:mm:ss.sssssssss z (±hh:mm)` + + Examples: + - `2000-01-01T20:00:00 Europe/Zurich (+01)` + - `2000-01-01T20:00:00.999999999 Europe/Zurich (+01)` + """); + } - [Fact] - public void ZonedDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() - { - var zonedDateTimeType = new ZonedDateTimeType( - ZonedDateTimePattern.Create( - "MM", - CultureInfo.InvariantCulture, - null, - null, - new ZonedDateTime())); - - zonedDateTimeType.Description.MatchInlineSnapshot( - """ - A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants. - A ZonedDateTime is global, in that it maps to a single Instant. - """); + [Fact] + public void ZonedDateTimeType_DescriptionUnknownPatterns_MatchesSnapshot() + { + var zonedDateTimeType = new ZonedDateTimeType( + ZonedDateTimePattern.Create( + "MM", + CultureInfo.InvariantCulture, + null, + null, + new ZonedDateTime())); + + zonedDateTimeType.Description.MatchInlineSnapshot( + """ + A LocalDateTime in a specific time zone and with a particular offset to distinguish between otherwise-ambiguous instants. + A ZonedDateTime is global, in that it maps to a single Instant. + """); + } } } diff --git a/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/HotChocolate.PersistedOperations.FileSystem.Tests.csproj b/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/HotChocolate.PersistedOperations.FileSystem.Tests.csproj index 3ed195f80bd..0bcc48249db 100644 --- a/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/HotChocolate.PersistedOperations.FileSystem.Tests.csproj +++ b/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/HotChocolate.PersistedOperations.FileSystem.Tests.csproj @@ -6,6 +6,7 @@ + diff --git a/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/IntegrationTests.cs b/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/IntegrationTests.cs index ee985f04f26..018a3392f89 100644 --- a/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/IntegrationTests.cs +++ b/src/HotChocolate/PersistedOperations/test/PersistedOperations.FileSystem.Tests/IntegrationTests.cs @@ -1,7 +1,7 @@ +using CookieCrumble; using Microsoft.Extensions.DependencyInjection; using HotChocolate.Types; using HotChocolate.Execution; -using Snapshooter.Xunit; using HotChocolate.Language; using IO = System.IO;