From 573e718b576d179d44cd69dec745a151c48b36a9 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Nov 2026 08:38:14 +1100 Subject: [PATCH 1/3] move to net11 --- .editorconfig | 1 + global.json | 2 +- readme.md | 3 +- src/Benchmarks/Benchmarks.csproj | 2 +- src/Directory.Packages.props | 42 +++++++++---------- ...hQL.EntityFramework.Analyzers.Tests.csproj | 2 +- .../GraphQL.EntityFramework.csproj | 2 +- src/SampleWeb.Client/SampleWeb.Client.csproj | 2 +- src/SampleWeb.Tests/SampleWeb.Tests.csproj | 2 +- src/SampleWeb/SampleWeb.csproj | 4 +- src/Shared.sln.DotSettings | 2 + src/Snippets/Snippets.csproj | 2 +- src/Tests/Tests.csproj | 2 +- src/nuget.md | 3 +- 14 files changed, 38 insertions(+), 33 deletions(-) diff --git a/.editorconfig b/.editorconfig index b71712c19..55a077679 100644 --- a/.editorconfig +++ b/.editorconfig @@ -300,6 +300,7 @@ dotnet_style_collection_initializer = true:error dotnet_style_coalesce_expression = false:error dotnet_style_null_propagation = true:error dotnet_style_explicit_tuple_names = true:error +dotnet_style_prefer_compound_assignment = true:error # Use collection expression syntax resharper_use_collection_expression_highlighting = error diff --git a/global.json b/global.json index f75d9e14e..aad363437 100644 --- a/global.json +++ b/global.json @@ -3,7 +3,7 @@ "runner": "Microsoft.Testing.Platform" }, "sdk": { - "version": "10.0.403", + "version": "11.0.100", "allowPrerelease": true, "rollForward": "latestFeature" } diff --git a/readme.md b/readme.md index 562f26cd7..a15cf0531 100644 --- a/readme.md +++ b/readme.md @@ -29,7 +29,8 @@ Add [EntityFramework Core IQueryable](https://docs.microsoft.com/en-us/dotnet/ap ## Sponsors -### Entity Framework Extensions + +### Entity Framework Extensions [Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=GraphQL.EntityFramework) is a major sponsor and is proud to contribute to the development this project. diff --git a/src/Benchmarks/Benchmarks.csproj b/src/Benchmarks/Benchmarks.csproj index 1c5c897e3..56824c0de 100644 --- a/src/Benchmarks/Benchmarks.csproj +++ b/src/Benchmarks/Benchmarks.csproj @@ -2,7 +2,7 @@ Exe - net10.0 + net11.0 enable enable diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index e4c0f3389..44a818d0e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -7,38 +7,38 @@ - - + + - - - - - - - + + + + + + + - - - - + + + + - - - + + + - - + + - + - - + + \ No newline at end of file diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj b/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj index a1cc148df..420e84d6a 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 preview diff --git a/src/GraphQL.EntityFramework/GraphQL.EntityFramework.csproj b/src/GraphQL.EntityFramework/GraphQL.EntityFramework.csproj index 77eeaf3af..7d05c06f9 100644 --- a/src/GraphQL.EntityFramework/GraphQL.EntityFramework.csproj +++ b/src/GraphQL.EntityFramework/GraphQL.EntityFramework.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 Add EntityFramework Core IQueryable support to GraphQL true true diff --git a/src/SampleWeb.Client/SampleWeb.Client.csproj b/src/SampleWeb.Client/SampleWeb.Client.csproj index 03d754380..8fb3e97de 100644 --- a/src/SampleWeb.Client/SampleWeb.Client.csproj +++ b/src/SampleWeb.Client/SampleWeb.Client.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 false SampleWeb.Client enable diff --git a/src/SampleWeb.Tests/SampleWeb.Tests.csproj b/src/SampleWeb.Tests/SampleWeb.Tests.csproj index 49021c269..fadee9584 100644 --- a/src/SampleWeb.Tests/SampleWeb.Tests.csproj +++ b/src/SampleWeb.Tests/SampleWeb.Tests.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 false Exe $(NoWarn);xUnit1051 diff --git a/src/SampleWeb/SampleWeb.csproj b/src/SampleWeb/SampleWeb.csproj index c51ce016b..048ee0180 100644 --- a/src/SampleWeb/SampleWeb.csproj +++ b/src/SampleWeb/SampleWeb.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 false @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/src/Shared.sln.DotSettings b/src/Shared.sln.DotSettings index 76b2e545f..1f872feb9 100644 --- a/src/Shared.sln.DotSettings +++ b/src/Shared.sln.DotSettings @@ -15,6 +15,8 @@ ERROR WARNING ERROR + DO_NOT_SHOW + DO_NOT_SHOW ERROR ERROR ERROR diff --git a/src/Snippets/Snippets.csproj b/src/Snippets/Snippets.csproj index 70ce60df3..90f87f97b 100644 --- a/src/Snippets/Snippets.csproj +++ b/src/Snippets/Snippets.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 $(NoWarn);xUnit1051 false false diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 60c049d5e..d3f17c037 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,6 +1,6 @@ - net10.0 + net11.0 $(NoWarn);EF1000;xUnit1051 Exe testing diff --git a/src/nuget.md b/src/nuget.md index ea217c55f..939a3011d 100644 --- a/src/nuget.md +++ b/src/nuget.md @@ -25,7 +25,8 @@ Add [EntityFramework Core IQueryable](https://docs.microsoft.com/en-us/dotnet/ap ## Sponsors -### Entity Framework Extensions + +### Entity Framework Extensions [Entity Framework Extensions](https://entityframework-extensions.net/?utm_source=simoncropp&utm_medium=GraphQL.EntityFramework) is a major sponsor and is proud to contribute to the development this project. From 80ed6e98aba97d007badf5411d0c66ad6c3709b2 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Nov 2026 08:39:49 +1100 Subject: [PATCH 2/3] Update Directory.Build.props --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 34492a5b5..3fbba28a4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CS1591;NU5104;CS1573;CS9107;NU1608;NU1109 - 36.3.0 + 37.0.0 preview 1.0.0 EntityFrameworkCore, EntityFramework, GraphQL From 738c11f890652a313eb91fcdb7073122b3d68ed6 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 17 Nov 2026 09:00:35 +1100 Subject: [PATCH 3/3] Move tests to TUnit - Swap xunit.v3/Verify.XunitV3 for TUnit/Verify.TUnit and convert asserts to Assert.That - Unique LocalDb names for parameterized tests, NotInParallel for SampleWeb tests - Replace coverlet with Microsoft.Testing.Extensions.CodeCoverage in run-coverage.ps1 - Accept EF Core 11 SQL snapshot changes --- claude.md | 14 +- docs/configuration.md | 26 +- src/Directory.Packages.props | 6 +- ...avigationProjectionCodeFixProviderTests.cs | 11 +- .../FieldBuilderResolveAnalyzerTests.cs | 89 +++--- .../FilterIdentityProjectionAnalyzerTests.cs | 129 +++++---- ...rIdentityProjectionCodeFixProviderTests.cs | 15 +- .../GlobalUsings.cs | 1 - ...hQL.EntityFramework.Analyzers.Tests.csproj | 5 +- src/SampleWeb.Tests/GraphQlControllerTests.cs | 24 +- src/SampleWeb.Tests/SampleWeb.Tests.csproj | 6 +- src/SampleWeb.Tests/SchemaPrint.cs | 2 +- src/Snippets/Snippets.csproj | 11 - src/Tests/ArgumentProcessorTests.cs | 21 +- src/Tests/BatchFilterTests.cs | 19 +- src/Tests/CompressTests.cs | 12 +- .../ConnectionConverterTests.cs | 218 ++++++++------- .../DependencyTests.cs | 8 +- src/Tests/EfFieldBuilderTests.cs | 60 ++-- src/Tests/ExpressionBuilderTests.cs | 242 ++++++++-------- src/Tests/ExpressionBuilderTypedTests.cs | 40 +-- src/Tests/FieldBuilderExtensionsTests.cs | 50 ++-- src/Tests/GlobalUsings.cs | 1 + src/Tests/InMemoryStringComparisonTests.cs | 54 ++-- .../Graphs/WithManyChildrenGraphType.cs | 7 +- ...tch_filter_one_call_per_depth.verified.txt | 3 +- ...s_below_collection_navigation.verified.txt | 4 +- ...th_nested_navigation_property.verified.txt | 2 - ...anyToManyRightWhereAndInclude.verified.txt | 1 + ...RightWhereAndInclude_notEqual.verified.txt | 1 + ...abstract_navigation_is_loaded.verified.txt | 1 - ...IntegrationTests.Query_Cyclic.verified.txt | 6 +- ...tion_to_base_type_is_included.verified.txt | 1 - ...collection_on_navigation_list.verified.txt | 1 + .../IntegrationTests/IntegrationTests.cs | 263 +++++++++--------- .../IntegrationTests_AutoMapFilters.cs | 6 +- .../IntegrationTests_Cancellation.cs | 8 +- ...IntegrationTests_FieldBuilderExtensions.cs | 30 +- .../IntegrationTests_ForeignKeyProjection.cs | 4 +- ...ationTests_abstract_navigation_includes.cs | 2 +- ...ionTests_abstract_type_include_fallback.cs | 8 +- ...grationTests_anonymous_type_projections.cs | 8 +- .../IntegrationTests_batch_filters.cs | 36 +-- .../IntegrationTests_circular_include.cs | 4 +- ...ationTests_clr_discriminator_projection.cs | 6 +- .../IntegrationTests_concrete_tph.cs | 4 +- ...ionTests_connection_fragment_projection.cs | 10 +- ...ntegrationTests_connection_no_page_size.cs | 2 +- .../IntegrationTests_connection_ordering.cs | 4 +- ...IntegrationTests_connection_split_query.cs | 6 +- .../IntegrationTests_dbcontext_resolution.cs | 14 +- ...ntegrationTests_filter_navigation_merge.cs | 2 +- .../IntegrationTests_filter_runtime_type.cs | 12 +- .../IntegrationTests_filtered.cs | 10 +- ...grationTests_filters_without_projection.cs | 6 +- .../IntegrationTests_guarded_key.cs | 12 +- .../IntegrationTests_in_comparison.cs | 6 +- .../IntegrationTests_include_guard.cs | 4 +- ...grationTests_interface_field_projection.cs | 8 +- .../IntegrationTests_items_navigation.cs | 2 +- ...ationTests_named_type_filter_projection.cs | 8 +- ...rationTests_navigation_arguments_in_sql.cs | 18 +- .../IntegrationTests_navigation_key_order.cs | 6 +- .../IntegrationTests_navigation_merge.cs | 6 +- ...rationTests_nested_fragment_navigations.cs | 4 +- .../IntegrationTests_nested_fragments.cs | 6 +- .../IntegrationTests_nested_projection.cs | 8 +- .../IntegrationTests_null_ids.cs | 2 +- ...grationTests_nullable_value_projections.cs | 10 +- ...ationTests_query_with_select_projection.cs | 10 +- ...ationTests_readonly_navigation_fallback.cs | 28 +- .../IntegrationTests_resolve_list_filters.cs | 8 +- ...tegrationTests_resolverless_navigations.cs | 8 +- .../IntegrationTests_simple_type_overloads.cs | 22 +- .../IntegrationTests_simplified_filter_api.cs | 14 +- .../IntegrationTests_tph_base_type_include.cs | 4 +- ...IntegrationTests_tph_derived_navigation.cs | 8 +- .../IntegrationTests_typed_order_by.cs | 10 +- .../IntegrationTests_typed_where.cs | 46 +-- ...Tests_validate_projection_compatibility.cs | 38 ++- .../IntegrationTests_value_projections.cs | 10 +- .../IntegrationTests_whole_navigation.cs | 2 +- src/Tests/KeyNameExtractorTests.cs | 16 +- src/Tests/Mapping/MappingTests.cs | 8 +- .../MultiContextTests/MultiContextTests.cs | 2 +- src/Tests/ProjectionAnalyzerTests.cs | 95 ++++--- src/Tests/PropertyCacheTests.cs | 74 +++-- src/Tests/SelectExpressionBuilderTests.cs | 22 +- src/Tests/SelfReferencingWhereTests.cs | 8 +- src/Tests/SideBySideCollectionsTests.cs | 82 +++--- src/Tests/Tests.csproj | 8 +- src/Tests/TypeConverterTests.cs | 76 ++--- src/coverage.config | 24 ++ src/coverage.runsettings | 16 -- src/run-coverage.ps1 | 10 +- 95 files changed, 1150 insertions(+), 1135 deletions(-) create mode 100644 src/coverage.config delete mode 100644 src/coverage.runsettings diff --git a/claude.md b/claude.md index d08f5460a..b9ac958b2 100644 --- a/claude.md +++ b/claude.md @@ -22,16 +22,18 @@ dotnet build src --configuration Release ### Running Tests ```bash -dotnet test src --configuration Release --no-build --no-restore +dotnet test --solution src/GraphQL.EntityFramework.slnx --configuration Release --no-build --no-restore ``` +Tests run on Microsoft.Testing.Platform (see `global.json`), so filtering uses TUnit's `--treenode-filter` (`/Assembly/Namespace/Class/Test`) rather than VSTest's `--filter`. + ### Running a Single Test ```bash -# Run a specific test by fully qualified name -dotnet test src --filter "FullyQualifiedName~TestNamespace.TestClass.TestMethod" +# Run a specific test +dotnet test --project src/Tests --treenode-filter "/*/*/TestClass/TestMethod" # Run all tests in a class -dotnet test src --filter "FullyQualifiedName~TestNamespace.TestClass" +dotnet test --project src/Tests --treenode-filter "/*/*/TestClass/*" ``` ### Documentation Generation @@ -200,8 +202,8 @@ The analyzer automatically runs during build and in IDEs (Visual Studio, Rider, ## Testing Tests use: -- xUnit v3 -- Verify.XunitV3 for snapshot testing +- TUnit (`[Test]`, `[Arguments]`, `await Assert.That(...)`) +- Verify.TUnit for snapshot testing - EfLocalDb for in-memory SQL Server testing - SQL Server LocalDB for integration tests diff --git a/docs/configuration.md b/docs/configuration.md index 31bd065c8..d84b59148 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -444,6 +444,8 @@ The `GraphQlController` can be tested using the [ASP.NET Integration tests](http ```cs +// The tests share one web host and database connection, so run them one at a time +[NotInParallel] public class GraphQlControllerTests { static HttpClient client; @@ -465,7 +467,7 @@ public class GraphQlControllerTests clientQueryExecutor = new(JsonConvert.SerializeObject); } - [Fact] + [Test] public async Task Get() { var query = @@ -482,7 +484,7 @@ public class GraphQlControllerTests await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Post() { var query = @@ -499,7 +501,7 @@ public class GraphQlControllerTests await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Single() { var query = @@ -532,7 +534,7 @@ public class GraphQlControllerTests """); } - [Fact] + [Test] public async Task First() { var query = @@ -555,7 +557,7 @@ public class GraphQlControllerTests await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Single_not_found() { var query = @@ -584,7 +586,7 @@ public class GraphQlControllerTests """); } - [Fact] + [Test] public async Task First_not_found() { var query = @@ -603,10 +605,10 @@ public class GraphQlControllerTests }; var response = await clientQueryExecutor.ExecuteGet(client, query, variables); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK); } - [Fact] + [Test] public async Task Variable() { var query = @@ -641,7 +643,7 @@ public class GraphQlControllerTests """); } - [Fact] + [Test] public async Task Companies_paging() { var after = 1; @@ -666,7 +668,7 @@ public class GraphQlControllerTests await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Employee_summary() { var query = @@ -683,7 +685,7 @@ public class GraphQlControllerTests await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Complex_query_result() { var query = @@ -709,7 +711,7 @@ public class GraphQlControllerTests } } ``` -snippet source | anchor +snippet source | anchor diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 44a818d0e..51eb3768e 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -6,7 +6,6 @@ - @@ -24,7 +23,6 @@ - @@ -32,8 +30,8 @@ - - + + diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/AbstractNavigationProjectionCodeFixProviderTests.cs b/src/GraphQL.EntityFramework.Analyzers.Tests/AbstractNavigationProjectionCodeFixProviderTests.cs index f50f0b427..208b5f3bc 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/AbstractNavigationProjectionCodeFixProviderTests.cs +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/AbstractNavigationProjectionCodeFixProviderTests.cs @@ -1,6 +1,6 @@ public class AbstractNavigationProjectionCodeFixProviderTests { - [Fact] + [Test] public async Task ConvertsIdentityProjectionToExplicitProjection() { var source = """ @@ -112,9 +112,9 @@ static Document CreateDocument(string source) var requiredAssemblies = new[] { typeof(Guid).Assembly, - Assembly.Load("System.Runtime"), + System.Reflection.Assembly.Load("System.Runtime"), typeof(IQueryable<>).Assembly, - Assembly.Load("System.Security.Claims"), + System.Reflection.Assembly.Load("System.Security.Claims"), }; foreach (var assembly in requiredAssemblies) @@ -132,9 +132,8 @@ static Document CreateDocument(string source) references.All(_ => _.Display != assembly.Location)) { var name = assembly.GetName().Name ?? ""; - if ((!name.StartsWith("System.") && - !name.StartsWith("Microsoft.")) || - name.Contains("xunit", StringComparison.OrdinalIgnoreCase)) + if (!name.StartsWith("System.") && + !name.StartsWith("Microsoft.")) { continue; } diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/FieldBuilderResolveAnalyzerTests.cs b/src/GraphQL.EntityFramework.Analyzers.Tests/FieldBuilderResolveAnalyzerTests.cs index 0bacc9f9f..5bfe99b86 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/FieldBuilderResolveAnalyzerTests.cs +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/FieldBuilderResolveAnalyzerTests.cs @@ -1,6 +1,6 @@ public class FieldBuilderResolveAnalyzerTests { - [Fact] + [Test] public async Task DetectsResolveWithNavigationPropertyAccess() { var source = """ @@ -29,11 +29,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsResolveAsyncWithNavigationPropertyAccess() { var source = """ @@ -63,11 +63,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsResolveWithDirectNavigationAccess() { var source = """ @@ -95,11 +95,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task AllowsResolveWithIdPropertyAccess() { var source = """ @@ -126,10 +126,10 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task AllowsResolveWithForeignKeyAccess() { var source = """ @@ -158,10 +158,10 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task DetectsResolveWithScalarProperties() { var source = """ @@ -195,11 +195,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr var diagnostics = await GetDiagnosticsAsync(source); // Should warn because Name, Age, IsActive, CreatedDate are scalar properties, not PK/FK - Assert.Equal(2, diagnostics.Length); // Two Resolve calls - Assert.All(diagnostics, _ => Assert.Equal("GQLEF002", _.Id)); + await Assert.That(diagnostics.Length).IsEqualTo(2); // Two Resolve calls + await Assert.That(diagnostics).All(_ => _.Id == "GQLEF002"); } - [Fact] + [Test] public async Task AllowsProjectionBasedResolve() { var source = """ @@ -234,10 +234,10 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task AllowsProjectionBasedResolveAsync() { var source = """ @@ -273,10 +273,10 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task IgnoresNonEfGraphTypeClasses() { var source = """ @@ -301,10 +301,10 @@ public RegularGraphType() """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task AllowsResolveWithOnlyPKAndFK() { var source = """ @@ -334,10 +334,10 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task DetectsCollectionNavigationAccess() { var source = """ @@ -367,11 +367,11 @@ public ParentGraphType(IEfGraphQLService graphQlService) : base(g """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsResolveWithDiscardVariable() { var source = """ @@ -401,11 +401,11 @@ public ParentGraphType(IEfGraphQLService graphQlService) : base(g """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsResolveAsyncWithDiscardVariable() { var source = """ @@ -435,11 +435,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsResolveAsyncWithElidedDelegate() { var source = """ @@ -469,11 +469,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF002", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF002"); } - [Fact] + [Test] public async Task DetectsIdentityProjectionInProjectionBasedResolve() { var source = """ @@ -504,11 +504,11 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF003", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF003"); } - [Fact] + [Test] public async Task DetectsIdentityProjectionInProjectionBasedResolveAsyncWithPositionalArguments() { var source = """ @@ -540,8 +540,8 @@ public ChildGraphType(IEfGraphQLService graphQlService) : base(gr """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF003", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF003"); } static async Task GetDiagnosticsAsync(string source) @@ -582,9 +582,8 @@ static async Task GetDiagnosticsAsync(string source) references.All(_ => _.Display != assembly.Location)) { var name = assembly.GetName().Name ?? ""; - if ((!name.StartsWith("System.") && - !name.StartsWith("Microsoft.")) || - name.Contains("xunit", StringComparison.OrdinalIgnoreCase)) + if (!name.StartsWith("System.") && + !name.StartsWith("Microsoft.")) { continue; } diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionAnalyzerTests.cs b/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionAnalyzerTests.cs index c347fe14a..ffebb6441 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionAnalyzerTests.cs +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionAnalyzerTests.cs @@ -2,7 +2,7 @@ public class FilterIdentityProjectionAnalyzerTests { // GQLEF004 Tests - Suggest simplified API - [Fact] + [Test] public async Task GQLEF004_SuggestsSimplifiedAPI_ForIdentityProjectionWithPKAccess() { var source = """ @@ -30,11 +30,11 @@ public void ConfigureFilters(Filters filters, Guid targetId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF004", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF004"); } - [Fact] + [Test] public async Task GQLEF004_SuggestsSimplifiedAPI_ForIdentityProjectionWithFKAccess() { var source = """ @@ -62,11 +62,11 @@ public void ConfigureFilters(Filters filters, Guid targetId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF004", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF004"); } - [Fact] + [Test] public async Task GQLEF004_SuggestsSimplifiedAPI_ForIdentityProjectionWithMultipleFKAccess() { var source = """ @@ -95,11 +95,11 @@ public void ConfigureFilters(Filters filters, Guid parentId, int """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF004", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF004"); } - [Fact] + [Test] public async Task GQLEF004_NoWarning_ForNonIdentityProjection() { var source = """ @@ -127,12 +127,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } // GQLEF005 Tests - Invalid simplified API usage - [Fact] + [Test] public async Task GQLEF005_Error_ForSimplifiedAPIAccessingScalarProperty() { var source = """ @@ -159,12 +159,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF005", diagnostics[0].Id); - Assert.Contains("Name", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF005"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Name"); } - [Fact] + [Test] public async Task GQLEF005_Error_ForSimplifiedAPIAccessingNavigationProperty() { var source = """ @@ -193,12 +193,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF005", diagnostics[0].Id); - Assert.Contains("Parent", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF005"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Parent"); } - [Fact] + [Test] public async Task GQLEF005_NoError_ForSimplifiedAPIAccessingPK() { var source = """ @@ -225,10 +225,10 @@ public void ConfigureFilters(Filters filters, Guid targetId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task GQLEF005_NoError_ForSimplifiedAPIAccessingFK() { var source = """ @@ -255,10 +255,10 @@ public void ConfigureFilters(Filters filters, Guid parentId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task GQLEF005_NoError_ForSimplifiedAPIAccessingNullableFK() { var source = """ @@ -285,12 +285,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } // GQLEF006 Tests - Invalid identity projection with existing API - [Fact] + [Test] public async Task GQLEF006_Error_ForIdentityProjectionAccessingScalarProperty() { var source = """ @@ -318,12 +318,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF006", diagnostics[0].Id); - Assert.Contains("City", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF006"); + await Assert.That(diagnostics[0].GetMessage()).Contains("City"); } - [Fact] + [Test] public async Task GQLEF006_Error_ForIdentityProjectionAccessingNavigationProperty() { var source = """ @@ -352,14 +352,14 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF006", diagnostics[0].Id); - Assert.Contains("Parent", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF006"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Parent"); } // Edge Cases - [Fact] + [Test] public async Task EdgeCase_DiscardParameter() { var source = """ @@ -385,10 +385,10 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task EdgeCase_TypeNameWithEntitySuffix() { var source = """ @@ -415,10 +415,10 @@ public void ConfigureFilters(Filters filters, Guid companyId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task EdgeCase_ComplexExpression() { var source = """ @@ -447,10 +447,10 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task EdgeCase_MultiplePropertyAccess() { var source = """ @@ -481,12 +481,12 @@ public void ConfigureFilters(Filters filters, Guid parentId) var diagnostics = await GetDiagnosticsAsync(source); // Should report error for Name access (first non-key property encountered) - Assert.Single(diagnostics); - Assert.Equal("GQLEF006", diagnostics[0].Id); - Assert.Contains("Name", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF006"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Name"); } - [Fact] + [Test] public async Task EdgeCase_AsyncFilter() { var source = """ @@ -518,7 +518,7 @@ public void ConfigureFilters(Filters filters, Guid parentId) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } static async Task GetDiagnosticsAsync(string source) @@ -540,11 +540,11 @@ static async Task GetDiagnosticsAsync(string source) { typeof(Guid).Assembly, // System.Runtime - Assembly.Load("System.Runtime"), + System.Reflection.Assembly.Load("System.Runtime"), // System.Linq.Expressions typeof(IQueryable<>).Assembly, // System.Security.Claims - Assembly.Load("System.Security.Claims"), + System.Reflection.Assembly.Load("System.Security.Claims"), }; foreach (var assembly in requiredAssemblies) @@ -563,9 +563,8 @@ static async Task GetDiagnosticsAsync(string source) references.All(_ => _.Display != assembly.Location)) { var name = assembly.GetName().Name ?? ""; - if ((!name.StartsWith("System.") && - !name.StartsWith("Microsoft.")) || - name.Contains("xunit", StringComparison.OrdinalIgnoreCase)) + if (!name.StartsWith("System.") && + !name.StartsWith("Microsoft.")) { continue; } @@ -610,7 +609,7 @@ static async Task GetDiagnosticsAsync(string source) // GQLEF007 Tests - Identity projection with abstract navigation access - [Fact] + [Test] public async Task GQLEF007_Reports_IdentityProjection_WithAbstractNavigationAccess() { var source = """ @@ -647,12 +646,12 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF007", diagnostics[0].Id); - Assert.Contains("Parent", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF007"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Parent"); } - [Fact] + [Test] public async Task GQLEF007_Reports_FourParamFilter_WithAbstractNavigationAccess() { var source = """ @@ -685,11 +684,11 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF007", diagnostics[0].Id); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF007"); } - [Fact] + [Test] public async Task GQLEF007_NoReport_ConcreteNavigationAccess() { var source = """ @@ -724,10 +723,10 @@ public void ConfigureFilters(Filters filters) var diagnostics = await GetDiagnosticsAsync(source); // Should report GQLEF006 (non-key property access) but not GQLEF007 - Assert.DoesNotContain(diagnostics, d => d.Id == "GQLEF007"); + await Assert.That(diagnostics).DoesNotContain(d => d.Id == "GQLEF007"); } - [Fact] + [Test] public async Task GQLEF007_NoReport_ExplicitProjection_WithAbstractNavigation() { var source = """ @@ -762,10 +761,10 @@ public void ConfigureFilters(Filters filters) var diagnostics = await GetDiagnosticsAsync(source); // Explicit projection - analyzer doesn't catch this (runtime does) - Assert.Empty(diagnostics); + await Assert.That(diagnostics).IsEmpty(); } - [Fact] + [Test] public async Task GQLEF007_Reports_NestedAbstractNavigationAccess() { var source = """ @@ -800,8 +799,8 @@ public void ConfigureFilters(Filters filters) """; var diagnostics = await GetDiagnosticsAsync(source); - Assert.Single(diagnostics); - Assert.Equal("GQLEF007", diagnostics[0].Id); - Assert.Contains("Parent", diagnostics[0].GetMessage()); + await Assert.That(diagnostics).HasSingleItem(); + await Assert.That(diagnostics[0].Id).IsEqualTo("GQLEF007"); + await Assert.That(diagnostics[0].GetMessage()).Contains("Parent"); } } diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionCodeFixProviderTests.cs b/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionCodeFixProviderTests.cs index b932cff49..cc91ac1c7 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionCodeFixProviderTests.cs +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/FilterIdentityProjectionCodeFixProviderTests.cs @@ -1,6 +1,6 @@ public class FilterIdentityProjectionCodeFixProviderTests { - [Fact] + [Test] public async Task RemovesIdentityProjectionParameter() { var source = """ @@ -30,7 +30,7 @@ public void ConfigureFilters(Filters filters, Guid targetId) await Verify(result); } - [Fact] + [Test] public async Task RemovesIdentityProjectionParameter_WithMultilineFormatting() { var source = """ @@ -64,7 +64,7 @@ public void ConfigureFilters(Filters filters) await Verify(result); } - [Fact] + [Test] public async Task RemovesIdentityProjectionParameter_PreservesFilterFormatting() { var source = """ @@ -169,9 +169,9 @@ static Document CreateDocument(string source) var requiredAssemblies = new[] { typeof(Guid).Assembly, - Assembly.Load("System.Runtime"), + System.Reflection.Assembly.Load("System.Runtime"), typeof(IQueryable<>).Assembly, - Assembly.Load("System.Security.Claims"), + System.Reflection.Assembly.Load("System.Security.Claims"), }; foreach (var assembly in requiredAssemblies) @@ -189,9 +189,8 @@ static Document CreateDocument(string source) references.All(_ => _.Display != assembly.Location)) { var name = assembly.GetName().Name ?? ""; - if ((!name.StartsWith("System.") && - !name.StartsWith("Microsoft.")) || - name.Contains("xunit", StringComparison.OrdinalIgnoreCase)) + if (!name.StartsWith("System.") && + !name.StartsWith("Microsoft.")) { continue; } diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/GlobalUsings.cs b/src/GraphQL.EntityFramework.Analyzers.Tests/GlobalUsings.cs index 2a5838ee4..846e49e29 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/GlobalUsings.cs +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/GlobalUsings.cs @@ -8,4 +8,3 @@ global using Microsoft.CodeAnalysis.CSharp; global using Microsoft.CodeAnalysis.Diagnostics; global using Microsoft.EntityFrameworkCore; -global using Xunit; diff --git a/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj b/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj index 420e84d6a..1a8f7aaaf 100644 --- a/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj +++ b/src/GraphQL.EntityFramework.Analyzers.Tests/GraphQL.EntityFramework.Analyzers.Tests.csproj @@ -7,14 +7,13 @@ - - + + - diff --git a/src/SampleWeb.Tests/GraphQlControllerTests.cs b/src/SampleWeb.Tests/GraphQlControllerTests.cs index cfe640284..2831bfa26 100644 --- a/src/SampleWeb.Tests/GraphQlControllerTests.cs +++ b/src/SampleWeb.Tests/GraphQlControllerTests.cs @@ -5,6 +5,8 @@ #region GraphQlControllerTests +// The tests share one web host and database connection, so run them one at a time +[NotInParallel] public class GraphQlControllerTests { static HttpClient client; @@ -26,7 +28,7 @@ static GraphQlControllerTests() clientQueryExecutor = new(JsonConvert.SerializeObject); } - [Fact] + [Test] public async Task Get() { var query = @@ -43,7 +45,7 @@ public async Task Get() await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Post() { var query = @@ -60,7 +62,7 @@ public async Task Post() await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Single() { var query = @@ -93,7 +95,7 @@ await Verify(await response.Content.ReadAsStringAsync()) """); } - [Fact] + [Test] public async Task First() { var query = @@ -116,7 +118,7 @@ public async Task First() await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Single_not_found() { var query = @@ -145,7 +147,7 @@ await ThrowsTask(() => clientQueryExecutor.ExecuteGet(client, query, variables)) """); } - [Fact] + [Test] public async Task First_not_found() { var query = @@ -164,10 +166,10 @@ public async Task First_not_found() }; var response = await clientQueryExecutor.ExecuteGet(client, query, variables); - Assert.Equal(HttpStatusCode.OK, response.StatusCode); + await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.OK); } - [Fact] + [Test] public async Task Variable() { var query = @@ -202,7 +204,7 @@ await Verify(await response.Content.ReadAsStringAsync()) """); } - [Fact] + [Test] public async Task Companies_paging() { var after = 1; @@ -227,7 +229,7 @@ public async Task Companies_paging() await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Employee_summary() { var query = @@ -244,7 +246,7 @@ public async Task Employee_summary() await Verify(await response.Content.ReadAsStringAsync()); } - [Fact] + [Test] public async Task Complex_query_result() { var query = diff --git a/src/SampleWeb.Tests/SampleWeb.Tests.csproj b/src/SampleWeb.Tests/SampleWeb.Tests.csproj index fadee9584..c9770b330 100644 --- a/src/SampleWeb.Tests/SampleWeb.Tests.csproj +++ b/src/SampleWeb.Tests/SampleWeb.Tests.csproj @@ -3,20 +3,18 @@ net11.0 false Exe - $(NoWarn);xUnit1051 - - + + - diff --git a/src/SampleWeb.Tests/SchemaPrint.cs b/src/SampleWeb.Tests/SchemaPrint.cs index 60ce6a08c..26120910f 100644 --- a/src/SampleWeb.Tests/SchemaPrint.cs +++ b/src/SampleWeb.Tests/SchemaPrint.cs @@ -2,7 +2,7 @@ public class SchemaPrint { - [Fact] + [Test] public async Task Print() { var services = new ServiceCollection(); diff --git a/src/Snippets/Snippets.csproj b/src/Snippets/Snippets.csproj index 90f87f97b..65dbfd242 100644 --- a/src/Snippets/Snippets.csproj +++ b/src/Snippets/Snippets.csproj @@ -1,23 +1,12 @@ net11.0 - $(NoWarn);xUnit1051 - false - false - - - - - - - - diff --git a/src/Tests/ArgumentProcessorTests.cs b/src/Tests/ArgumentProcessorTests.cs index 0916333c2..0a1a87d7b 100644 --- a/src/Tests/ArgumentProcessorTests.cs +++ b/src/Tests/ArgumentProcessorTests.cs @@ -2,8 +2,8 @@ { // The in memory path assumed the key is named Id, so an entity keyed by anything else failed // on the ids argument, while the queryable path resolved the key from the model. - [Fact] - public void Ids_use_key_name_from_model() + [Test] + public async Task Ids_use_key_name_from_model() { var entity1 = new NamedIdEntity { @@ -23,11 +23,12 @@ public void Ids_use_key_name_from_model() .ApplyGraphQlArguments(["NamedId"], context, false) .ToList(); - Assert.Equal(["one"], result.Select(_ => _.Property)); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) ["one"], CollectionOrdering.Matching); } - [Fact] - public void Ids_default_to_Id_for_the_hasId_overload() + [Test] + public async Task Ids_default_to_Id_for_the_hasId_overload() { var entity1 = new ParentEntity { @@ -47,12 +48,13 @@ public void Ids_default_to_Id_for_the_hasId_overload() .ApplyGraphQlArguments(true, context, false) .ToList(); - Assert.Equal(["two"], result.Select(_ => _.Property)); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) ["two"], CollectionOrdering.Matching); } // A null ids was dereferenced for its type name in the unsupported type error - [Fact] - public void Null_ids_is_the_same_as_no_ids() + [Test] + public async Task Null_ids_is_the_same_as_no_ids() { var context = BuildContext(null); @@ -70,7 +72,8 @@ public void Null_ids_is_the_same_as_no_ids() .ApplyGraphQlArguments(true, context, false) .ToList(); - Assert.Equal(["one", "two"], result.Select(_ => _.Property)); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) ["one", "two"], CollectionOrdering.Matching); } static ResolveFieldContext BuildContext(Guid? id) => diff --git a/src/Tests/BatchFilterTests.cs b/src/Tests/BatchFilterTests.cs index 30f63b569..b8ea72e5d 100644 --- a/src/Tests/BatchFilterTests.cs +++ b/src/Tests/BatchFilterTests.cs @@ -1,7 +1,7 @@ // Outside an execution there is no batch to share, so a batch filter runs over the items it is given public class BatchFilterTests { - [Fact] + [Test] public async Task ApplyFilter_passes_the_items_in_one_call() { var calls = new List>(); @@ -28,12 +28,13 @@ public async Task ApplyFilter_passes_the_items_in_one_call() var result = await filters.ApplyFilter(items, new(), null!, null); - Assert.Equal(["Value1", "Value1", "Value2"], result.Select(_ => _.Property)); - var call = Assert.Single(calls); - Assert.Equal(["Ignore", "Value1", "Value2"], call); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) ["Value1", "Value1", "Value2"], CollectionOrdering.Matching); + var call = await Assert.That(calls).HasSingleItem(); + await Assert.That(call).IsEquivalentTo((string?[]) ["Ignore", "Value1", "Value2"], CollectionOrdering.Matching); } - [Fact] + [Test] public async Task ShouldInclude_passes_the_item() { var calls = new List>(); @@ -56,9 +57,11 @@ public async Task ShouldInclude_passes_the_item() Property = "Ignore" }); - Assert.True(kept); - Assert.False(ignored); - Assert.Equal([["Value1"], ["Ignore"]], calls); + await Assert.That(kept).IsTrue(); + await Assert.That(ignored).IsFalse(); + await Assert.That(calls).Count().IsEqualTo(2); + await Assert.That(calls[0]).IsEquivalentTo((string?[]) ["Value1"], CollectionOrdering.Matching); + await Assert.That(calls[1]).IsEquivalentTo((string?[]) ["Ignore"], CollectionOrdering.Matching); } static Filters BuildFilters(List> calls) diff --git a/src/Tests/CompressTests.cs b/src/Tests/CompressTests.cs index 6fc9ad04e..680a17658 100644 --- a/src/Tests/CompressTests.cs +++ b/src/Tests/CompressTests.cs @@ -1,6 +1,6 @@ public class CompressTests { - [Fact] + [Test] public Task Simple() { var query = @@ -17,7 +17,7 @@ public Task Simple() .Snapshot("query($id:String!){companies(ids:[$id]){id}}"); } - [Fact] + [Test] public Task StringLiteralIsPreserved() { // whitespace inside a literal is significant, and stripping it silently queried for @@ -27,7 +27,7 @@ public Task StringLiteralIsPreserved() .Snapshot("""{users(where:{path:"name",comparison:equal,value:"Smith, John: Jr"}){id}}"""); } - [Fact] + [Test] public Task EscapedQuoteDoesNotEndTheLiteral() { var query = """{users(where: {value: "a \" b, c"}){id}}"""; @@ -35,7 +35,7 @@ public Task EscapedQuoteDoesNotEndTheLiteral() .Snapshot("""{users(where:{value:"a \" b, c"}){id}}"""); } - [Fact] + [Test] public Task BlockStringIsPreserved() { var query = "{users(where: {value: \"\"\"a, b: c\"\"\"}){id}}"; @@ -43,7 +43,7 @@ public Task BlockStringIsPreserved() .Snapshot("{users(where:{value:\"\"\"a, b: c\"\"\"}){id}}"); } - [Fact] + [Test] public Task CommentIsRemovedWithoutSwallowingTheQuery() { // collapsing the newline into a space would pull the rest of the query into the comment @@ -60,7 +60,7 @@ public Task CommentIsRemovedWithoutSwallowingTheQuery() .Snapshot("{users{id}}"); } - [Fact] + [Test] public Task NamesStaySeparated() => Verify(Compress.Query("query Named { users { id name } }")) .Snapshot("query Named{users{id name}}"); diff --git a/src/Tests/ConnectionConverter/ConnectionConverterTests.cs b/src/Tests/ConnectionConverter/ConnectionConverterTests.cs index 53a022aac..5409857e2 100644 --- a/src/Tests/ConnectionConverter/ConnectionConverterTests.cs +++ b/src/Tests/ConnectionConverter/ConnectionConverterTests.cs @@ -14,110 +14,110 @@ static ConnectionConverterTests() => static SqlInstance sqlInstance; - [Theory] + [Test] //no page size, the whole set - [InlineData(null, null, null, null)] + [Arguments(null, null, null, null)] //first after - [InlineData(1, 0, null, null)] - [InlineData(2, null, null, null)] - [InlineData(2, 1, null, null)] - [InlineData(3, null, null, null)] - [InlineData(3, 1, null, null)] - [InlineData(10, null, null, null)] - [InlineData(10, 1, null, null)] - [InlineData(11, null, null, null)] - [InlineData(11, 1, null, null)] + [Arguments(1, 0, null, null)] + [Arguments(2, null, null, null)] + [Arguments(2, 1, null, null)] + [Arguments(3, null, null, null)] + [Arguments(3, 1, null, null)] + [Arguments(10, null, null, null)] + [Arguments(10, 1, null, null)] + [Arguments(11, null, null, null)] + [Arguments(11, 1, null, null)] //first before - [InlineData(2, null, null, 2)] - [InlineData(3, null, null, 2)] - [InlineData(2, null, null, 3)] + [Arguments(2, null, null, 2)] + [Arguments(3, null, null, 2)] + [Arguments(2, null, null, 3)] //first after before - [InlineData(2, 2, null, 8)] - [InlineData(20, 2, null, 5)] + [Arguments(2, 2, null, 8)] + [Arguments(20, 2, null, 5)] //last before - [InlineData(null, null, 2, null)] - [InlineData(null, null, 2, 8)] + [Arguments(null, null, 2, null)] + [Arguments(null, null, 2, 8)] //last after - [InlineData(null, 7, 2, null)] - [InlineData(null, 3, 2, null)] + [Arguments(null, 7, 2, null)] + [Arguments(null, 3, 2, null)] //last after before - [InlineData(null, 2, 2, 8)] - [InlineData(null, 2, 20, 5)] + [Arguments(null, 2, 2, 8)] + [Arguments(null, 2, 20, 5)] //first and last - [InlineData(5, 1, 2, null)] + [Arguments(5, 1, 2, null)] //last larger than the available range - [InlineData(null, null, 20, null)] - [InlineData(null, null, 5, 2)] + [Arguments(null, null, 20, null)] + [Arguments(null, null, 5, 2)] //empty window - [InlineData(2, null, null, 0)] - [InlineData(2, 9, null, null)] - [InlineData(2, 5, null, 3)] + [Arguments(2, null, null, 0)] + [Arguments(2, 9, null, null)] + [Arguments(2, 5, null, 3)] public async Task Queryable(int? first, int? after, int? last, int? before) { var fieldContext = new ResolveFieldContext(); - await using var database = await sqlInstance.Build(databaseSuffix: $"{first.GetValueOrDefault(0)}{after.GetValueOrDefault(0)}{last.GetValueOrDefault(0)}{before.GetValueOrDefault(0)}"); + await using var database = await sqlInstance.Build(databaseSuffix: $"{first}_{after}_{last}_{before}"); var entities = database.Context.Entities; var connection = await ConnectionConverter.ApplyConnectionContext(entities.OrderBy(x=>x.Property), first, after, last, before, fieldContext, new(), Cancel.None,database.Context); await Verify(connection.Items!.OrderBy(_ => _!.Property)) .UseParameters(first, after, last, before); } - [Theory] + [Test] //no page size, the whole set - [InlineData(null, null, null, null)] + [Arguments(null, null, null, null)] //first after - [InlineData(1, 0, null, null)] - [InlineData(2, null, null, null)] - [InlineData(2, 1, null, null)] - [InlineData(3, null, null, null)] - [InlineData(3, 1, null, null)] - [InlineData(10, null, null, null)] - [InlineData(10, 1, null, null)] - [InlineData(11, null, null, null)] - [InlineData(11, 1, null, null)] + [Arguments(1, 0, null, null)] + [Arguments(2, null, null, null)] + [Arguments(2, 1, null, null)] + [Arguments(3, null, null, null)] + [Arguments(3, 1, null, null)] + [Arguments(10, null, null, null)] + [Arguments(10, 1, null, null)] + [Arguments(11, null, null, null)] + [Arguments(11, 1, null, null)] //first before - [InlineData(2, null, null, 2)] - [InlineData(3, null, null, 2)] - [InlineData(2, null, null, 3)] + [Arguments(2, null, null, 2)] + [Arguments(3, null, null, 2)] + [Arguments(2, null, null, 3)] //first after before - [InlineData(2, 2, null, 8)] - [InlineData(20, 2, null, 5)] + [Arguments(2, 2, null, 8)] + [Arguments(20, 2, null, 5)] //last before - [InlineData(null, null, 2, null)] - [InlineData(null, null, 2, 8)] + [Arguments(null, null, 2, null)] + [Arguments(null, null, 2, 8)] //last after - [InlineData(null, 7, 2, null)] - [InlineData(null, 3, 2, null)] + [Arguments(null, 7, 2, null)] + [Arguments(null, 3, 2, null)] //last after before - [InlineData(null, 2, 2, 8)] - [InlineData(null, 2, 20, 5)] + [Arguments(null, 2, 2, 8)] + [Arguments(null, 2, 20, 5)] //first and last - [InlineData(5, 1, 2, null)] + [Arguments(5, 1, 2, null)] //last larger than the available range - [InlineData(null, null, 20, null)] - [InlineData(null, null, 5, 2)] + [Arguments(null, null, 20, null)] + [Arguments(null, null, 5, 2)] //empty window - [InlineData(2, null, null, 0)] - [InlineData(2, 9, null, null)] - [InlineData(2, 5, null, 3)] + [Arguments(2, null, null, 0)] + [Arguments(2, 9, null, null)] + [Arguments(2, 5, null, 3)] public Task List(int? first, int? after, int? last, int? before) { var connection = ConnectionConverter.ApplyConnectionContext(list, first, after, last, before); @@ -125,92 +125,96 @@ public Task List(int? first, int? after, int? last, int? before) .UseParameters(first, after, last, before); } - [Theory] - [InlineData("not-a-number")] - [InlineData("")] - [InlineData("1.5")] - [InlineData("9999999999999999999")] - public void Malformed_cursor_reports_bad_input(string cursor) + [Test] + [Arguments("not-a-number")] + [Arguments("")] + [Arguments("1.5")] + [Arguments("9999999999999999999")] + public async Task Malformed_cursor_reports_bad_input(string cursor) { // cursors are client supplied, so a malformed one must not surface as a raw FormatException - var exception = Assert.Throws( + var exception = Assert.ThrowsExactly( () => ConnectionConverter.ApplyConnectionContext(list, 2, cursor, null, null)); - Assert.Contains("cursor must be an integer", exception.Message); + await Assert.That(exception.Message).Contains("cursor must be an integer"); } - [Fact] - public void Negative_after_cursor_is_rejected() + [Test] + public async Task Negative_after_cursor_is_rejected() { // a negative cursor previously parsed happily and reached the database as a negative OFFSET - var exception = Assert.Throws( + var exception = Assert.ThrowsExactly( () => ConnectionConverter.ApplyConnectionContext(list, 2, "-5", null, null)); - Assert.Contains("cursor cannot be negative", exception.Message); + await Assert.That(exception.Message).Contains("cursor cannot be negative"); } - [Fact] - public void Negative_before_cursor_is_rejected() + [Test] + public async Task Negative_before_cursor_is_rejected() { - var exception = Assert.Throws( + var exception = Assert.ThrowsExactly( () => ConnectionConverter.ApplyConnectionContext(list, 2, null, null, "-5")); - Assert.Contains("cursor cannot be negative", exception.Message); + await Assert.That(exception.Message).Contains("cursor cannot be negative"); } - [Fact] - public void Large_first_does_not_overflow_page_info() + [Test] + public async Task Large_first_does_not_overflow_page_info() { // take + skip overflowed to negative, so HasNextPage reported true on a fully covered page var connection = ConnectionConverter.ApplyConnectionContext(list, int.MaxValue, after: 0, last: null, before: null); - Assert.False(connection.PageInfo!.HasNextPage); - Assert.Equal("9", connection.PageInfo.EndCursor); + await Assert.That(connection.PageInfo!.HasNextPage).IsFalse(); + await Assert.That(connection.PageInfo.EndCursor).IsEqualTo("9"); } // The in memory path reversed the page for `last` while numbering the cursors ascending, so // cursor 8 sat on item j. Edges keep their order whichever end the page was taken from. - [Fact] - public void Last_keeps_edge_order_and_cursors() + [Test] + public async Task Last_keeps_edge_order_and_cursors() { var connection = ConnectionConverter.ApplyConnectionContext(list, first: null, after: null, last: 2, before: null); - Assert.Equal(["i", "j"], connection.Edges!.Select(_ => _.Node)); - Assert.Equal(["8", "9"], connection.Edges!.Select(_ => _.Cursor)); - Assert.Equal("8", connection.PageInfo!.StartCursor); - Assert.Equal("9", connection.PageInfo.EndCursor); + await Assert.That(connection.Edges!.Select(_ => _.Node)) + .IsEquivalentTo((string?[]) ["i", "j"], CollectionOrdering.Matching); + await Assert.That(connection.Edges!.Select(_ => _.Cursor)) + .IsEquivalentTo((string?[]) ["8", "9"], CollectionOrdering.Matching); + await Assert.That(connection.PageInfo!.StartCursor).IsEqualTo("8"); + await Assert.That(connection.PageInfo.EndCursor).IsEqualTo("9"); } - [Fact] - public void First_before_takes_from_the_start_of_the_window() + [Test] + public async Task First_before_takes_from_the_start_of_the_window() { // first: 2 before: 5 is a, b, not the two items before the cursor var connection = ConnectionConverter.ApplyConnectionContext(list, first: 2, after: null, last: null, before: 5); - Assert.Equal(["a", "b"], connection.Edges!.Select(_ => _.Node)); - Assert.True(connection.PageInfo!.HasNextPage); - Assert.False(connection.PageInfo.HasPreviousPage); + await Assert.That(connection.Edges!.Select(_ => _.Node)) + .IsEquivalentTo((string?[]) ["a", "b"], CollectionOrdering.Matching); + await Assert.That(connection.PageInfo!.HasNextPage).IsTrue(); + await Assert.That(connection.PageInfo.HasPreviousPage).IsFalse(); } - [Fact] - public void Last_after_takes_from_the_end_of_the_window() + [Test] + public async Task Last_after_takes_from_the_end_of_the_window() { // last: 2 after: 3 is i, j, not the two items after the cursor var connection = ConnectionConverter.ApplyConnectionContext(list, first: null, after: 3, last: 2, before: null); - Assert.Equal(["i", "j"], connection.Edges!.Select(_ => _.Node)); - Assert.False(connection.PageInfo!.HasNextPage); - Assert.True(connection.PageInfo.HasPreviousPage); + await Assert.That(connection.Edges!.Select(_ => _.Node)) + .IsEquivalentTo((string?[]) ["i", "j"], CollectionOrdering.Matching); + await Assert.That(connection.PageInfo!.HasNextPage).IsFalse(); + await Assert.That(connection.PageInfo.HasPreviousPage).IsTrue(); } - [Fact] - public void Empty_page_has_null_cursors() + [Test] + public async Task Empty_page_has_null_cursors() { // an empty connection reported startCursor 0 and endCursor -1 var connection = ConnectionConverter.ApplyConnectionContext(new List(), first: 2, after: null, last: null, before: null); - Assert.Empty(connection.Edges!); - Assert.Null(connection.PageInfo!.StartCursor); - Assert.Null(connection.PageInfo.EndCursor); - Assert.False(connection.PageInfo.HasNextPage); - Assert.False(connection.PageInfo.HasPreviousPage); + await Assert.That(connection.Edges!).IsEmpty(); + await Assert.That(connection.PageInfo!.StartCursor).IsNull(); + await Assert.That(connection.PageInfo.EndCursor).IsNull(); + await Assert.That(connection.PageInfo.HasNextPage).IsFalse(); + await Assert.That(connection.PageInfo.HasPreviousPage).IsFalse(); } - [Fact] - public void List_after_is_an_exclusive_cursor() + [Test] + public async Task List_after_is_an_exclusive_cursor() { // 'after' is an exclusive cursor: results start strictly after the given index, // matching the IQueryable path and the Relay connection spec. @@ -218,20 +222,20 @@ public void List_after_is_an_exclusive_cursor() var items = connection.Items! .Select(_ => _!) .ToList(); - Assert.Equal(new[] {"c", "d"}, items); + await Assert.That(items).IsEquivalentTo(new[] {"c", "d"}, CollectionOrdering.Matching); } - [Fact] - public void List_HasPreviousPage_true_when_page_size_covers_remaining_items() + [Test] + public async Task List_HasPreviousPage_true_when_page_size_covers_remaining_items() { // first(10) covers all remaining items, but after(0) skips the first item, // so a previous page exists. Previously the 'take < count' guard hid this. var connection = ConnectionConverter.ApplyConnectionContext(list, first: 10, after: 0, last: null, before: null); - Assert.True(connection.PageInfo!.HasPreviousPage); + await Assert.That(connection.PageInfo!.HasPreviousPage).IsTrue(); var first = connection.Items! .Select(_ => _!) .First(); - Assert.Equal("b", first); + await Assert.That(first).IsEqualTo("b"); } public class Entity diff --git a/src/Tests/DependencyResolutionTests/DependencyTests.cs b/src/Tests/DependencyResolutionTests/DependencyTests.cs index b78686795..27af03515 100644 --- a/src/Tests/DependencyResolutionTests/DependencyTests.cs +++ b/src/Tests/DependencyResolutionTests/DependencyTests.cs @@ -14,7 +14,7 @@ static DependencyTests() => } """; - [Fact] + [Test] public async Task ExplicitModel() { await using var database = await sqlInstance.Build(); @@ -39,7 +39,7 @@ public async Task ExplicitModel() await ExecutionResultData(executionOptions); } - [Fact] + [Test] public async Task ScopedDbContext() { await using var database = await sqlInstance.Build(); @@ -64,7 +64,7 @@ public async Task ScopedDbContext() await ExecutionResultData(executionOptions); } - [Fact] + [Test] public async Task TransientDbContext() { await using var database = await sqlInstance.Build(); @@ -89,7 +89,7 @@ public async Task TransientDbContext() await ExecutionResultData(options); } - [Fact] + [Test] public async Task SingletonDbContext() { await using var database = await sqlInstance.Build(); diff --git a/src/Tests/EfFieldBuilderTests.cs b/src/Tests/EfFieldBuilderTests.cs index ea734ce7b..3839acd61 100644 --- a/src/Tests/EfFieldBuilderTests.cs +++ b/src/Tests/EfFieldBuilderTests.cs @@ -14,8 +14,8 @@ class TestGraphType(IEfGraphQLService graphQlService) : // The service is not touched when defining fields, so none is required static TestGraphType BuildGraphType() => new(null!); - [Fact] - public void Field_returns_EfFieldBuilder_through_fluent_chain() + [Test] + public async Task Field_returns_EfFieldBuilder_through_fluent_chain() { var graphType = BuildGraphType(); @@ -25,28 +25,32 @@ public void Field_returns_EfFieldBuilder_through_fluent_chain() .Argument("argument") .Configure(_ => _.Metadata["key"] = "value"); - Assert.IsType>(builder); - Assert.Equal("description", builder.FieldType.Description); - Assert.Equal("reason", builder.FieldType.DeprecationReason); - Assert.Equal("value", builder.FieldType.Metadata["key"]); - Assert.NotNull(builder.FieldType.Arguments?.Find("argument")); + await Assert.That(builder).IsTypeOf>(); + await Assert.That(builder.FieldType.Description).IsEqualTo("description"); + await Assert.That(builder.FieldType.DeprecationReason).IsEqualTo("reason"); + await Assert.That(builder.FieldType.Metadata["key"]).IsEqualTo("value"); + await Assert.That(builder.FieldType.Arguments?.Find("argument")).IsNotNull(); } - [Fact] - public void Field_overloads_return_EfFieldBuilder() + [Test] + public async Task Field_overloads_return_EfFieldBuilder() { var graphType = BuildGraphType(); - Assert.IsType>(graphType.Field("a")); - Assert.IsType>(graphType.Field("b")); - Assert.IsType>(graphType.Field("c", typeof(IntGraphType))); - Assert.IsType>(graphType.Field("d", new IntGraphType())); - Assert.IsType>(graphType.Field("e", _ => _.Id)); - Assert.IsType>(graphType.Field(_ => _.Id)); + await Assert.That(graphType.Field("a")) + .IsTypeOf>(); + await Assert.That(graphType.Field("b")) + .IsTypeOf>(); + await Assert.That(graphType.Field("c", typeof(IntGraphType))) + .IsTypeOf>(); + await Assert.That(graphType.Field("d", new IntGraphType())) + .IsTypeOf>(); + await Assert.That(graphType.Field("e", _ => _.Id)).IsTypeOf>(); + await Assert.That(graphType.Field(_ => _.Id)).IsTypeOf>(); } - [Fact] - public void Resolve_with_projection_after_fluent_chain() + [Test] + public async Task Resolve_with_projection_after_fluent_chain() { var graphType = BuildGraphType(); @@ -57,36 +61,36 @@ public void Resolve_with_projection_after_fluent_chain() resolve: _ => _.Projection?.Id ?? 0) .DeprecationReason("reason"); - Assert.True(builder.FieldType.Metadata.ContainsKey("_EF_Projection")); - Assert.NotNull(builder.FieldType.Resolver); - Assert.Equal("reason", builder.FieldType.DeprecationReason); + await Assert.That(builder.FieldType.Metadata.ContainsKey("_EF_Projection")).IsTrue(); + await Assert.That(builder.FieldType.Resolver).IsNotNull(); + await Assert.That(builder.FieldType.DeprecationReason).IsEqualTo("reason"); } - [Fact] - public void Resolve_rejects_identity_projection() + [Test] + public async Task Resolve_rejects_identity_projection() { var graphType = BuildGraphType(); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => graphType.Field("test") .Resolve( projection: _ => _, resolve: _ => _.Projection.Id)); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } - [Fact] - public void ResolveAsync_rejects_identity_projection() + [Test] + public async Task ResolveAsync_rejects_identity_projection() { var graphType = BuildGraphType(); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => graphType.Field("test") .ResolveAsync( projection: _ => _, resolve: _ => Task.FromResult(_.Projection.Id))); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } } diff --git a/src/Tests/ExpressionBuilderTests.cs b/src/Tests/ExpressionBuilderTests.cs index 73b7d128f..04b037837 100644 --- a/src/Tests/ExpressionBuilderTests.cs +++ b/src/Tests/ExpressionBuilderTests.cs @@ -5,8 +5,8 @@ public class Target public string? Member { get; set; } } - [Fact] - public void Nested() + [Test] + public async Task Nested() { var list = new List { @@ -24,11 +24,11 @@ public void Nested() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member.Length", Comparison.Equal, ["2"])) .Single(); - Assert.Equal("bb", result.Member); + await Assert.That(result.Member).IsEqualTo("bb"); } - [Fact] - public void Nested_notEqual() + [Test] + public async Task Nested_notEqual() { var list = new List { @@ -46,11 +46,11 @@ public void Nested_notEqual() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member.Length", Comparison.NotEqual, ["2"])) .Single(); - Assert.Equal("a", result.Member); + await Assert.That(result.Member).IsEqualTo("a"); } - [Fact] - public void Nullable_requiring_parse() + [Test] + public async Task Nullable_requiring_parse() { var guid = new Guid("00000000-0000-0000-0000-000000000001"); var list = new List @@ -70,18 +70,18 @@ public void Nullable_requiring_parse() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Equal, [guid.ToString()])) .Single(); - Assert.Equal(guid, resultFromString.Field); + await Assert.That(resultFromString.Field).IsEqualTo(guid); var nullResult = list .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Equal, null)) .Single(); - Assert.Null(nullResult.Field); + await Assert.That(nullResult.Field).IsNull(); } - [Fact] - public void Nullable_requiring_parse_notEqual() + [Test] + public async Task Nullable_requiring_parse_notEqual() { var guid = new Guid("00000000-0000-0000-0000-000000000001"); var list = new List @@ -101,18 +101,18 @@ public void Nullable_requiring_parse_notEqual() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.NotEqual, [guid.ToString()])) .Single(); - Assert.Null(resultFromString.Field); + await Assert.That(resultFromString.Field).IsNull(); var nullResult = list .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.NotEqual, null)) .Single(); - Assert.Equal(guid, nullResult.Field); + await Assert.That(nullResult.Field).IsEqualTo(guid); } - [Fact] - public void Nullable_requiring_parse_In() + [Test] + public async Task Nullable_requiring_parse_In() { var guid = new Guid("00000000-0000-0000-0000-000000000001"); var list = new List @@ -132,14 +132,14 @@ public void Nullable_requiring_parse_In() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.In, [null])) .Single(); - Assert.Null(resultFromNull.Field); + await Assert.That(resultFromNull.Field).IsNull(); var resultWithGuid = list .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.In, [guid.ToString()])) .Single(); - Assert.Equal(guid, resultWithGuid.Field); + await Assert.That(resultWithGuid.Field).IsEqualTo(guid); var resultGuidAndNull = list .AsQueryable() @@ -147,7 +147,7 @@ public void Nullable_requiring_parse_In() .Select(parse => parse.Field) .ToList(); - Assert.Equal(resultGuidAndNull, [null, guid]); + await Assert.That(resultGuidAndNull).IsEquivalentTo((Guid?[]) [null, guid], CollectionOrdering.Matching); } public class TargetWithNullableRequiringParse @@ -155,8 +155,8 @@ public class TargetWithNullableRequiringParse public Guid? Field; } - [Fact] - public void Nullable() + [Test] + public async Task Nullable() { var list = new List { @@ -174,16 +174,16 @@ public void Nullable() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Equal, ["10"])) .Single(); - Assert.Equal(10, resultFromString.Field); + await Assert.That(resultFromString.Field).IsEqualTo(10); var nullResult = list .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Equal, null)) .Single(); - Assert.Null(nullResult.Field); + await Assert.That(nullResult.Field).IsNull(); } - [Fact] - public void Nullable_notEqual() + [Test] + public async Task Nullable_notEqual() { var list = new List { @@ -201,12 +201,12 @@ public void Nullable_notEqual() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.NotEqual, ["10"])) .Single(); - Assert.Null(resultFromString.Field); + await Assert.That(resultFromString.Field).IsNull(); var nullResult = list .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.NotEqual, null)) .Single(); - Assert.Equal(10, nullResult.Field); + await Assert.That(nullResult.Field).IsEqualTo(10); } public class TargetWithNullable @@ -219,8 +219,8 @@ public class TargetChildForPropertyNestedExpression public string? Member; } - [Fact] - public void InList() + [Test] + public async Task InList() { var list = new List { @@ -238,11 +238,11 @@ public void InList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.In, ["Value2"])) .Single(); - Assert.Equal("Value2", result.Member); + await Assert.That(result.Member).IsEqualTo("Value2"); } - [Fact] - public void NotInList() + [Test] + public async Task NotInList() { var list = new List { @@ -260,7 +260,7 @@ public void NotInList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.NotIn, ["Value2"])) .Single(); - Assert.Equal("Value1", result.Member); + await Assert.That(result.Member).IsEqualTo("Value1"); } public class TargetForIn @@ -268,8 +268,8 @@ public class TargetForIn public string? Member; } - [Fact] - public void InIntList() + [Test] + public async Task InIntList() { var list = new List { @@ -287,11 +287,11 @@ public void InIntList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.In, ["2"])) .Single(); - Assert.Equal(2, result.Member); + await Assert.That(result.Member).IsEqualTo(2); } - [Fact] - public void NotInIntList() + [Test] + public async Task NotInIntList() { var list = new List { @@ -309,7 +309,7 @@ public void NotInIntList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.NotIn, ["2"])) .Single(); - Assert.Equal(1, result.Member); + await Assert.That(result.Member).IsEqualTo(1); } public class TargetForInInt @@ -317,8 +317,8 @@ public class TargetForInInt public int Member; } - [Fact] - public void InGuidList() + [Test] + public async Task InGuidList() { var list = new List { @@ -336,11 +336,11 @@ public void InGuidList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.In, ["00000000-0000-0000-0000-000000000002"])) .Single(); - Assert.Same(list[1], result); + await Assert.That(result).IsSameReferenceAs(list[1]); } - [Fact] - public void NotInGuidList() + [Test] + public async Task NotInGuidList() { var list = new List { @@ -358,7 +358,7 @@ public void NotInGuidList() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Member", Comparison.NotIn, ["00000000-0000-0000-0000-000000000002"])) .Single(); - Assert.Same(list[0], result); + await Assert.That(result).IsSameReferenceAs(list[0]); } public class TargetForInGuid @@ -366,8 +366,8 @@ public class TargetForInGuid public Guid Member; } - [Fact] - public void Field() + [Test] + public async Task Field() { var list = new List { @@ -385,11 +385,11 @@ public void Field() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Equal, ["Target2"])) .Single(); - Assert.Equal("Target2", result.Field); + await Assert.That(result.Field).IsEqualTo("Target2"); } - [Fact] - public void Field_notEqual() + [Test] + public async Task Field_notEqual() { var list = new List { @@ -407,11 +407,11 @@ public void Field_notEqual() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.NotEqual, ["Target2"])) .Single(); - Assert.Equal("Target1", result.Field); + await Assert.That(result.Field).IsEqualTo("Target1"); } - [Fact] - public void Contains() + [Test] + public async Task Contains() { var list = new List { @@ -430,7 +430,7 @@ public void Contains() .AsQueryable() .Where(ExpressionBuilder.BuildPredicate("Field", Comparison.Contains, ["Target2"])) .Single(); - Assert.Equal("Target2", result.Field); + await Assert.That(result.Field).IsEqualTo("Target2"); } public class TargetWithField @@ -440,46 +440,46 @@ public class TargetWithField // A non nullable string is a required property in the EF model. EF removes a null check on // one, and Verify.EntityFramework throws for it. - [Theory] - [InlineData(Comparison.StartsWith)] - [InlineData(Comparison.EndsWith)] - [InlineData(Comparison.Contains)] - public void Non_nullable_string_has_no_null_check(Comparison comparison) + [Test] + [Arguments(Comparison.StartsWith)] + [Arguments(Comparison.EndsWith)] + [Arguments(Comparison.Contains)] + public async Task Non_nullable_string_has_no_null_check(Comparison comparison) { var predicate = ExpressionBuilder.BuildPredicate("Member", comparison, ["a"]); - Assert.DoesNotContain("!= null", predicate.ToString()); + await Assert.That(predicate.ToString()).DoesNotContain("!= null"); } - [Theory] - [InlineData(Comparison.StartsWith)] - [InlineData(Comparison.EndsWith)] - [InlineData(Comparison.Contains)] - public void Nullable_string_has_null_check(Comparison comparison) + [Test] + [Arguments(Comparison.StartsWith)] + [Arguments(Comparison.EndsWith)] + [Arguments(Comparison.Contains)] + public async Task Nullable_string_has_null_check(Comparison comparison) { var predicate = ExpressionBuilder.BuildPredicate("Member", comparison, ["a"]); - Assert.Contains("(_.Member != null)", predicate.ToString()); + await Assert.That(predicate.ToString()).Contains("(_.Member != null)"); } // The navigation can be null, and then so is the member read through it - [Fact] - public void Non_nullable_string_through_navigation_has_null_check() + [Test] + public async Task Non_nullable_string_through_navigation_has_null_check() { var predicate = ExpressionBuilder.BuildPredicate("Parent.Member", Comparison.StartsWith, ["a"]); - Assert.Contains("(_.Parent.Member != null)", predicate.ToString()); + await Assert.That(predicate.ToString()).Contains("(_.Parent.Member != null)"); } - [Fact] - public void Non_nullable_string_in_list_has_no_null_check() + [Test] + public async Task Non_nullable_string_in_list_has_no_null_check() { var predicate = ExpressionBuilder.BuildPredicate("Children[Member]", Comparison.StartsWith, ["a"]); - Assert.DoesNotContain("!= null", predicate.ToString()); + await Assert.That(predicate.ToString()).DoesNotContain("!= null"); } // notEqual and notIn are already negated, so negating them again unwraps them - [Theory] - [InlineData(Comparison.NotEqual)] - [InlineData(Comparison.NotIn)] - public void Negated_negative_comparison_is_not_negated_twice(Comparison comparison) + [Test] + [Arguments(Comparison.NotEqual)] + [Arguments(Comparison.NotIn)] + public async Task Negated_negative_comparison_is_not_negated_twice(Comparison comparison) { var list = new List { @@ -495,16 +495,16 @@ public void Negated_negative_comparison_is_not_negated_twice(Comparison comparis var predicate = ExpressionBuilder.BuildPredicate("Member", comparison, ["a"], true); - Assert.DoesNotContain("Not(", predicate.ToString()); + await Assert.That(predicate.ToString()).DoesNotContain("Not("); var result = list .AsQueryable() .Where(predicate) .Single(); - Assert.Equal("a", result.Member); + await Assert.That(result.Member).IsEqualTo("a"); } - [Fact] - public void Negated_none_is_not_negated_twice() + [Test] + public async Task Negated_none_is_not_negated_twice() { var predicate = ExpressionBuilder.BuildPredicate( new WhereExpression @@ -523,7 +523,7 @@ public void Negated_none_is_not_negated_twice() ] }); - Assert.DoesNotContain("Not(", predicate.ToString()); + await Assert.That(predicate.ToString()).DoesNotContain("Not("); } public class TargetWithNonNullable @@ -533,21 +533,21 @@ public class TargetWithNonNullable public List Children { get; set; } = []; } - [Theory] - [InlineData("Name", Comparison.Equal, "Person 1", "Person 1")] - [InlineData("Name", Comparison.Equal, "Person 2", "Person 1", true)] - [InlineData("Name", Comparison.Contains, "son 2", "Person 2")] - [InlineData("Name", Comparison.StartsWith, "Person 2", "Person 2")] - [InlineData("Name", Comparison.EndsWith, "son 2", "Person 2")] - [InlineData("Age", Comparison.Equal, "13", "Person 2")] - [InlineData("Age", Comparison.GreaterThan, "12", "Person 2")] - [InlineData("Age", Comparison.Equal, "12", "Person 2", true)] - [InlineData("Age", Comparison.GreaterThanOrEqual, "13", "Person 2")] - [InlineData("Age", Comparison.LessThan, "13", "Person 1")] - [InlineData("Age", Comparison.LessThanOrEqual, "12", "Person 1")] - [InlineData("DateOfBirth", Comparison.Equal, "2001-10-10T10:10:10+00:00", "Person 1")] - [InlineData("DateOfBirth.Day", Comparison.Equal, "11", "Person 2")] - public void Combos(string name, Comparison expression, string value, string expectedName, bool negate = false) + [Test] + [Arguments("Name", Comparison.Equal, "Person 1", "Person 1")] + [Arguments("Name", Comparison.Equal, "Person 2", "Person 1", true)] + [Arguments("Name", Comparison.Contains, "son 2", "Person 2")] + [Arguments("Name", Comparison.StartsWith, "Person 2", "Person 2")] + [Arguments("Name", Comparison.EndsWith, "son 2", "Person 2")] + [Arguments("Age", Comparison.Equal, "13", "Person 2")] + [Arguments("Age", Comparison.GreaterThan, "12", "Person 2")] + [Arguments("Age", Comparison.Equal, "12", "Person 2", true)] + [Arguments("Age", Comparison.GreaterThanOrEqual, "13", "Person 2")] + [Arguments("Age", Comparison.LessThan, "13", "Person 1")] + [Arguments("Age", Comparison.LessThanOrEqual, "12", "Person 1")] + [Arguments("DateOfBirth", Comparison.Equal, "2001-10-10T10:10:10+00:00", "Person 1")] + [Arguments("DateOfBirth.Day", Comparison.Equal, "11", "Person 2")] + public async Task Combos(string name, Comparison expression, string value, string expectedName, bool negate = false) { var people = new List { @@ -569,30 +569,30 @@ public void Combos(string name, Comparison expression, string value, string expe .AsQueryable() .Where(ExpressionBuilder.BuildPredicate(name, expression, [value], negate)) .Single(); - Assert.Equal(expectedName, result.Name); - } - - [Theory] - [InlineData("Employees.Count", Comparison.Equal, "3", "Company 1")] - [InlineData("Employees.Count", Comparison.LessThan, "3", "Company 2")] - [InlineData("Employees.Count", Comparison.LessThanOrEqual, "2", "Company 2")] - [InlineData("Employees.Count", Comparison.GreaterThan, "2", "Company 1")] - [InlineData("Employees.Count", Comparison.GreaterThanOrEqual, "3", "Company 1")] - [InlineData("Employees[Name]", Comparison.Equal, "Person 1", "Company 1")] - [InlineData("Employees[Name]", Comparison.Equal, "Person 3", "Company 1", true)] - [InlineData("Employees[Name]", Comparison.Contains, "son 2", "Company 1")] - [InlineData("Employees[Name]", Comparison.StartsWith, "Person 2", "Company 1")] - [InlineData("Employees[Name]", Comparison.EndsWith, "son 2", "Company 1")] - [InlineData("Employees[Age]", Comparison.Equal, "12", "Company 1")] - [InlineData("Employees[Age]", Comparison.GreaterThan, "12", "Company 2")] - [InlineData("Employees[Age]", Comparison.Equal, "12", "Company 2", true)] - [InlineData("Employees[Age]", Comparison.GreaterThanOrEqual, "31", "Company 2")] - [InlineData("Employees[Age]", Comparison.LessThan, "13", "Company 1")] - [InlineData("Employees[Age]", Comparison.LessThanOrEqual, "12", "Company 1")] - [InlineData("Employees[DateOfBirth]", Comparison.Equal, "2001-10-10T10:10:10+00:00", "Company 1")] - [InlineData("Employees[DateOfBirth.Day]", Comparison.Equal, "11", "Company 2")] - [InlineData("Employees[Company.Employees[Name]]", Comparison.Contains, "son 2", "Company 1")] - public void ListMemberQueryCombos(string name, Comparison expression, string value, string expectedName, bool negate = false) + await Assert.That(result.Name).IsEqualTo(expectedName); + } + + [Test] + [Arguments("Employees.Count", Comparison.Equal, "3", "Company 1")] + [Arguments("Employees.Count", Comparison.LessThan, "3", "Company 2")] + [Arguments("Employees.Count", Comparison.LessThanOrEqual, "2", "Company 2")] + [Arguments("Employees.Count", Comparison.GreaterThan, "2", "Company 1")] + [Arguments("Employees.Count", Comparison.GreaterThanOrEqual, "3", "Company 1")] + [Arguments("Employees[Name]", Comparison.Equal, "Person 1", "Company 1")] + [Arguments("Employees[Name]", Comparison.Equal, "Person 3", "Company 1", true)] + [Arguments("Employees[Name]", Comparison.Contains, "son 2", "Company 1")] + [Arguments("Employees[Name]", Comparison.StartsWith, "Person 2", "Company 1")] + [Arguments("Employees[Name]", Comparison.EndsWith, "son 2", "Company 1")] + [Arguments("Employees[Age]", Comparison.Equal, "12", "Company 1")] + [Arguments("Employees[Age]", Comparison.GreaterThan, "12", "Company 2")] + [Arguments("Employees[Age]", Comparison.Equal, "12", "Company 2", true)] + [Arguments("Employees[Age]", Comparison.GreaterThanOrEqual, "31", "Company 2")] + [Arguments("Employees[Age]", Comparison.LessThan, "13", "Company 1")] + [Arguments("Employees[Age]", Comparison.LessThanOrEqual, "12", "Company 1")] + [Arguments("Employees[DateOfBirth]", Comparison.Equal, "2001-10-10T10:10:10+00:00", "Company 1")] + [Arguments("Employees[DateOfBirth.Day]", Comparison.Equal, "11", "Company 2")] + [Arguments("Employees[Company.Employees[Name]]", Comparison.Contains, "son 2", "Company 1")] + public async Task ListMemberQueryCombos(string name, Comparison expression, string value, string expectedName, bool negate = false) { var companies = new List { @@ -655,7 +655,7 @@ public void ListMemberQueryCombos(string name, Comparison expression, string val .AsQueryable() .Where(ExpressionBuilder.BuildPredicate(name, expression, [value], negate)) .Single(); - Assert.Equal(expectedName, result.Name); + await Assert.That(result.Name).IsEqualTo(expectedName); } public class Company diff --git a/src/Tests/ExpressionBuilderTypedTests.cs b/src/Tests/ExpressionBuilderTypedTests.cs index 99be5f773..f0839c226 100644 --- a/src/Tests/ExpressionBuilderTypedTests.cs +++ b/src/Tests/ExpressionBuilderTypedTests.cs @@ -79,23 +79,23 @@ static WhereExpression Collection(Quantifier quantifier, bool negate = false) => ] }; - [Theory] - [InlineData(Quantifier.Any, false, "AllYoung,Mixed")] - [InlineData(Quantifier.All, false, "AllYoung,Empty")] - [InlineData(Quantifier.None, false, "AllOld,Empty")] - [InlineData(Quantifier.Any, true, "AllOld,Empty")] - public void Quantifiers(Quantifier quantifier, bool negate, string expected) + [Test] + [Arguments(Quantifier.Any, false, "AllYoung,Mixed")] + [Arguments(Quantifier.All, false, "AllYoung,Empty")] + [Arguments(Quantifier.None, false, "AllOld,Empty")] + [Arguments(Quantifier.Any, true, "AllOld,Empty")] + public async Task Quantifiers(Quantifier quantifier, bool negate, string expected) { var predicate = ExpressionBuilder.BuildPredicate(Collection(quantifier, negate)); var names = Companies() .AsQueryable() .Where(predicate) .Select(_ => _.Name); - Assert.Equal(expected, string.Join(",", names)); + await Assert.That(string.Join(",", names)).IsEqualTo(expected); } - [Fact] - public void Quantifier_without_conditions_is_has_items() + [Test] + public async Task Quantifier_without_conditions_is_has_items() { var predicate = ExpressionBuilder.BuildPredicate( new WhereExpression @@ -108,11 +108,11 @@ public void Quantifier_without_conditions_is_has_items() .AsQueryable() .Where(predicate) .Select(_ => _.Name); - Assert.Equal("AllYoung,Mixed,AllOld", string.Join(",", names)); + await Assert.That(string.Join(",", names)).IsEqualTo("AllYoung,Mixed,AllOld"); } - [Fact] - public void Typed_values() + [Test] + public async Task Typed_values() { var guid = new Guid("00000000-0000-0000-0000-000000000001"); var date = new DateTime(2020, 10, 1, 0, 0, 0, DateTimeKind.Utc); @@ -173,12 +173,12 @@ public void Typed_values() .AsQueryable() .Where(predicate) .Single(); - Assert.Equal(guid, result.Id); + await Assert.That(result.Id).IsEqualTo(guid); } // A value of a compatible type, such as an int for a long, is converted - [Fact] - public void Compatible_value_is_converted() + [Test] + public async Task Compatible_value_is_converted() { var targets = new List { @@ -202,13 +202,13 @@ public void Compatible_value_is_converted() .AsQueryable() .Where(predicate) .Single(); - Assert.Equal(10, result.Big); + await Assert.That(result.Big).IsEqualTo(10); } - [Fact] - public void Duplicate_typed_values_throw() + [Test] + public async Task Duplicate_typed_values_throw() { - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => ExpressionBuilder.BuildPredicate( new WhereExpression { @@ -216,7 +216,7 @@ public void Duplicate_typed_values_throw() Comparison = Comparison.In, Value = [10, 10] })); - Assert.Contains("Duplicates", exception.InnerException!.Message); + await Assert.That(exception.InnerException!.Message).Contains("Duplicates"); } public class Target diff --git a/src/Tests/FieldBuilderExtensionsTests.cs b/src/Tests/FieldBuilderExtensionsTests.cs index 81bad62b8..0b8375ec1 100644 --- a/src/Tests/FieldBuilderExtensionsTests.cs +++ b/src/Tests/FieldBuilderExtensionsTests.cs @@ -11,94 +11,94 @@ class TestDbContext(DbContextOptions options) : DbContext(options); // Identity projections are rejected before the service is touched, so no real service is required static readonly IEfGraphQLService graphQlService = null!; - [Fact] - public void Resolve_ThrowsArgumentException_WhenIdentityProjectionUsed() + [Test] + public async Task Resolve_ThrowsArgumentException_WhenIdentityProjectionUsed() { var graphType = new ObjectGraphType(); var field = graphType.Field("test"); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => field.Resolve( graphQlService, projection: _ => _, resolve: _ => _.Projection.Id)); - Assert.Contains("Identity projection", exception.Message); - Assert.Contains("_ => _", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); + await Assert.That(exception.Message).Contains("_ => _"); } - [Fact] - public void Resolve_ThrowsArgumentException_WhenIdentityProjectionUsedWithDiscardVariable() + [Test] + public async Task Resolve_ThrowsArgumentException_WhenIdentityProjectionUsedWithDiscardVariable() { var graphType = new ObjectGraphType(); var field = graphType.Field("test"); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => field.Resolve( graphQlService, projection: _ => _, resolve: _ => _.Projection.Id)); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } - [Fact] - public void ResolveAsync_ThrowsArgumentException_WhenIdentityProjectionUsed() + [Test] + public async Task ResolveAsync_ThrowsArgumentException_WhenIdentityProjectionUsed() { var graphType = new ObjectGraphType(); var field = graphType.Field("test"); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => field.ResolveAsync( graphQlService, projection: _ => _, resolve: _ => Task.FromResult(_.Projection.Id))); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } - [Fact] - public void ResolveList_ThrowsArgumentException_WhenIdentityProjectionUsed() + [Test] + public async Task ResolveList_ThrowsArgumentException_WhenIdentityProjectionUsed() { var graphType = new ObjectGraphType(); var field = graphType.Field>("test"); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => field.ResolveList( graphQlService, projection: _ => _, resolve: _ => [_.Projection.Id])); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } - [Fact] - public void ResolveListAsync_ThrowsArgumentException_WhenIdentityProjectionUsed() + [Test] + public async Task ResolveListAsync_ThrowsArgumentException_WhenIdentityProjectionUsed() { var graphType = new ObjectGraphType(); var field = graphType.Field>("test"); - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => field.ResolveListAsync( graphQlService, projection: _ => _, resolve: _ => Task.FromResult>([_.Projection.Id]))); - Assert.Contains("Identity projection", exception.Message); + await Assert.That(exception.Message).Contains("Identity projection"); } - [Fact] - public void FieldBuilderEx_Resolve_ThrowsException() + [Test] + public async Task FieldBuilderEx_Resolve_ThrowsException() { // Arrange var fieldType = new FieldType { Name = "test", Type = typeof(StringGraphType) }; var builder = new FieldBuilderEx(fieldType); // Assert - Calling Resolve should throw - var exception = Assert.Throws(() => + var exception = Assert.ThrowsExactly(() => builder.Resolve(_ => "test")); - Assert.Contains("resolve has already been configured", exception.Message); + await Assert.That(exception.Message).Contains("resolve has already been configured"); } enum TestEnum diff --git a/src/Tests/GlobalUsings.cs b/src/Tests/GlobalUsings.cs index b7d4b6604..4ba6e10fc 100644 --- a/src/Tests/GlobalUsings.cs +++ b/src/Tests/GlobalUsings.cs @@ -3,3 +3,4 @@ global using EfOrderBy; global using GraphQL.Execution; global using Polyfills; +global using TUnit.Assertions.Enums; diff --git a/src/Tests/InMemoryStringComparisonTests.cs b/src/Tests/InMemoryStringComparisonTests.cs index 5a1a534e4..8843daaf6 100644 --- a/src/Tests/InMemoryStringComparisonTests.cs +++ b/src/Tests/InMemoryStringComparisonTests.cs @@ -4,35 +4,36 @@ // like, which threw outside a query, matches the pattern in memory. public class InMemoryStringComparisonTests { - [Theory] - [InlineData(Comparison.Equal, "VALUE", "Value")] - [InlineData(Comparison.StartsWith, "VAL", "Value")] - [InlineData(Comparison.EndsWith, "LUE", "Value")] - [InlineData(Comparison.Contains, "ALU", "Value")] - [InlineData(Comparison.In, "VALUE", "Value")] - [InlineData(Comparison.Like, "%ALU%", "Value")] - [InlineData(Comparison.Like, "V_LUE", "Value")] - [InlineData(Comparison.Like, "[A-Z]alue", "Value")] - public void Matches_ignoring_case(Comparison comparison, string value, string property) + [Test] + [Arguments(Comparison.Equal, "VALUE", "Value")] + [Arguments(Comparison.StartsWith, "VAL", "Value")] + [Arguments(Comparison.EndsWith, "LUE", "Value")] + [Arguments(Comparison.Contains, "ALU", "Value")] + [Arguments(Comparison.In, "VALUE", "Value")] + [Arguments(Comparison.Like, "%ALU%", "Value")] + [Arguments(Comparison.Like, "V_LUE", "Value")] + [Arguments(Comparison.Like, "[A-Z]alue", "Value")] + public async Task Matches_ignoring_case(Comparison comparison, string value, string property) { var result = Apply(comparison, value, new ParentEntity {Property = property}, new ParentEntity {Property = "Other"}); - Assert.Equal([property], result.Select(_ => _.Property)); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) [property], CollectionOrdering.Matching); } - [Theory] - [InlineData(Comparison.Like, "Val", "Value")] - [InlineData(Comparison.Like, "V_LUE", "Vaalue")] - [InlineData(Comparison.Like, "%.%", "Value")] - public void Like_does_not_match(Comparison comparison, string value, string property) + [Test] + [Arguments(Comparison.Like, "Val", "Value")] + [Arguments(Comparison.Like, "V_LUE", "Vaalue")] + [Arguments(Comparison.Like, "%.%", "Value")] + public async Task Like_does_not_match(Comparison comparison, string value, string property) { var result = Apply(comparison, value, new ParentEntity {Property = property}); - Assert.Empty(result); + await Assert.That(result).IsEmpty(); } - [Fact] - public void Negated_equal_ignores_case() + [Test] + public async Task Negated_equal_ignores_case() { var context = BuildContext( new() @@ -51,16 +52,17 @@ public void Negated_equal_ignores_case() .ApplyGraphQlArguments(true, context, false) .ToList(); - Assert.Equal(["Other"], result.Select(_ => _.Property)); + await Assert.That(result.Select(_ => _.Property)) + .IsEquivalentTo((string?[]) ["Other"], CollectionOrdering.Matching); } // The where has no null check on a non nullable string, and the member can still be null in // memory, for example when it was not loaded - [Theory] - [InlineData(Comparison.StartsWith)] - [InlineData(Comparison.EndsWith)] - [InlineData(Comparison.Contains)] - public void Null_in_non_nullable_string_does_not_match(Comparison comparison) + [Test] + [Arguments(Comparison.StartsWith)] + [Arguments(Comparison.EndsWith)] + [Arguments(Comparison.Contains)] + public async Task Null_in_non_nullable_string_does_not_match(Comparison comparison) { var context = BuildContext( new() @@ -78,7 +80,7 @@ public void Null_in_non_nullable_string_does_not_match(Comparison comparison) .ApplyGraphQlArguments(false, context, false) .ToList(); - Assert.Equal(["A"], result.Select(_ => _.Member)); + await Assert.That(result.Select(_ => _.Member)).IsEquivalentTo(["A"], CollectionOrdering.Matching); } public class WithNonNullable diff --git a/src/Tests/IntegrationTests/Graphs/WithManyChildrenGraphType.cs b/src/Tests/IntegrationTests/Graphs/WithManyChildrenGraphType.cs index 06a86145e..f0cda5203 100644 --- a/src/Tests/IntegrationTests/Graphs/WithManyChildrenGraphType.cs +++ b/src/Tests/IntegrationTests/Graphs/WithManyChildrenGraphType.cs @@ -9,8 +9,11 @@ public WithManyChildrenGraphType(IEfGraphQLService graphQl projection: _ => new { _.Child1, _.Child2 }, resolve: ctx => { - Assert.NotNull(ctx.Projection.Child2); - Assert.NotNull(ctx.Projection.Child1); + if (ctx.Projection.Child1 is null || ctx.Projection.Child2 is null) + { + throw new InvalidOperationException("Expected both Child1 and Child2 to be projected"); + } + return ctx.Projection.Child1; }); // Child1 is not the first path in the projection diff --git a/src/Tests/IntegrationTests/IntegrationTests.Batch_filter_one_call_per_depth.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Batch_filter_one_call_per_depth.verified.txt index 04ed9a591..40e0fc453 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Batch_filter_one_call_per_depth.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Batch_filter_one_call_per_depth.verified.txt @@ -41,13 +41,13 @@ Text: select c.Id, case when p.Id is null then cast (1 as bit) else cast (0 as bit) end, - p.Id, s.Id, s.c, s.Id0, s.Property, s.ParentId, s.Property0, + p.Id, p.Property, c.ParentId, c.Property @@ -69,7 +69,6 @@ from ChildEntities as c on p.Id = s.ParentId order by c.Property, c.Id, - p.Id, s.Id }, childBatch: [ diff --git a/src/Tests/IntegrationTests/IntegrationTests.Derived_navigations_under_fragments_below_collection_navigation.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Derived_navigations_under_fragments_below_collection_navigation.verified.txt index 1f7dc182e..6a0aac050 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Derived_navigations_under_fragments_below_collection_navigation.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Derived_navigations_under_fragments_below_collection_navigation.verified.txt @@ -64,8 +64,6 @@ from TphDerivedNavOwners as t on t0.CategoryId = c.Id) as s on t.Id = s.OwnerId order by t.Id, - s.Property, - s.Id, - s.Id0 + s.Property } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/IntegrationTests.Filter_using_anonymous_type_with_nested_navigation_property.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Filter_using_anonymous_type_with_nested_navigation_property.verified.txt index 2a26f2a46..11d6a6cb5 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Filter_using_anonymous_type_with_nested_navigation_property.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Filter_using_anonymous_type_with_nested_navigation_property.verified.txt @@ -28,7 +28,6 @@ select f.Id, s.c, s.Property, s.Property0, - s.Id0, f.Property from FilterParentEntities as f left outer join @@ -38,7 +37,6 @@ from FilterParentEntities as f case when f1.Id is null then cast (1 as bit) else cast (0 as bit) end as c, f1.Property, f0.Property as Property0, - f1.Id as Id0, f0.ParentId from FilterChildEntities as f0 left outer join diff --git a/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude.verified.txt index 6f72ffe20..bae4bf5f6 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude.verified.txt @@ -45,6 +45,7 @@ where exists (select 1 order by m.Id, s.Id, s.ManyToManyLeftEntityId, + s.ManyToManyRightEntityId, Parameters: { @p: { Value: Right2, diff --git a/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude_notEqual.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude_notEqual.verified.txt index 7745aa632..53b6b8c25 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude_notEqual.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.ManyToManyRightWhereAndInclude_notEqual.verified.txt @@ -54,6 +54,7 @@ where exists (select 1 order by m.Id, s.Id, s.ManyToManyLeftEntityId, + s.ManyToManyRightEntityId, Parameters: { @p: { Value: Right2, diff --git a/src/Tests/IntegrationTests/IntegrationTests.Navigation_under_abstract_navigation_is_loaded.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Navigation_under_abstract_navigation_is_loaded.verified.txt index d3f9b3061..27f9c47d4 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Navigation_under_abstract_navigation_is_loaded.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Navigation_under_abstract_navigation_is_loaded.verified.txt @@ -48,7 +48,6 @@ from DerivedChildEntities as d where d.Property = @p order by d.Property, d.Id, - b.Id, d0.Property, Parameters: { @p: { diff --git a/src/Tests/IntegrationTests/IntegrationTests.Query_Cyclic.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Query_Cyclic.verified.txt index 080f6eab8..ce587d5df 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Query_Cyclic.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Query_Cyclic.verified.txt @@ -63,13 +63,13 @@ Text: select c.Id, case when p.Id is null then cast (1 as bit) else cast (0 as bit) end, - p.Id, s.Id, s.c, s.Id0, s.Property, s.ParentId, s.Property0, + p.Id, p.Property, c.ParentId, c.Property @@ -91,8 +91,6 @@ from ChildEntities as c on p.Id = s.ParentId order by c.Property, c.Id, - p.Id, - s.Property0, - s.Id + s.Property0 } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/IntegrationTests.Unrelated_navigation_to_base_type_is_included.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Unrelated_navigation_to_base_type_is_included.verified.txt index f5e882289..88e132f47 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Unrelated_navigation_to_base_type_is_included.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Unrelated_navigation_to_base_type_is_included.verified.txt @@ -49,7 +49,6 @@ from TphRootEntities as t where t.Property = @p order by t.Property, t.Id, - s.Id, Parameters: { @p: { Value: TheRequest, diff --git a/src/Tests/IntegrationTests/IntegrationTests.Where_collection_on_navigation_list.verified.txt b/src/Tests/IntegrationTests/IntegrationTests.Where_collection_on_navigation_list.verified.txt index 62ddc055c..b296372da 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.Where_collection_on_navigation_list.verified.txt +++ b/src/Tests/IntegrationTests/IntegrationTests.Where_collection_on_navigation_list.verified.txt @@ -51,6 +51,7 @@ order by m.LeftName, m.Id, s.Id, s.ManyToManyLeftEntityId, + s.ManyToManyRightEntityId, Parameters: { @p: { Value: Left1, diff --git a/src/Tests/IntegrationTests/IntegrationTests.cs b/src/Tests/IntegrationTests/IntegrationTests.cs index 45dd97638..0d6e48a34 100644 --- a/src/Tests/IntegrationTests/IntegrationTests.cs +++ b/src/Tests/IntegrationTests/IntegrationTests.cs @@ -31,7 +31,7 @@ static IntegrationDbContext Construct(DbContextOptionsBuilder Construct(new DbContextOptionsBuilder().UseSqlServer("Server=unused")); - [Fact] + [Test] public async Task SchemaPrint() { await using var dbContext = NewModelOnlyContext(); @@ -53,7 +53,7 @@ public async Task SchemaPrint() await Verify(print); } - [Fact] + [Test] public async Task LogQuery() { string? queryText = null; @@ -84,10 +84,10 @@ public async Task LogQuery() await using var database = await sqlInstance.Build(); await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); - Assert.NotNull(queryText); + await Assert.That(queryText).IsNotNull(); } - [Fact] + [Test] public async Task Where_multiple() { var query = @@ -118,7 +118,7 @@ public async Task Where_multiple() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Where_date() { var query = @@ -141,7 +141,7 @@ public async Task Where_date() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_date_notEqual() { var query = @@ -164,7 +164,7 @@ public async Task Where_date_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_enum() { var query = @@ -187,7 +187,7 @@ public async Task Where_enum() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_enum_notEqual() { var query = @@ -210,7 +210,7 @@ public async Task Where_enum_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_string_notEqual() { var query = @@ -237,7 +237,7 @@ public async Task Where_string_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Where_string_notEqual_diffCase() { var query = @@ -264,7 +264,7 @@ public async Task Where_string_notEqual_diffCase() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Where_string_contains() { var query = @@ -311,7 +311,7 @@ public async Task Where_string_contains() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5, entity6, entity7, entity8]); } - [Fact] + [Test] public async Task Where_string_contains_diffCase() { var query = @@ -359,7 +359,7 @@ public async Task Where_string_contains_diffCase() } - [Fact] + [Test] public async Task Where_enum_in() { var query = @@ -382,7 +382,7 @@ public async Task Where_enum_in() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_time() { var query = @@ -405,7 +405,7 @@ public async Task Where_time() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_time_notEqual() { var query = @@ -428,7 +428,7 @@ public async Task Where_time_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_nullable_properties1() { var query = "{ withNullableEntities (where: {nullable: {equal: null}}){ id } }"; @@ -444,7 +444,7 @@ public async Task Where_with_nullable_properties1() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_nullable_properties1_NotEqual() { var query = "{ withNullableEntities (where: {nullable: {notEqual: null}}){ id } }"; @@ -460,7 +460,7 @@ public async Task Where_with_nullable_properties1_NotEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_nullable_properties2() { var query = "{ withNullableEntities (where: {nullable: {equal: 10}}){ id } }"; @@ -475,7 +475,7 @@ public async Task Where_with_nullable_properties2() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_nullable_properties2_notEqual() { var query = "{ withNullableEntities (where: {nullable: {notEqual: 10}}){ id } }"; @@ -490,7 +490,7 @@ public async Task Where_with_nullable_properties2_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_null_comparison_value() { var query = "{ parentEntities (where: {property: {equal: null}}){ id } }"; @@ -508,7 +508,7 @@ public async Task Where_null_comparison_value() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_null_comparison_value_notEqual() { var query = "{ parentEntities (where: {property: {notEqual: null}}){ id } }"; @@ -526,7 +526,7 @@ public async Task Where_null_comparison_value_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Take() { var query = @@ -554,7 +554,7 @@ public async Task Take() // The orderBy argument replaces the ordering the resolver applied, rather than being added // after it, where EF discards the resolver's ordering - [Fact] + [Test] public async Task OrderByArgumentReplacesResolverOrdering() { var query = @@ -580,7 +580,7 @@ public async Task OrderByArgumentReplacesResolverOrdering() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task TakeNoOrder() { var query = @@ -606,7 +606,7 @@ public async Task TakeNoOrder() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Skip() { var query = @@ -632,7 +632,7 @@ public async Task Skip() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task SkipNoOrder() { var query = @@ -658,7 +658,7 @@ public async Task SkipNoOrder() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Connection_first_page() { var query = @@ -687,7 +687,7 @@ public async Task Connection_first_page() /// /// The page info without totalCount needs no count: the page query reads one row past the page, and that row answers hasNextPage. /// - [Fact] + [Test] public async Task Connection_page_info_without_total_count_peeks() { var query = @@ -714,7 +714,7 @@ public async Task Connection_page_info_without_total_count_peeks() /// /// The last page has no row past it to read, so hasNextPage is false without the count. /// - [Fact] + [Test] public async Task Connection_page_info_without_total_count_last_page() { var query = @@ -741,7 +741,7 @@ public async Task Connection_page_info_without_total_count_last_page() /// /// A page past the end is empty, which proves nothing about rows before it, so hasPreviousPage is false, as the spec allows when paging forward. /// - [Fact] + [Test] public async Task Connection_page_info_without_total_count_past_the_end() { var query = @@ -768,7 +768,7 @@ public async Task Connection_page_info_without_total_count_past_the_end() /// /// Nothing selected reads the count, and first and after place the window from the start, so the count query is skipped and the page is a single query. /// - [Fact] + [Test] public async Task Connection_items_only_skips_count() { var query = @@ -790,7 +790,7 @@ public async Task Connection_items_only_skips_count() /// /// Without the count the offset is not clamped to the end, so a page past it is read from the database as an empty page. /// - [Fact] + [Test] public async Task Connection_items_only_past_the_end_is_empty() { var query = @@ -812,7 +812,7 @@ public async Task Connection_items_only_past_the_end_is_empty() /// /// last places the window from the end, which needs the count even when nothing selected reads it. /// - [Fact] + [Test] public async Task Connection_items_only_with_last_counts() { var query = @@ -831,7 +831,7 @@ public async Task Connection_items_only_with_last_counts() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_page_back() { var query = @@ -859,7 +859,7 @@ public async Task Connection_page_back() } - [Fact] + [Test] public async Task Connection_nested() { var query = @@ -888,7 +888,7 @@ public async Task Connection_nested() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_nested_OmitQueryArguments() { var query = @@ -929,7 +929,7 @@ static IEnumerable BuildEntities(uint length) } } - [Fact] + [Test] public async Task OrderBy() { var query = @@ -955,7 +955,7 @@ public async Task OrderBy() await RunQuery(database, query, null, null, false, [entity2, entity1]); } - [Fact] + [Test] public async Task OrderByDescending() { var query = @@ -981,7 +981,7 @@ public async Task OrderByDescending() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task OrderByNullable() { var query = @@ -1004,7 +1004,7 @@ public async Task OrderByNullable() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task OrderByNested() { var query = @@ -1040,7 +1040,7 @@ public async Task OrderByNested() await RunQuery(database, query, null, null, false, [parent1, parent2, entity1, entity2]); } - [Fact] + [Test] public async Task OrderByNestedNullable() { var query = @@ -1071,7 +1071,7 @@ public async Task OrderByNestedNullable() await RunQuery(database, query, null, null, false, [parent, entity1, entity2]); } - [Fact] + [Test] public async Task Like() { var query = @@ -1097,7 +1097,7 @@ public async Task Like() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_variable() { var query = @@ -1130,7 +1130,7 @@ public async Task Where_with_variable() await RunQuery(database, query, inputs, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_with_variable_notEqual() { var query = @@ -1163,7 +1163,7 @@ public async Task Where_with_variable_notEqual() await RunQuery(database, query, inputs, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task CustomType() { var query = @@ -1189,7 +1189,7 @@ public async Task CustomType() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Single_NotFound() { var query = @@ -1204,7 +1204,7 @@ public async Task Single_NotFound() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Single_NotFound_with_sql_included() { var query = @@ -1219,7 +1219,7 @@ public async Task Single_NotFound_with_sql_included() await RunQuery(database, query, null, null, false, [], includeSqlInExceptions: true); } - [Fact] + [Test] public async Task First_NotFound() { var query = @@ -1234,7 +1234,7 @@ public async Task First_NotFound() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Single_Found_NoTracking() { var query = @@ -1259,7 +1259,7 @@ public async Task Single_Found_NoTracking() await RunQuery(database, query, null, null, true, [entity1, entity2]); } - [Fact] + [Test] public async Task First_Found_NoTracking() { var query = @@ -1284,7 +1284,7 @@ public async Task First_Found_NoTracking() await RunQuery(database, query, null, null, true, [entity1, entity2]); } - [Fact] + [Test] public async Task Owned() { var query = @@ -1315,7 +1315,7 @@ public async Task Owned() await RunQuery(database, query, null, null, false, [entity1]); } - [Fact] + [Test] public async Task Explicit_Null() { var query = @@ -1330,7 +1330,7 @@ public async Task Explicit_Null() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Single_Found() { var query = @@ -1355,7 +1355,7 @@ public async Task Single_Found() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task First_Found() { var query = @@ -1380,7 +1380,7 @@ public async Task First_Found() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Single_NoArgs() { var query = @@ -1410,7 +1410,7 @@ public async Task Single_NoArgs() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task First_NoArgs() { var query = @@ -1440,7 +1440,7 @@ public async Task First_NoArgs() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Single_IdOnly() { var query = @@ -1470,7 +1470,7 @@ public async Task Single_IdOnly() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task First_IdOnly() { var query = @@ -1500,7 +1500,7 @@ public async Task First_IdOnly() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task SingleNullable_NotFound() { var query = @@ -1515,7 +1515,7 @@ public async Task SingleNullable_NotFound() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task FirstNullable_NotFound() { var query = @@ -1530,7 +1530,7 @@ public async Task FirstNullable_NotFound() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task SingleNullable_Found() { var query = @@ -1555,7 +1555,7 @@ public async Task SingleNullable_Found() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task FirstNullable_Found() { var query = @@ -1580,7 +1580,7 @@ public async Task FirstNullable_Found() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task SingleParent_Child_mutation() { var query = @@ -1631,7 +1631,7 @@ public async Task SingleParent_Child_mutation() // A mutation with a resolver of its own reads the entity back through ApplyProjection, so it // loads what a query field would: the selected columns, and the children with their orderBy // applied by the database. - [Fact] + [Test] public async Task Custom_mutation_reads_back_with_projection() { var query = @@ -1669,7 +1669,7 @@ public async Task Custom_mutation_reads_back_with_projection() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task FirstParent_Child_mutation() { var query = @@ -1717,7 +1717,7 @@ public async Task FirstParent_Child_mutation() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task SingleParent_Child() { var query = @@ -1765,7 +1765,7 @@ public async Task SingleParent_Child() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task FirstParent_Child() { var query = @@ -1813,7 +1813,7 @@ public async Task FirstParent_Child() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task SingleParent_Child_WithFragment() { var query = @@ -1867,7 +1867,7 @@ fragment childEntityFields on Child { await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task FirstParent_Child_WithFragment() { var query = @@ -1921,7 +1921,7 @@ fragment childEntityFields on Child { await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task Where() { var query = @@ -1947,7 +1947,7 @@ public async Task Where() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_sql_injection() { var query = @@ -1965,7 +1965,7 @@ public async Task Where_sql_injection() await RunQuery(database, query, null, null, false, [entity1]); } - [Fact] + [Test] public async Task Where_notEqual() { var query = @@ -1991,7 +1991,7 @@ public async Task Where_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_default_comparison() { var query = @@ -2017,7 +2017,7 @@ public async Task Where_default_comparison() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Id() { var query = @@ -2044,7 +2044,7 @@ public async Task Id() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task NamedId() { var query = @@ -2071,7 +2071,7 @@ public async Task NamedId() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Id_multiple() { var query = @@ -2105,7 +2105,7 @@ public async Task Id_multiple() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task In() { var query = @@ -2131,7 +2131,7 @@ public async Task In() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task In_multiple() { var query = @@ -2158,7 +2158,8 @@ public async Task In_multiple() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact(Skip = "Work out why include is not used")] + [Test] + [Skip("Work out why include is not used")] public async Task Connection_parent_child() { var query = @@ -2214,7 +2215,7 @@ public async Task Connection_parent_child() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task Aliased_scalar_field() { var query = @@ -2236,7 +2237,7 @@ public async Task Aliased_scalar_field() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task Aliased_scalar_field_on_navigation() { var query = @@ -2267,7 +2268,7 @@ public async Task Aliased_scalar_field_on_navigation() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Navigation_list_where() { var query = @@ -2302,7 +2303,7 @@ public async Task Navigation_list_where() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Multiple_filters_for_same_type_all_apply() { var filters = new Filters(); @@ -2333,7 +2334,7 @@ await RunQuery( ]); } - [Fact] + [Test] public async Task Child_parent_with_alias() { var query = @@ -2380,7 +2381,8 @@ public async Task Child_parent_with_alias() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact(Skip = "TODO")] + [Test] + [Skip("TODO")] public async Task Multiple_nested_AddQueryField() { var query = @@ -2406,7 +2408,8 @@ public async Task Multiple_nested_AddQueryField() await RunQuery(database, query, null, null, false, [level1, level2]); } - [Fact(Skip = "fix order")] + [Test] + [Skip("fix order")] public async Task Skip_level() { var query = @@ -2439,7 +2442,7 @@ public async Task Skip_level() await RunQuery(database, query, null, null, false, [level1, level2, level3]); } - [Fact] + [Test] public async Task Multiple_nested() { var query = @@ -2475,7 +2478,7 @@ public async Task Multiple_nested() await RunQuery(database, query, null, null, false, [level1, level2, level3]); } - [Fact] + [Test] public async Task Null_on_nested() { var query = @@ -2518,7 +2521,7 @@ public async Task Null_on_nested() await RunQuery(database, query, null, null, false, [level1b, level2b, level1a, level2a, level3a]); } - [Fact] + [Test] public async Task Null_on_nested_notEqual() { var query = @@ -2561,7 +2564,7 @@ public async Task Null_on_nested_notEqual() await RunQuery(database, query, null, null, false, [level1b, level2b, level1a, level2a, level3a]); } - [Fact] + [Test] public async Task Query_Cyclic() { var query = @@ -2617,7 +2620,7 @@ public async Task Query_Cyclic() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task Query_NoTracking() { var query = @@ -2665,7 +2668,7 @@ public async Task Query_NoTracking() await RunQuery(database, query, null, null, true, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task Child_parent() { var query = @@ -2713,7 +2716,7 @@ public async Task Child_parent() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task With_null_navigation_property() { var query = @@ -2756,7 +2759,7 @@ public async Task With_null_navigation_property() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity5]); } - [Fact] + [Test] public async Task With_null_navigation_property_notEqual() { var query = @@ -2799,7 +2802,7 @@ public async Task With_null_navigation_property_notEqual() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity5]); } - [Fact] + [Test] public async Task Query_field_named_after_navigation_is_not_projected_by_parent() { var query = @@ -2827,7 +2830,8 @@ public async Task Query_field_named_after_navigation_is_not_projected_by_parent( await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact(Skip = "fix order")] + [Test] + [Skip("fix order")] public async Task MisNamedQuery() { var query = @@ -2865,7 +2869,8 @@ public async Task MisNamedQuery() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact(Skip = "fix order")] + [Test] + [Skip("fix order")] public async Task Parent_child() { var query = @@ -2913,7 +2918,7 @@ public async Task Parent_child() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4, entity5]); } - [Fact] + [Test] public async Task Parent_child_with_id() { var parent = new ParentEntity @@ -2949,7 +2954,8 @@ public async Task Parent_child_with_id() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact(Skip = "fix order")] + [Test] + [Skip("fix order")] public async Task Parent_with_id_child() { var parent1 = new ParentEntity @@ -2989,7 +2995,7 @@ public async Task Parent_with_id_child() await RunQuery(database, query, null, null, false, [parent1, parent2, child1, child2]); } - [Fact] + [Test] public async Task Parent_with_id_child_with_id() { var parent1 = new ParentEntity @@ -3029,7 +3035,7 @@ public async Task Parent_with_id_child_with_id() await RunQuery(database, query, null, null, false, [parent1, parent2, child1, child2]); } - [Fact] + [Test] public async Task Many_children() { var query = @@ -3061,7 +3067,8 @@ public async Task Many_children() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact(Skip = "Broke with gql 4")] + [Test] + [Skip("Broke with gql 4")] public async Task InheritedEntityInterface() { var query = @@ -3135,7 +3142,7 @@ fragment childEntityFields on DerivedChild { await RunQuery(database, query, null, null, false, [derivedEntity1, childEntity1, childEntity2, derivedEntity2, childEntity3, childEntity4]); } - [Fact] + [Test] public async Task Query_entity_with_readonly_properties() { var query = @@ -3168,7 +3175,7 @@ public async Task Query_entity_with_readonly_properties() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Query_readonly_computed_property_should_work() { var query = @@ -3201,7 +3208,7 @@ public async Task Query_readonly_computed_property_should_work() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Query_database_computed_column_readonly_property() { var query = @@ -3234,7 +3241,7 @@ public async Task Query_database_computed_column_readonly_property() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task ManyToManyRightWhereAndInclude() { var query = @@ -3289,7 +3296,7 @@ public async Task ManyToManyRightWhereAndInclude() await RunQuery(database, query, null, null, false, [middle11, middle12, middle21]); } - [Fact] + [Test] public async Task ManyToManyRightWhereAndInclude_notEqual() { var query = @@ -3344,7 +3351,7 @@ public async Task ManyToManyRightWhereAndInclude_notEqual() await RunQuery(database, query, null, null, false, [middle11, middle12, middle21]); } - [Fact] + [Test] public async Task ManyToManyLeftWhereAndInclude() { var query = @@ -3399,7 +3406,7 @@ public async Task ManyToManyLeftWhereAndInclude() await RunQuery(database, query, null, null, false, [middle11, middle12, middle21]); } - [Fact] + [Test] public async Task ManyToManyLeftWhereAndInclude_notEqual() { var query = @@ -3508,7 +3515,7 @@ static IEnumerable GetGraphQlTypes() => .GetTypes() .Where(_ => !_.IsAbstract && _.IsAssignableTo()); - [Fact] + [Test] public async Task IQueryableFirst() { var query = @@ -3523,7 +3530,7 @@ public async Task IQueryableFirst() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task IQueryableSingle() { var query = @@ -3538,7 +3545,7 @@ public async Task IQueryableSingle() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task IQueryable() { var query = @@ -3553,7 +3560,7 @@ public async Task IQueryable() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task SingleNullQueryableSingle() { var query = @@ -3568,7 +3575,7 @@ public async Task SingleNullQueryableSingle() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullQueryableFirst() { var query = @@ -3583,7 +3590,7 @@ public async Task NullQueryableFirst() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskQueryableSingle() { var query = @@ -3598,7 +3605,7 @@ public async Task NullTaskQueryableSingle() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskInnerQueryableSingle() { var query = @@ -3613,7 +3620,7 @@ public async Task NullTaskInnerQueryableSingle() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskQueryableFirst() { var query = @@ -3628,7 +3635,7 @@ public async Task NullTaskQueryableFirst() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskInnerQueryableFirst() { var query = @@ -3643,7 +3650,7 @@ public async Task NullTaskInnerQueryableFirst() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task SingleNullQueryableSingleDisallowNull() { var query = @@ -3658,7 +3665,7 @@ public async Task SingleNullQueryableSingleDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullQueryableFirstDisallowNull() { var query = @@ -3673,7 +3680,7 @@ public async Task NullQueryableFirstDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskQueryableSingleDisallowNull() { var query = @@ -3688,7 +3695,7 @@ public async Task NullTaskQueryableSingleDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskInnerQueryableSingleDisallowNull() { var query = @@ -3703,7 +3710,7 @@ public async Task NullTaskInnerQueryableSingleDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskQueryableFirstDisallowNull() { var query = @@ -3718,7 +3725,7 @@ public async Task NullTaskQueryableFirstDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullTaskInnerQueryableFirstDisallowNull() { var query = @@ -3733,7 +3740,7 @@ public async Task NullTaskInnerQueryableFirstDisallowNull() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task NullQueryConnection() { var query = @@ -3759,7 +3766,7 @@ public async Task NullQueryConnection() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task NullTaskQueryConnection() { var query = @@ -3785,7 +3792,7 @@ public async Task NullTaskQueryConnection() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task NullTaskInnerQueryConnection() { var query = @@ -3811,7 +3818,7 @@ public async Task NullTaskInnerQueryConnection() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Filter_with_projection_accesses_foreign_key() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_AutoMapFilters.cs b/src/Tests/IntegrationTests/IntegrationTests_AutoMapFilters.cs index a4438b989..98cae2240 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_AutoMapFilters.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_AutoMapFilters.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // Tests that AutoMap'd collection navigation fields apply filters correctly // FilterParentGraphType uses AutoMap() which registers the Children navigation - [Fact] + [Test] public async Task AutoMap_ListNavigation_AppliesFilters() { var query = @@ -42,7 +42,7 @@ public async Task AutoMap_ListNavigation_AppliesFilters() // Tests that projection-based AddNavigationListField applies filters // This uses the simple projection-based overload: AddNavigationListField(graph, name, projection) - [Fact] + [Test] public async Task ProjectionBased_NavigationList_AppliesFilters() { var query = @@ -86,7 +86,7 @@ public async Task ProjectionBased_NavigationList_AppliesFilters() // Tests that projection-based AddNavigationField applies ShouldInclude filter // Multiple_nested_Filtered already tests this scenario with Level3Entity - [Fact] + [Test] public async Task ProjectionBased_NavigationSingle_AppliesFilters() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_Cancellation.cs b/src/Tests/IntegrationTests/IntegrationTests_Cancellation.cs index 510f5699a..2d0fd629a 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_Cancellation.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_Cancellation.cs @@ -1,7 +1,7 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task QueryConnection_WithCancelledToken_ThrowsOperationCanceledException() { var query = @@ -54,11 +54,11 @@ public async Task QueryConnection_WithCancelledToken_ThrowsOperationCanceledExce }; // Should throw OperationCanceledException (or derived TaskCanceledException) without wrapping - await Assert.ThrowsAnyAsync(async () => + await Assert.ThrowsAsync(async () => await executer.ExecuteAsync(options)); } - [Fact] + [Test] public async Task QueryConnection_WithOperationCancelled_ThrowsOperationCanceledException() { var query = @@ -111,7 +111,7 @@ public async Task QueryConnection_WithOperationCancelled_ThrowsOperationCanceled // Cancel immediately to trigger OperationCanceledException await cts.CancelAsync(); - await Assert.ThrowsAnyAsync(async () => + await Assert.ThrowsAsync(async () => await executer.ExecuteAsync(options)); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_FieldBuilderExtensions.cs b/src/Tests/IntegrationTests/IntegrationTests_FieldBuilderExtensions.cs index 2a5faf340..d048a172f 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_FieldBuilderExtensions.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_FieldBuilderExtensions.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task FieldBuilder_int_value_type_projection() { var query = @@ -25,7 +25,7 @@ public async Task FieldBuilder_int_value_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_bool_value_type_projection() { var query = @@ -55,7 +55,7 @@ public async Task FieldBuilder_bool_value_type_projection() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task FieldBuilder_datetime_value_type_projection() { var query = @@ -80,7 +80,7 @@ public async Task FieldBuilder_datetime_value_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_decimal_value_type_projection() { var query = @@ -105,7 +105,7 @@ public async Task FieldBuilder_decimal_value_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_double_value_type_projection() { var query = @@ -130,7 +130,7 @@ public async Task FieldBuilder_double_value_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_long_value_type_projection() { var query = @@ -155,7 +155,7 @@ public async Task FieldBuilder_long_value_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_async_bool_value_type_projection() { var query = @@ -184,7 +184,7 @@ public async Task FieldBuilder_async_bool_value_type_projection() await RunQuery(database, query, null, null, false, [entity, parent]); } - [Fact] + [Test] public async Task FieldBuilder_async_int_value_type_projection() { var query = @@ -225,7 +225,7 @@ public async Task FieldBuilder_async_int_value_type_projection() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, parent]); } - [Fact] + [Test] public async Task FieldBuilder_string_reference_type_projection() { var query = @@ -248,7 +248,7 @@ public async Task FieldBuilder_string_reference_type_projection() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_navigation_property_projection() { var query = @@ -282,7 +282,7 @@ public async Task FieldBuilder_navigation_property_projection() await RunQuery(database, query, null, null, false, [entityWithParent, entityWithoutParent, parent]); } - [Fact] + [Test] public async Task FieldBuilder_multiple_value_types_combined() { var query = @@ -318,7 +318,7 @@ public async Task FieldBuilder_multiple_value_types_combined() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task FieldBuilder_enum_scalar_projection() { var query = @@ -353,7 +353,7 @@ public async Task FieldBuilder_enum_scalar_projection() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task FieldBuilder_enum_projection_through_navigation() { // This test verifies that scalar enum projections work correctly when navigating through relationships @@ -403,7 +403,7 @@ public async Task FieldBuilder_enum_projection_through_navigation() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task FieldBuilder_WithProjection_scalar_field_included_in_select() { // Verifies that WithProjection (metadata-only, no resolver wrapping) @@ -434,7 +434,7 @@ public async Task FieldBuilder_WithProjection_scalar_field_included_in_select() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task FieldBuilder_WithProjection_twice_includes_both_in_select() { // Both projections of a field are loaded. The second replaced the first, so the resolver diff --git a/src/Tests/IntegrationTests/IntegrationTests_ForeignKeyProjection.cs b/src/Tests/IntegrationTests/IntegrationTests_ForeignKeyProjection.cs index 051cbf26c..7e5078cb0 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_ForeignKeyProjection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_ForeignKeyProjection.cs @@ -2,7 +2,7 @@ // https://github.com/SimonCropp/GraphQL.EntityFramework/issues/XXX public partial class IntegrationTests { - [Fact] + [Test] public async Task ForeignKey_CustomField_UsesProjectedForeignKey() { var query = @@ -62,7 +62,7 @@ public async Task ForeignKey_CustomField_UsesProjectedForeignKey() await RunQuery(database, query, null, null, false, [activeDepartment, inactiveDepartment, employee1, employee2, employee3]); } - [Fact] + [Test] public async Task ForeignKey_NestedNavigation_IncludesForeignKeyInProjection() { // This test verifies that foreign keys are included in nested navigation projections diff --git a/src/Tests/IntegrationTests/IntegrationTests_abstract_navigation_includes.cs b/src/Tests/IntegrationTests/IntegrationTests_abstract_navigation_includes.cs index f82729773..7091d93f1 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_abstract_navigation_includes.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_abstract_navigation_includes.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // A navigation to an abstract type is projected as a chain of type tests, and the collection // under it is bound once to the result of that chain. The navigation used to be bound whole, // with what was requested under it loaded through includes applied alongside the select. - [Fact] + [Test] public async Task Navigation_under_abstract_navigation_is_loaded() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_abstract_type_include_fallback.cs b/src/Tests/IntegrationTests/IntegrationTests_abstract_type_include_fallback.cs index 8e586ad0a..913da638a 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_abstract_type_include_fallback.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_abstract_type_include_fallback.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // An abstract type is projected as a chain of type tests, each creating a concrete derived // type. It used to be loaded whole through includes. - [Fact] + [Test] public async Task Abstract_root_type_query_is_projected() { var derivedEntity = new DerivedEntity @@ -36,7 +36,7 @@ ... on Derived // A collection selected on a type with derived types is bound once, to whichever type the // chain of type tests created. Bound inside each type's member init it was joined once per // concrete type. - [Fact] + [Test] public async Task Abstract_root_type_collection_is_loaded_once() { var parent = new DerivedEntity @@ -83,7 +83,7 @@ public async Task Abstract_root_type_collection_is_loaded_once() await RunQuery(database, query, null, null, false, [parent, child1, child2, other]); } - [Fact] + [Test] public async Task Navigation_to_abstract_type_is_projected() { var parent = new DerivedEntity @@ -119,7 +119,7 @@ ... on Derived // displayName is expression bodied, so the select cannot bind it and the query falls back to // includes. A mapped get only property, such as computedInDb, no longer causes this. - [Fact] + [Test] public async Task Readonly_root_with_navigation_falls_back_to_include() { var parent = new ReadOnlyParentEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_anonymous_type_projections.cs b/src/Tests/IntegrationTests/IntegrationTests_anonymous_type_projections.cs index 995e1c967..782ef15a6 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_anonymous_type_projections.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_anonymous_type_projections.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Filter_using_anonymous_type_projection_with_For() { var query = @@ -53,7 +53,7 @@ public async Task Filter_using_anonymous_type_projection_with_For() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3, entity4]); } - [Fact] + [Test] public async Task Filter_using_anonymous_type_with_async_filter() { var query = @@ -104,7 +104,7 @@ public async Task Filter_using_anonymous_type_with_async_filter() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_anonymous_type_with_three_properties() { var query = @@ -169,7 +169,7 @@ public async Task Filter_using_anonymous_type_with_three_properties() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3, entity4]); } - [Fact] + [Test] public async Task Filter_using_anonymous_type_with_nested_navigation_property() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_batch_filters.cs b/src/Tests/IntegrationTests/IntegrationTests_batch_filters.cs index 21f2a564d..94b8d2ffd 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_batch_filters.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_batch_filters.cs @@ -3,7 +3,7 @@ // many calls the items shared. public partial class IntegrationTests { - [Fact] + [Test] public async Task Batch_filter_root_list() { var query = @@ -34,7 +34,7 @@ public async Task Batch_filter_root_list() } // Two root fields returning the same type share the call - [Fact] + [Test] public async Task Batch_filter_fields_share_one_call() { var query = @@ -69,7 +69,7 @@ public async Task Batch_filter_fields_share_one_call() } // The children of each parent resolve separately, and are filtered in one call - [Fact] + [Test] public async Task Batch_filter_navigation_list_rows_share_one_call() { var query = @@ -93,7 +93,7 @@ public async Task Batch_filter_navigation_list_rows_share_one_call() } // The parent of each child resolves separately, and is filtered in one call - [Fact] + [Test] public async Task Batch_filter_navigation_rows_share_one_call() { var query = @@ -138,7 +138,7 @@ public async Task Batch_filter_navigation_rows_share_one_call() await RunQuery(database, query, BuildBatchFilters(), [kept, ignored, child1, child2, child3]); } - [Fact] + [Test] public async Task Batch_filter_navigation_connection_rows_share_one_call() { var query = @@ -166,7 +166,7 @@ public async Task Batch_filter_navigation_connection_rows_share_one_call() } // The total count is taken before any filter runs, as it is for a per item filter - [Fact] + [Test] public async Task Batch_filter_root_connection() { var query = @@ -193,7 +193,7 @@ public async Task Batch_filter_root_connection() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_resolve_list_rows_share_one_call() { var query = @@ -216,7 +216,7 @@ public async Task Batch_filter_resolve_list_rows_share_one_call() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_resolve_rows_share_one_call() { var query = @@ -257,7 +257,7 @@ public async Task Batch_filter_resolve_rows_share_one_call() } // Each depth of the query shares one call per batch filter, however many rows it has - [Fact] + [Test] public async Task Batch_filter_one_call_per_depth() { var query = @@ -288,7 +288,7 @@ public async Task Batch_filter_one_call_per_depth() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_single() { var (entities, kept, _) = BuildParentsWithChildren(); @@ -310,7 +310,7 @@ public async Task Batch_filter_single() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_single_excluded() { var (entities, _, ignored) = BuildParentsWithChildren(); @@ -328,7 +328,7 @@ public async Task Batch_filter_single_excluded() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_single_nullable_excluded() { var (entities, _, ignored) = BuildParentsWithChildren(); @@ -346,7 +346,7 @@ public async Task Batch_filter_single_nullable_excluded() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_first() { var (entities, kept, _) = BuildParentsWithChildren(); @@ -364,7 +364,7 @@ public async Task Batch_filter_first() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_first_excluded() { var (entities, _, ignored) = BuildParentsWithChildren(); @@ -382,7 +382,7 @@ public async Task Batch_filter_first_excluded() await RunQuery(database, query, BuildBatchFilters(), entities); } - [Fact] + [Test] public async Task Batch_filter_first_nullable_excluded() { var (entities, _, ignored) = BuildParentsWithChildren(); @@ -401,7 +401,7 @@ public async Task Batch_filter_first_nullable_excluded() } // Items a per item filter excludes are not passed to the batch filter - [Fact] + [Test] public async Task Batch_filter_runs_after_per_item_filters() { var query = @@ -436,7 +436,7 @@ public async Task Batch_filter_runs_after_per_item_filters() await RunQuery(database, query, filters, [parent1, parent2, parent3]); } - [Fact] + [Test] public async Task Batch_filter_on_derived_type_applies_to_base_typed_list() { var query = @@ -471,7 +471,7 @@ public async Task Batch_filter_on_derived_type_applies_to_base_typed_list() await RunQuery(database, query, filters, [derived, derivedKept, derivedWithNavigation]); } - [Fact] + [Test] public async Task Batch_filter_exception() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_circular_include.cs b/src/Tests/IntegrationTests/IntegrationTests_circular_include.cs index 300507d9f..adbfe5280 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_circular_include.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_circular_include.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task ReadOnly_circular_include_does_not_walkback() { var parent = new ReadOnlyParentEntity @@ -36,7 +36,7 @@ public async Task ReadOnly_circular_include_does_not_walkback() await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact] + [Test] public async Task Single_child_to_parent_walkback_skipped() { var entity1 = new ParentEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_clr_discriminator_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_clr_discriminator_projection.cs index 984cb988b..de7965fb6 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_clr_discriminator_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_clr_discriminator_projection.cs @@ -5,7 +5,7 @@ public partial class IntegrationTests /// discriminator property, the discriminator column is included in the SQL SELECT projection /// even when it is not explicitly requested in the GraphQL query. /// - [Fact] + [Test] public async Task CLR_discriminator_included_in_single_field_projection() { var entity = new DiscriminatorDerivedAEntity @@ -34,7 +34,7 @@ public async Task CLR_discriminator_included_in_single_field_projection() /// Without the fix, the projected entity would have EntityType = TypeA (default 0) /// regardless of the actual discriminator value. /// - [Fact] + [Test] public async Task CLR_discriminator_returns_correct_value_when_queried() { var entityA = new DiscriminatorDerivedAEntity @@ -68,7 +68,7 @@ public async Task CLR_discriminator_returns_correct_value_when_queried() /// a list of derived entities, ensuring all returned entities have the correct /// discriminator value. /// - [Fact] + [Test] public async Task CLR_discriminator_included_in_query_field_projection() { var entity1 = new DiscriminatorDerivedAEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_concrete_tph.cs b/src/Tests/IntegrationTests/IntegrationTests_concrete_tph.cs index 8864270ae..ef1963ad4 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_concrete_tph.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_concrete_tph.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // A member init creates the type it names, so projecting a concrete base type materialized // every row as the base and derived rows lost their identity: the derived fragment matched // nothing and __typename was wrong. Types with derived types now load the full entity instead. - [Fact] + [Test] public async Task Concrete_tph_base_keeps_derived_identity() { var query = @@ -35,7 +35,7 @@ ... on ConcreteTphDerived await RunQuery(database, query, null, null, false, [baseEntity, derivedEntity]); } - [Fact] + [Test] public async Task Concrete_tph_base_keeps_derived_identity_single() { var derivedEntity = new ConcreteTphDerivedEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_connection_fragment_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_connection_fragment_projection.cs index 47b562ca1..639eb1b5b 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_connection_fragment_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_connection_fragment_projection.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Connection_items_with_inline_fields() { var query = @@ -20,7 +20,7 @@ public async Task Connection_items_with_inline_fields() await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_items_with_fragment_spread() { var query = @@ -44,7 +44,7 @@ fragment parentFields on Parent { await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_edges_node_with_fragment_spread() { var query = @@ -71,7 +71,7 @@ fragment parentFields on Parent { await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_items_with_inline_fragment() { var query = @@ -93,7 +93,7 @@ ... on Parent { await RunQuery(database, query, null, null, false, entities.ToArray()); } - [Fact] + [Test] public async Task Connection_items_with_fragment_spread_and_children() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_connection_no_page_size.cs b/src/Tests/IntegrationTests/IntegrationTests_connection_no_page_size.cs index 37eba26c2..0be16522d 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_connection_no_page_size.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_connection_no_page_size.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // With neither first nor last, and no page size on the field, first defaulted to zero and the // connection came back with the total count but no edges. It now returns everything. - [Fact] + [Test] public async Task Connection_without_first_or_last_returns_everything() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_connection_ordering.cs b/src/Tests/IntegrationTests/IntegrationTests_connection_ordering.cs index e5c6b8c80..e3797ce4b 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_connection_ordering.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_connection_ordering.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Connection_with_read_only_property_and_navigation() { // ReadOnlyEntity has read-only properties (DisplayName, IsAdult, ComputedInDb) @@ -33,7 +33,7 @@ public async Task Connection_with_read_only_property_and_navigation() await RunQuery(database, query, null, null, false, [parent, entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Connection_with_read_only_property_navigation_and_fragment() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_connection_split_query.cs b/src/Tests/IntegrationTests/IntegrationTests_connection_split_query.cs index 2a53ba56c..abd4162cb 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_connection_split_query.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_connection_split_query.cs @@ -1,7 +1,7 @@ public partial class IntegrationTests { // The resolver's AsSplitQuery is removed, since no collection is selected - [Fact] + [Test] public async Task Connection_split_query_without_collection() { var query = @@ -24,7 +24,7 @@ public async Task Connection_split_query_without_collection() // The resolver's AsSplitQuery is removed from a connection over a type with derived types, // since no collection is selected - [Fact] + [Test] public async Task Connection_split_query_with_derived_types_without_collection() { var query = @@ -53,7 +53,7 @@ public async Task Connection_split_query_with_derived_types_without_collection() } // The resolver's AsSplitQuery is kept, since the children are selected - [Fact] + [Test] public async Task Connection_split_query_with_collection() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_dbcontext_resolution.cs b/src/Tests/IntegrationTests/IntegrationTests_dbcontext_resolution.cs index 3f3c93858..fdfeecf9b 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_dbcontext_resolution.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_dbcontext_resolution.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // The root field and the navigations of every row share one resolve of the DbContext, and a // second execution resolves its own - [Fact] + [Test] public async Task DbContext_resolved_once_per_execution() { var query = @@ -55,10 +55,10 @@ public async Task DbContext_resolved_once_per_execution() var executer = new EfDocumentExecuter(); await Execute(); - Assert.Equal(1, resolves); + await Assert.That(resolves).IsEqualTo(1); await Execute(); - Assert.Equal(2, resolves); + await Assert.That(resolves).IsEqualTo(2); Task Execute() => executer.ExecuteWithErrorCheck( @@ -73,7 +73,7 @@ Task Execute() => // A field context built outside an execution, such as the ResolveEfFieldContext handed to a // query field's resolve, has no execution to hold the DbContext against. It used to throw; it // is resolved from the context's own request services instead, and not held. - [Fact] + [Test] public async Task DbContext_resolved_without_an_execution() { await using var dbContext = NewModelOnlyContext(); @@ -94,8 +94,8 @@ public async Task DbContext_resolved_without_an_execution() RequestServices = provider }; - Assert.Same(dbContext, service.ResolveDbContext(fieldContext)); - Assert.Same(dbContext, service.ResolveDbContext(fieldContext)); - Assert.Equal(2, resolves); + await Assert.That(service.ResolveDbContext(fieldContext)).IsSameReferenceAs(dbContext); + await Assert.That(service.ResolveDbContext(fieldContext)).IsSameReferenceAs(dbContext); + await Assert.That(resolves).IsEqualTo(2); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_filter_navigation_merge.cs b/src/Tests/IntegrationTests/IntegrationTests_filter_navigation_merge.cs index f61cac03f..0c3c867b1 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_filter_navigation_merge.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_filter_navigation_merge.cs @@ -5,7 +5,7 @@ public partial class IntegrationTests /// When a filter accesses Parent.Property and the GraphQL query requests Parent.Id, /// both should be selected in the SQL query. /// - [Fact] + [Test] public async Task Filter_navigation_properties_merged_with_graphql_fields() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_filter_runtime_type.cs b/src/Tests/IntegrationTests/IntegrationTests_filter_runtime_type.cs index ea1ec7602..a4eedd9c3 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_filter_runtime_type.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_filter_runtime_type.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // Field returns an object typed builder. The filter lookup used the static type, // so no filter matched object and a denied parent was returned through parentObject while the // typed parentAlias next to it was correctly null. - [Fact] + [Test] public async Task Filter_applies_to_object_typed_projection_field() { var query = @@ -46,7 +46,7 @@ public async Task Filter_applies_to_object_typed_projection_field() // A filter registered for a derived type was only applied to fields typed as that derived // type. Derived instances returned by a base typed field went unfiltered. - [Fact] + [Test] public async Task Filter_on_derived_type_applies_to_base_typed_list() { var query = @@ -82,7 +82,7 @@ public async Task Filter_on_derived_type_applies_to_base_typed_list() } // The single field variant, so the runtime type is used for a lone item as well as a list - [Fact] + [Test] public async Task Filter_on_derived_type_applies_to_base_typed_single() { var leaf = new TphLeafEntity @@ -113,7 +113,7 @@ public async Task Filter_on_derived_type_applies_to_base_typed_single() // A result is only filtered when a filter applies to one of its items, and finding that walks // every item. The first item here is of a type with no filter, so a walk that stopped at the // first item, or the first type, would return the filtered item unfiltered. - [Fact] + [Test] public async Task Filter_on_derived_type_applies_when_not_first_in_list() { var query = @@ -151,7 +151,7 @@ public async Task Filter_on_derived_type_applies_when_not_first_in_list() // The navigation variant. The navigation is typed as the abstract base, so whether a filter // applies has to be decided from the runtime type of the parent it returns, not the navigation's // type, which no filter is registered for. - [Fact] + [Test] public async Task Filter_on_derived_type_applies_to_base_typed_navigation() { var query = @@ -207,7 +207,7 @@ public async Task Filter_on_derived_type_applies_to_base_typed_navigation() // The projection requirements of a derived type filter are loaded by a base typed query, so // the filter can read them from the derived items it is applied to. - [Fact] + [Test] public async Task Filter_on_derived_type_requirements_loaded_by_base_typed_query() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_filtered.cs b/src/Tests/IntegrationTests/IntegrationTests_filtered.cs index e175f1f73..d774af80f 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_filtered.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_filtered.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Child_filtered() { var query = @@ -61,7 +61,7 @@ class FilterProjection public string? Property { get; set; } } - [Fact] + [Test] public async Task RootList_filtered() { var query = @@ -87,7 +87,7 @@ public async Task RootList_filtered() await RunQuery(database, query, null, BuildFilters(), false, [entity1, entity2]); } - [Fact] + [Test] public async Task Root_connectionFiltered() { var query = @@ -120,7 +120,7 @@ public async Task Root_connectionFiltered() await RunQuery(database, query, null, BuildFilters(), false, [entity1, entity2]); } - [Fact] + [Test] public async Task Connection_parent_child_Filtered() { var query = @@ -167,7 +167,7 @@ public async Task Connection_parent_child_Filtered() await RunQuery(database, query, null, BuildFilters(), false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Multiple_nested_Filtered() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_filters_without_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_filters_without_projection.cs index 459582737..351ae35d8 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_filters_without_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_filters_without_projection.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Filter_without_projection_sync() { var query = @@ -40,7 +40,7 @@ public async Task Filter_without_projection_sync() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_without_projection_async() { var query = @@ -83,7 +83,7 @@ public async Task Filter_without_projection_async() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_without_projection_denies_all() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_guarded_key.cs b/src/Tests/IntegrationTests/IntegrationTests_guarded_key.cs index a1a664d20..55b14dddb 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_guarded_key.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_guarded_key.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Query_entity_with_guarded_key_setter() { var entity = new GuardedKeyEntity("test@example.com"); @@ -20,7 +20,7 @@ public async Task Query_entity_with_guarded_key_setter() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] + [Test] public async Task Single_entity_with_guarded_key_setter() { var entity = new GuardedKeyEntity("test@example.com"); @@ -40,8 +40,8 @@ public async Task Single_entity_with_guarded_key_setter() await RunQuery(database, query, null, null, false, [entity]); } - [Fact] - public void Projection_with_guarded_key_setter_returns_null() + [Test] + public async Task Projection_with_guarded_key_setter_returns_null() { // When a key property has a custom (non-auto) setter, // TryBuild should return null to fall back to full entity loading, @@ -59,7 +59,7 @@ public void Projection_with_guarded_key_setter_returns_null() var result = SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression); - Assert.False(result); - Assert.Null(expression); + await Assert.That(result).IsFalse(); + await Assert.That(expression).IsNull(); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_in_comparison.cs b/src/Tests/IntegrationTests/IntegrationTests_in_comparison.cs index e8e9d59eb..ce753ec9d 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_in_comparison.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_in_comparison.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // The `in` comparison was limited to a fixed set of types for the list Contains lookup, which // did not include Date and Time even though their values could be converted. - [Fact] + [Test] public async Task Where_in_on_date() { var query = @@ -32,7 +32,7 @@ public async Task Where_in_on_date() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Where_in_on_time() { var query = @@ -59,7 +59,7 @@ public async Task Where_in_on_time() } // decimal had neither a list converter nor a Contains entry - [Fact] + [Test] public async Task Where_in_on_decimal() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_include_guard.cs b/src/Tests/IntegrationTests/IntegrationTests_include_guard.cs index 9082a2f43..5708d4889 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_include_guard.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_include_guard.cs @@ -5,7 +5,7 @@ public partial class IntegrationTests // never included, and came back null. Only the inverse of the navigation just traversed is // skipped now, which is the one nested include EF rejects. summary is read only, so cannot be // bound by a select, which is what puts these queries on the includes path. - [Fact] + [Test] public async Task Unrelated_navigation_to_base_type_is_included() { var related = new TphLeafEntity @@ -50,7 +50,7 @@ public async Task Unrelated_navigation_to_base_type_is_included() } // The inverse skip has to hold in a no tracking query, where EF rejects the cycle outright - [Fact] + [Test] public async Task Tph_base_type_include_skipped_with_filter_no_tracking() { var leaf = new TphLeafEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_interface_field_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_interface_field_projection.cs index 039a478a1..4d77fb209 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_interface_field_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_interface_field_projection.cs @@ -6,7 +6,7 @@ public partial class IntegrationTests // Selected on the interface it was not: the field of the interface carries no projection, and // only that field was looked at. - [Fact] + [Test] public async Task Interface_field_uses_projection_of_implementing_types() { var query = @@ -26,7 +26,7 @@ public async Task Interface_field_uses_projection_of_implementing_types() // A fragment at the root of an interface typed query is not among the sub fields, so its // fields were recorded by name alone and their projections never read. - [Fact] + [Test] public async Task Interface_field_in_root_fragment_uses_its_projection() { var query = @@ -51,7 +51,7 @@ ... on DerivedWithNavigation await RunQuery(database, query, null, null, false, InterfaceProjectionEntities()); } - [Fact] + [Test] public async Task Interface_field_in_connection_uses_projection_of_implementing_types() { var query = @@ -72,7 +72,7 @@ public async Task Interface_field_in_connection_uses_projection_of_implementing_ await RunQuery(database, query, null, null, false, InterfaceProjectionEntities()); } - [Fact] + [Test] public async Task Interface_field_under_navigation_uses_projection_of_implementing_types() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_items_navigation.cs b/src/Tests/IntegrationTests/IntegrationTests_items_navigation.cs index 397d454a4..4c5a534b4 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_items_navigation.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_items_navigation.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // A field named items, edges or node was taken for a connection wrapper by its name alone, // so a navigation named Items was never projected and came back empty. The wrapper is now // recognised by the graph type the field is selected from. - [Fact] + [Test] public async Task Navigation_named_items_is_projected() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_named_type_filter_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_named_type_filter_projection.cs index f85d01bb0..f4645773a 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_named_type_filter_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_named_type_filter_projection.cs @@ -6,7 +6,7 @@ public partial class IntegrationTests /// ChildEntity.Parent is a ParentEntity with only Id and Property, but in a real scenario /// the navigation entity would have many more columns that shouldn't be selected. /// - [Fact] + [Test] public async Task Named_record_filter_projection_should_select_minimal_columns() { var query = @@ -57,7 +57,7 @@ public async Task Named_record_filter_projection_should_select_minimal_columns() /// /// Actual behavior (BUG): SQL includes ALL parent fields because Include() is used. /// - [Fact] + [Test] public async Task Filter_projection_should_not_select_all_navigation_fields() { var query = @@ -121,7 +121,7 @@ public async Task Filter_projection_should_not_select_all_navigation_fields() /// Expected: SQL should only select BaseEntity.CommonProperty (required by filter) /// Actual (BUG): SQL includes ALL fields (Field1-Field10) due to Include() being used /// - [Fact] + [Test] public async Task Filter_projection_with_TPH_inheritance_should_not_select_all_fields() { var query = @@ -188,7 +188,7 @@ public async Task Filter_projection_with_TPH_inheritance_should_not_select_all_f /// - The filter projection accesses properties through the abstract navigation /// - e.g. _.Parent.Property where Parent is of abstract type BaseEntity /// - [Fact] + [Test] public async Task Filter_projection_with_abstract_navigation_should_not_throw() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_navigation_arguments_in_sql.cs b/src/Tests/IntegrationTests/IntegrationTests_navigation_arguments_in_sql.cs index e6b396c2f..0d1440379 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_navigation_arguments_in_sql.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_navigation_arguments_in_sql.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // The where of a navigation list was applied in memory to the projected children, so it // followed the ordinal in memory rules rather than the database collation, and it only saw // the columns the selection had asked for. It is now applied inside the collection subquery. - [Fact] + [Test] public async Task Navigation_where_evaluates_in_sql() { var query = @@ -40,7 +40,7 @@ public async Task Navigation_where_evaluates_in_sql() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Navigation_where_on_unselected_property() { var query = @@ -77,7 +77,7 @@ public async Task Navigation_where_on_unselected_property() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Navigation_orderBy_on_unselected_property() { var query = @@ -116,7 +116,7 @@ public async Task Navigation_orderBy_on_unselected_property() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Navigation_ids_evaluates_in_sql() { var query = @@ -153,7 +153,7 @@ public async Task Navigation_ids_evaluates_in_sql() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Navigation_where_from_variable() { var query = @@ -197,7 +197,7 @@ public async Task Navigation_where_from_variable() } // Skip and take stay with the resolver, applied to the collection the query filtered and ordered - [Fact] + [Test] public async Task Navigation_skip_take_after_sql_where() { var query = @@ -242,7 +242,7 @@ public async Task Navigation_skip_take_after_sql_where() // One loaded collection cannot satisfy two sets of arguments, so aliases with different // arguments fall back to loading the collection whole and filtering in memory - [Fact] + [Test] public async Task Navigation_aliases_with_different_where() { var query = @@ -283,7 +283,7 @@ public async Task Navigation_aliases_with_different_where() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Navigation_connection_where_evaluates_in_sql() { var query = @@ -326,7 +326,7 @@ public async Task Navigation_connection_where_evaluates_in_sql() // A resolver that returns something other than the projected collection keeps the in memory // pass, which now ignores case the way the database does - [Fact] + [Test] public async Task Navigation_custom_resolver_where_in_memory() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_navigation_key_order.cs b/src/Tests/IntegrationTests/IntegrationTests_navigation_key_order.cs index 117afbcd7..bc79d872e 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_navigation_key_order.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_navigation_key_order.cs @@ -32,21 +32,21 @@ static object[] ParentWithChild() return [parent, child]; } - [Fact] + [Test] public async Task Navigation_without_orderBy_ordered_by_key() { await using var database = await sqlInstance.Build(); await RunQuery(database, parentChildQuery, null, null, false, ParentWithChild()); } - [Fact] + [Test] public async Task Navigation_without_orderBy_not_ordered_by_key() { await using var database = await sqlInstance.Build(); await RunQuery(database, parentChildQuery, null, null, false, ParentWithChild(), orderNavigationsByKey: false); } - [Fact] + [Test] public async Task Navigation_with_orderBy_not_ordered_by_key() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_navigation_merge.cs b/src/Tests/IntegrationTests/IntegrationTests_navigation_merge.cs index 65a258255..61a5a0f79 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_navigation_merge.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_navigation_merge.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // The same navigation selected under two aliases. Whichever selection was processed first // used to win, so the fields asked for by the other came back as defaults. - [Fact] + [Test] public async Task Aliased_navigation_selections_merge() { var query = @@ -42,7 +42,7 @@ public async Task Aliased_navigation_selections_merge() // A navigation field and a projection based field that projects the same navigation, selected // side by side. The navigation field was processed first, and the projection based field was // then skipped, so the fields it selected were never projected. - [Fact] + [Test] public async Task Projection_based_field_merges_with_navigation_field() { var query = @@ -79,7 +79,7 @@ public async Task Projection_based_field_merges_with_navigation_field() } // Navigations below the aliased selections are merged as well - [Fact] + [Test] public async Task Aliased_navigation_selections_merge_nested_navigations() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_nested_fragment_navigations.cs b/src/Tests/IntegrationTests/IntegrationTests_nested_fragment_navigations.cs index ef3d1b762..7b095ecd6 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_nested_fragment_navigations.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_nested_fragment_navigations.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // Derived type navigations under a fragment were collected for the root selection only, so // below a navigation the derived navigation fell through to the scalar path and was dropped - [Fact] + [Test] public async Task Derived_navigation_under_fragment_below_reference_navigation() { var category = new CategoryEntity @@ -41,7 +41,7 @@ ... on TphDerivedNavCategory { await RunQuery(database, query, null, null, false, [category, item, owner]); } - [Fact] + [Test] public async Task Derived_navigations_under_fragments_below_collection_navigation() { var category = new CategoryEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_nested_fragments.cs b/src/Tests/IntegrationTests/IntegrationTests_nested_fragments.cs index cf15d5adb..ab6a52b0e 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_nested_fragments.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_nested_fragments.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // Below the root, fragments were followed one level down only, so a fragment that spread // another fragment contributed nothing to the projection. - [Fact] + [Test] public async Task Fragment_spread_inside_fragment_spread() { var query = @@ -44,7 +44,7 @@ fragment childProperty on Child await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact] + [Test] public async Task Fragment_spread_inside_inline_fragment() { var query = @@ -86,7 +86,7 @@ fragment childProperty on Child // The root is abstract, so this takes the include path. The navigation on the derived type is // selected by an inline fragment that sits inside a fragment spread, which was not followed. - [Fact] + [Test] public async Task Derived_navigation_inline_fragment_inside_fragment_spread() { var category = new CategoryEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_nested_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_nested_projection.cs index dd4ec4b4b..35ab297bc 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_nested_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_nested_projection.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // Below the root, the edges/items/node wrappers of a connection were recorded as scalar fields // named after the wrapper, so only the keys of the nodes were projected and every other // scalar came back null. - [Fact] + [Test] public async Task Nested_connection_projects_scalars() { var query = @@ -56,7 +56,7 @@ public async Task Nested_connection_projects_scalars() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Nested_connection_under_root_connection_projects_scalars() { var query = @@ -97,7 +97,7 @@ public async Task Nested_connection_under_root_connection_projects_scalars() // Projection metadata was only looked up for the root sub fields. A projection based field // below a navigation was matched against the entity by its GraphQL name, found nothing, and // so the navigation it projects was never loaded. - [Fact] + [Test] public async Task Nested_projection_based_navigation_field() { var query = @@ -133,7 +133,7 @@ public async Task Nested_projection_based_navigation_field() await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact] + [Test] public async Task Nested_projection_based_scalar_fields() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_null_ids.cs b/src/Tests/IntegrationTests/IntegrationTests_null_ids.cs index 94d4cb78a..76461f930 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_null_ids.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_null_ids.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // A null ids argument was dereferenced for its type name while building the unsupported // type error. It is now the same as not passing ids. - [Fact] + [Test] public async Task Null_ids_returns_everything() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_nullable_value_projections.cs b/src/Tests/IntegrationTests/IntegrationTests_nullable_value_projections.cs index 346abe645..619d368e3 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_nullable_value_projections.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_nullable_value_projections.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Filter_nullable_int_projection_with_value() { var query = @@ -46,7 +46,7 @@ public async Task Filter_nullable_int_projection_with_value() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_nullable_int_projection_is_null() { var query = @@ -92,7 +92,7 @@ public async Task Filter_nullable_int_projection_is_null() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_nullable_bool_projection() { var query = @@ -145,7 +145,7 @@ public async Task Filter_nullable_bool_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3, entity4]); } - [Fact] + [Test] public async Task Filter_nullable_datetime_projection() { var query = @@ -200,7 +200,7 @@ public async Task Filter_nullable_datetime_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3, entity4]); } - [Fact] + [Test] public async Task Filter_nullable_string_is_not_null() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_query_with_select_projection.cs b/src/Tests/IntegrationTests/IntegrationTests_query_with_select_projection.cs index 2520ab31b..3726b2fff 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_query_with_select_projection.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_query_with_select_projection.cs @@ -7,7 +7,7 @@ public partial class IntegrationTests /// EF Core throws "Include has been used on non entity queryable" when Include is /// applied after Select. /// - [Fact] + [Test] public async Task Query_with_select_projection_and_filter() { var query = @@ -44,7 +44,7 @@ public async Task Query_with_select_projection_and_filter() /// This is the scenario where GroundTransportOrderedView.Select(_ => _.GroundTransport) /// is used, and the filter accesses GroundTransport.TravelRequest.HighestStatusAchieved. /// - [Fact] + [Test] public async Task Query_with_select_projection_and_filter_accessing_navigation() { var query = @@ -85,7 +85,7 @@ public async Task Query_with_select_projection_and_filter_accessing_navigation() /// Tests that regular queries (without Select projection in resolver) still work /// correctly with filters that require navigation properties. /// - [Fact] + [Test] public async Task Query_without_select_projection_with_navigation_filter() { var query = @@ -130,7 +130,7 @@ public async Task Query_without_select_projection_with_navigation_filter() /// - The filter accesses TravelRequest.HighestStatusAchieved (a navigation property) /// - Include must be added to load TravelRequest for the filter to work /// - [Fact] + [Test] public async Task AddSingleField_with_filter_accessing_navigation_uses_include() { var query = @@ -176,7 +176,7 @@ public async Task AddSingleField_with_filter_accessing_navigation_uses_include() /// Tests that AddSingleField filter correctly denies access when the navigation property /// doesn't match the filter criteria. /// - [Fact] + [Test] public async Task AddSingleField_with_filter_accessing_navigation_denies_when_no_match() { // Query the nullable endpoint to avoid SingleEntityNotFoundException diff --git a/src/Tests/IntegrationTests/IntegrationTests_readonly_navigation_fallback.cs b/src/Tests/IntegrationTests/IntegrationTests_readonly_navigation_fallback.cs index f0c8941ec..fe4733213 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_readonly_navigation_fallback.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_readonly_navigation_fallback.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // displayName is expression bodied: it has no column to select and no field to bind, so the // navigation is bound whole. A get only property that is mapped, such as computedInDb, is // bound through its backing field and no longer causes this. - [Fact] + [Test] public async Task Collection_navigation_to_entity_with_readonly_property_falls_back_to_full_include() { var parent = new ReadOnlyParentEntity @@ -39,7 +39,7 @@ public async Task Collection_navigation_to_entity_with_readonly_property_falls_b await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact] + [Test] public async Task Single_query_with_collection_navigation_to_readonly_entity() { var parent = new ReadOnlyParentEntity @@ -76,8 +76,8 @@ public async Task Single_query_with_collection_navigation_to_readonly_entity() await RunQuery(database, query, null, null, false, [parent, child]); } - [Fact] - public void Projection_with_readonly_scalar_on_collection_navigation_builds_expression() + [Test] + public async Task Projection_with_readonly_scalar_on_collection_navigation_builds_expression() { // When a collection navigation target has a read-only property, // TryBuild should succeed by falling back to including the full navigation entity. @@ -104,12 +104,12 @@ public void Projection_with_readonly_scalar_on_collection_navigation_builds_expr var result = SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression); - Assert.True(result); - Assert.NotNull(expression); + await Assert.That(result).IsTrue(); + await Assert.That(expression).IsNotNull(); } - [Fact] - public void Projection_with_readonly_scalar_on_single_navigation_builds_expression() + [Test] + public async Task Projection_with_readonly_scalar_on_single_navigation_builds_expression() { // When a single navigation target has a read-only property, // TryBuild should succeed by falling back to including the full navigation entity. @@ -136,12 +136,12 @@ public void Projection_with_readonly_scalar_on_single_navigation_builds_expressi var result = SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression); - Assert.True(result); - Assert.NotNull(expression); + await Assert.That(result).IsTrue(); + await Assert.That(expression).IsNotNull(); } - [Fact] - public void Projection_with_readonly_scalar_at_root_still_returns_null() + [Test] + public async Task Projection_with_readonly_scalar_at_root_still_returns_null() { // A read-only property at the ROOT entity level // still causes TryBuild to return null (load full entity). @@ -158,7 +158,7 @@ public void Projection_with_readonly_scalar_at_root_still_returns_null() var result = SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression); - Assert.False(result); - Assert.Null(expression); + await Assert.That(result).IsFalse(); + await Assert.That(expression).IsNull(); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_resolve_list_filters.cs b/src/Tests/IntegrationTests/IntegrationTests_resolve_list_filters.cs index c2165a46a..3cd532dfd 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_resolve_list_filters.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_resolve_list_filters.cs @@ -2,9 +2,9 @@ public partial class IntegrationTests { // ResolveList and ResolveListAsync returned their items as is, while every other list path // applies the filters, so a filter that excluded an item elsewhere let it through here - [Theory] - [InlineData("childrenViaResolveList")] - [InlineData("childrenViaResolveListAsync")] + [Test] + [Arguments("childrenViaResolveList")] + [Arguments("childrenViaResolveListAsync")] public async Task Resolve_list_applies_filters(string fieldName) { var query = @@ -42,7 +42,7 @@ public async Task Resolve_list_applies_filters(string fieldName) projection: _ => _.Property, filter: (_, _, _, property) => property != "Denied"); - await using var database = await sqlInstance.Build(); + await using var database = await sqlInstance.Build(databaseSuffix: fieldName); await RunQuery(database, query, null, filters, false, [parent, allowed, denied]); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_resolverless_navigations.cs b/src/Tests/IntegrationTests/IntegrationTests_resolverless_navigations.cs index 99ab27c20..f23525b90 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_resolverless_navigations.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_resolverless_navigations.cs @@ -3,7 +3,7 @@ public partial class IntegrationTests // The resolver-less navigation overloads on an object type fell back to GraphQL.NET's name // resolver, which returned the raw property, ignored the arguments and applied no filters. // They now get the same resolver AutoMap uses. - [Fact] + [Test] public async Task Resolverless_list_applies_arguments_and_filters() { var query = @@ -51,7 +51,7 @@ public async Task Resolverless_list_applies_arguments_and_filters() await RunQuery(database, query, null, filters, false, [parent, child1, child2, child3]); } - [Fact] + [Test] public async Task Resolverless_connection_pages() { var query = @@ -92,7 +92,7 @@ public async Task Resolverless_connection_pages() await RunQuery(database, query, null, null, false, [parent, child1, child2]); } - [Fact] + [Test] public async Task Resolverless_single_applies_filters() { var query = @@ -141,7 +141,7 @@ public async Task Resolverless_single_applies_filters() // The field's selection set went to the first path in the projection expression, so with // `new { _.Child2, _.Child1 }` resolving Child1, nothing under Child1 was projected - [Fact] + [Test] public async Task Selection_applies_to_navigation_of_field_type() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_simple_type_overloads.cs b/src/Tests/IntegrationTests/IntegrationTests_simple_type_overloads.cs index 106547372..76381e467 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_simple_type_overloads.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_simple_type_overloads.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Filter_using_int_overload() { var query = @@ -40,7 +40,7 @@ public async Task Filter_using_int_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_nullable_int_overload() { var query = @@ -80,7 +80,7 @@ public async Task Filter_using_nullable_int_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_datetime_overload() { var query = @@ -122,7 +122,7 @@ public async Task Filter_using_datetime_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_nullable_datetime_overload() { var query = @@ -164,7 +164,7 @@ public async Task Filter_using_nullable_datetime_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_bool_overload() { var query = @@ -204,7 +204,7 @@ public async Task Filter_using_bool_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_nullable_bool_overload() { var query = @@ -244,7 +244,7 @@ public async Task Filter_using_nullable_bool_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_guid_overload() { var query = @@ -286,7 +286,7 @@ public async Task Filter_using_guid_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_nullable_guid_overload() { var query = @@ -328,7 +328,7 @@ public async Task Filter_using_nullable_guid_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_string_overload() { var query = @@ -364,7 +364,7 @@ public async Task Filter_using_string_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_async_int_overload() { var query = @@ -408,7 +408,7 @@ public async Task Filter_using_async_int_overload() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_using_boolean_expression_shorthand() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_simplified_filter_api.cs b/src/Tests/IntegrationTests/IntegrationTests_simplified_filter_api.cs index f9389d657..c1aa35f6e 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_simplified_filter_api.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_simplified_filter_api.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Simplified_filter_sync_with_pk_access() { var query = @@ -26,7 +26,7 @@ public async Task Simplified_filter_sync_with_pk_access() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_async_with_fk_access() { var parent1 = new ParentEntity { Property = "Parent1" }; @@ -59,7 +59,7 @@ public async Task Simplified_filter_async_with_fk_access() await RunQuery(database, query, null, filters, false, [parent1, parent2, entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_multiple_fk_access() { var parent1 = new ParentEntity { Property = "Parent1" }; @@ -89,7 +89,7 @@ public async Task Simplified_filter_multiple_fk_access() await RunQuery(database, query, null, filters, false, [parent1, parent2, parent3, entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_nullable_fk_handling() { var parent1 = new ParentEntity { Property = "Parent1" }; @@ -117,7 +117,7 @@ public async Task Simplified_filter_nullable_fk_handling() await RunQuery(database, query, null, filters, false, [parent1, entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_combined_with_existing_filters() { var query = @@ -148,7 +148,7 @@ public async Task Simplified_filter_combined_with_existing_filters() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_list_query_filtering() { var query = @@ -174,7 +174,7 @@ public async Task Simplified_filter_list_query_filtering() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Simplified_filter_connection_query_filtering() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_tph_base_type_include.cs b/src/Tests/IntegrationTests/IntegrationTests_tph_base_type_include.cs index 23436a44b..2f8d4e01d 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_tph_base_type_include.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_tph_base_type_include.cs @@ -4,7 +4,7 @@ // causing a circular include (e.g. TravelRequest -> Attachment -> BaseRequest). // The include path skips the inverse of the navigation it came through, which is the one // nested include EF rejects in a no tracking query. - [Fact] + [Test] public async Task Tph_base_type_include_skipped_with_filter() { var leaf = new TphLeafEntity @@ -43,7 +43,7 @@ public async Task Tph_base_type_include_skipped_with_filter() await RunQuery(database, query, null, BuildTphFilters(), false, [leaf, attachment]); } - [Fact] + [Test] public async Task Tph_base_type_single_include_skipped_with_filter() { var leaf = new TphLeafEntity diff --git a/src/Tests/IntegrationTests/IntegrationTests_tph_derived_navigation.cs b/src/Tests/IntegrationTests/IntegrationTests_tph_derived_navigation.cs index 6436a7c2b..71dd87c8b 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_tph_derived_navigation.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_tph_derived_navigation.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Tph_derived_navigation_via_inline_fragments() { var category = new CategoryEntity { Name = "Science" }; @@ -38,7 +38,7 @@ ... on TphDerivedNavRegion { await RunQuery(database, query, null, null, false, [category, region, categoryItem, regionItem]); } - [Fact] + [Test] public async Task Tph_derived_navigation_via_inline_fragments_single() { var category = new CategoryEntity { Name = "History" }; @@ -65,7 +65,7 @@ ... on TphDerivedNavCategory { await RunQuery(database, query, null, null, false, [category, categoryItem]); } - [Fact] + [Test] public async Task Tph_derived_navigation_base_fields_still_work() { var categoryItem = new TphDerivedNavCategoryEntity { Property = "BaseOnly" }; @@ -86,7 +86,7 @@ public async Task Tph_derived_navigation_base_fields_still_work() await RunQuery(database, query, null, null, false, [categoryItem, regionItem]); } - [Fact] + [Test] public async Task Tph_derived_navigation_mixed_with_base_scalars() { var category = new CategoryEntity { Name = "Art" }; diff --git a/src/Tests/IntegrationTests/IntegrationTests_typed_order_by.cs b/src/Tests/IntegrationTests/IntegrationTests_typed_order_by.cs index 548b8bdf1..aae69c6d6 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_typed_order_by.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_typed_order_by.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task OrderBy_two_keys() { var query = @@ -38,7 +38,7 @@ public async Task OrderBy_two_keys() await RunQuery(database, query, null, null, false, [parent, child1, child2, child3]); } - [Fact] + [Test] public async Task OrderBy_nested_descending() { var query = @@ -83,7 +83,7 @@ public async Task OrderBy_nested_descending() await RunQuery(database, query, null, null, false, [parent1, parent2, child1, child2, child3]); } - [Fact] + [Test] public async Task OrderBy_item_with_two_properties() { var query = @@ -100,7 +100,7 @@ public async Task OrderBy_item_with_two_properties() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task OrderBy_empty_item() { var query = @@ -117,7 +117,7 @@ public async Task OrderBy_empty_item() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task OrderBy_with_typed_variable() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_typed_where.cs b/src/Tests/IntegrationTests/IntegrationTests_typed_where.cs index 356697ccb..f0e1899fc 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_typed_where.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_typed_where.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Where_and_or_not() { var query = @@ -47,7 +47,7 @@ public async Task Where_and_or_not() await RunQuery(database, query, null, null, false, [entity1, entity2, entity3, entity4]); } - [Fact] + [Test] public async Task Where_nested_navigation() { var query = @@ -91,9 +91,9 @@ public async Task Where_nested_navigation() await RunQuery(database, query, null, null, false, [parent1, parent2, child1, child2]); } - [Theory] - [InlineData(true)] - [InlineData(false)] + [Test] + [Arguments(true)] + [Arguments(false)] public async Task Where_navigation_is_null(bool isNull) { var query = @@ -124,11 +124,11 @@ public async Task Where_navigation_is_null(bool isNull) Property = "Child2" }; - await using var database = await sqlInstance.Build(); + await using var database = await sqlInstance.Build(databaseSuffix: isNull.ToString()); await RunQuery(database, query, null, null, false, [parent, withParent, orphan]); } - [Fact] + [Test] public async Task Where_is_null_at_root() { var query = @@ -145,10 +145,10 @@ public async Task Where_is_null_at_root() await RunQuery(database, query, null, null, false, []); } - [Theory] - [InlineData("any")] - [InlineData("all")] - [InlineData("none")] + [Test] + [Arguments("any")] + [Arguments("all")] + [Arguments("none")] public async Task Where_collection(string quantifier) { var query = @@ -211,11 +211,11 @@ public async Task Where_collection(string quantifier) Property = "NoChildren" }; - await using var database = await sqlInstance.Build(); + await using var database = await sqlInstance.Build(databaseSuffix: quantifier); await RunQuery(database, query, null, null, false, [allMatch, someMatch, noneMatch, noChildren]); } - [Fact] + [Test] public async Task Where_collection_any_without_conditions() { var query = @@ -253,7 +253,7 @@ public async Task Where_collection_any_without_conditions() } // The value arrives as a GraphQL Decimal, so the server culture plays no part - [Fact] + [Test] public async Task Where_typed_value_is_culture_independent() { var query = @@ -291,7 +291,7 @@ public async Task Where_typed_value_is_culture_independent() } } - [Fact] + [Test] public async Task Where_typed_comparisons() { var query = @@ -354,7 +354,7 @@ public async Task Where_typed_comparisons() await RunQuery(database, query, null, null, false, [match, tooOld, inactive, wrongStatus]); } - [Fact] + [Test] public async Task Where_in_with_null() { var query = @@ -381,7 +381,7 @@ public async Task Where_in_with_null() await RunQuery(database, query, null, null, false, [one, two, none]); } - [Fact] + [Test] public async Task Where_with_typed_variable() { var query = @@ -424,7 +424,7 @@ public async Task Where_with_typed_variable() await RunQuery(database, query, inputs, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_empty_applies_no_filter() { var query = @@ -450,7 +450,7 @@ public async Task Where_empty_applies_no_filter() await RunQuery(database, query, null, null, false, [entity1, entity2]); } - [Fact] + [Test] public async Task Where_unknown_property() { var query = @@ -467,7 +467,7 @@ public async Task Where_unknown_property() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Where_value_of_wrong_type() { var query = @@ -484,7 +484,7 @@ public async Task Where_value_of_wrong_type() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Where_comparison_not_available_for_type() { var query = @@ -501,7 +501,7 @@ public async Task Where_comparison_not_available_for_type() await RunQuery(database, query, null, null, false, []); } - [Fact] + [Test] public async Task Where_owned() { var query = @@ -547,7 +547,7 @@ public async Task Where_owned() await RunQuery(database, query, null, null, false, [match, other]); } - [Fact] + [Test] public async Task Where_collection_on_navigation_list() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_validate_projection_compatibility.cs b/src/Tests/IntegrationTests/IntegrationTests_validate_projection_compatibility.cs index 3b2bcdcb8..a5f0c6586 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_validate_projection_compatibility.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_validate_projection_compatibility.cs @@ -1,7 +1,7 @@ public partial class IntegrationTests { - [Fact] - public void Querying_abstract_type_returns_false() + [Test] + public async Task Querying_abstract_type_returns_false() { var projection = new FieldProjectionInfo( [with(StringComparer.OrdinalIgnoreCase), "Property"], @@ -13,33 +13,31 @@ public void Querying_abstract_type_returns_false() var result = SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression); - Assert.False(result); - Assert.Null(expression); + await Assert.That(result).IsFalse(); + await Assert.That(expression).IsNull(); } - [Fact] - public void Filter_with_identity_projection_does_not_throw() + [Test] + public async Task Filter_with_identity_projection_does_not_throw() { var filters = new Filters(); - var exception = Record.Exception(() => - filters.For().Add( - projection: _ => _, - filter: (_, _, _, entity) => entity.Property == "Test")); - - Assert.Null(exception); + await Assert.That(() => + filters.For().Add( + projection: _ => _, + filter: (_, _, _, entity) => entity.Property == "Test")) + .ThrowsNothing(); } - [Fact] - public void Filter_with_explicit_projection_does_not_throw() + [Test] + public async Task Filter_with_explicit_projection_does_not_throw() { var filters = new Filters(); - var exception = Record.Exception(() => - filters.For().Add( - projection: e => new { e.Id, e.Property }, - filter: (_, _, _, proj) => proj.Property == "Test")); - - Assert.Null(exception); + await Assert.That(() => + filters.For().Add( + projection: _ => new { _.Id, _.Property }, + filter: (_, _, _, proj) => proj.Property == "Test")) + .ThrowsNothing(); } } diff --git a/src/Tests/IntegrationTests/IntegrationTests_value_projections.cs b/src/Tests/IntegrationTests/IntegrationTests_value_projections.cs index 25e67130e..052303739 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_value_projections.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_value_projections.cs @@ -1,6 +1,6 @@ public partial class IntegrationTests { - [Fact] + [Test] public async Task Filter_string_projection() { var query = @@ -43,7 +43,7 @@ public async Task Filter_string_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_int_projection() { var query = @@ -89,7 +89,7 @@ public async Task Filter_int_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_bool_projection() { var query = @@ -135,7 +135,7 @@ public async Task Filter_bool_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_datetime_projection() { var query = @@ -183,7 +183,7 @@ public async Task Filter_datetime_projection() await RunQuery(database, query, null, filters, false, [entity1, entity2, entity3]); } - [Fact] + [Test] public async Task Filter_guid_projection() { var query = diff --git a/src/Tests/IntegrationTests/IntegrationTests_whole_navigation.cs b/src/Tests/IntegrationTests/IntegrationTests_whole_navigation.cs index bff1aff6a..5539f3c55 100644 --- a/src/Tests/IntegrationTests/IntegrationTests_whole_navigation.cs +++ b/src/Tests/IntegrationTests/IntegrationTests_whole_navigation.cs @@ -2,7 +2,7 @@ public partial class IntegrationTests { // A filter whose projection is the navigation itself had that navigation skipped when merging // its requirements, so the filter saw null. It is now loaded whole. - [Fact] + [Test] public async Task Filter_reading_whole_navigation_sees_its_properties() { var allowParent = new ParentEntity diff --git a/src/Tests/KeyNameExtractorTests.cs b/src/Tests/KeyNameExtractorTests.cs index 193155a31..fbe374afa 100644 --- a/src/Tests/KeyNameExtractorTests.cs +++ b/src/Tests/KeyNameExtractorTests.cs @@ -6,8 +6,8 @@ public class KeyNameExtractorTests // Entities were skipped when their assembly name started with System, meant for the // Dictionary join entity of a shadow many to many. A user assembly named // that way lost every key, so ids disappeared from the schema. - [Fact] - public void Entity_in_assembly_named_like_system_keeps_its_key() + [Test] + public async Task Entity_in_assembly_named_like_system_keeps_its_key() { var entityType = BuildEntityType("Systemic.Domain", "Entity"); @@ -16,11 +16,11 @@ public void Entity_in_assembly_named_like_system_keeps_its_key() var model = builder.FinalizeModel(); var keyNames = model.GetKeyNames(); - Assert.Equal(["Id"], keyNames[entityType]); + await Assert.That(keyNames[entityType]).IsEquivalentTo(["Id"], CollectionOrdering.Matching); } - [Fact] - public void Shadow_many_to_many_join_entity_is_skipped() + [Test] + public async Task Shadow_many_to_many_join_entity_is_skipped() { var builder = SqlServerConventionSetBuilder.CreateModelBuilder(); builder.Entity() @@ -30,9 +30,9 @@ public void Shadow_many_to_many_join_entity_is_skipped() var model = builder.FinalizeModel(); var keyNames = model.GetKeyNames(); - Assert.Equal(["Id"], keyNames[typeof(Left)]); - Assert.Equal(["Id"], keyNames[typeof(Right)]); - Assert.DoesNotContain(typeof(Dictionary), keyNames.Keys); + await Assert.That(keyNames[typeof(Left)]).IsEquivalentTo(["Id"], CollectionOrdering.Matching); + await Assert.That(keyNames[typeof(Right)]).IsEquivalentTo(["Id"], CollectionOrdering.Matching); + await Assert.That(keyNames.Keys).DoesNotContain(typeof(Dictionary)); } static Type BuildEntityType(string assemblyName, string typeName) diff --git a/src/Tests/Mapping/MappingTests.cs b/src/Tests/Mapping/MappingTests.cs index c5376e610..2250edcd5 100644 --- a/src/Tests/Mapping/MappingTests.cs +++ b/src/Tests/Mapping/MappingTests.cs @@ -20,7 +20,7 @@ static MappingTests() }); } - [Fact] + [Test] public async Task SchemaPrint() { var services = new ServiceCollection(); @@ -36,7 +36,7 @@ public async Task SchemaPrint() await Verify(print); } - [Fact] + [Test] public async Task Resolve() { await using var database = await sqlInstance.Build(); @@ -76,7 +76,7 @@ await Verify(resolve) """); } - [Fact] + [Test] public async Task PropertyToObject() { var expression = Mapper.PropertyToObject("Property"); @@ -99,7 +99,7 @@ await Verify( """); } - [Fact] + [Test] public async Task NavigationProperty() { var child = new MappingChild(); diff --git a/src/Tests/MultiContextTests/MultiContextTests.cs b/src/Tests/MultiContextTests/MultiContextTests.cs index 53bffc4b6..7e095e474 100644 --- a/src/Tests/MultiContextTests/MultiContextTests.cs +++ b/src/Tests/MultiContextTests/MultiContextTests.cs @@ -1,6 +1,6 @@ public class MultiContextTests { - [Fact] + [Test] public async Task Run() { var sqlInstance1 = new SqlInstance(constructInstance: builder => new(builder.ThrowOnAntiPatterns().Options)); diff --git a/src/Tests/ProjectionAnalyzerTests.cs b/src/Tests/ProjectionAnalyzerTests.cs index 4b383b54a..f4f17b0fa 100644 --- a/src/Tests/ProjectionAnalyzerTests.cs +++ b/src/Tests/ProjectionAnalyzerTests.cs @@ -36,70 +36,70 @@ class EntityWithNav : BaseEntity public Nav? Nav { get; set; } } - [Fact] - public void SimpleProperty() + [Test] + public async Task SimpleProperty() { Expression> projection = e => e.Name; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Name", paths); + await Assert.That(paths).Contains("Name"); } - [Fact] - public void CastToBaseType() + [Test] + public async Task CastToBaseType() { Expression> projection = e => e.Status; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Status", paths); + await Assert.That(paths).Contains("Status"); } - [Fact] - public void CastToInterface() + [Test] + public async Task CastToInterface() { Expression> projection = e => e.Name; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Name", paths); + await Assert.That(paths).Contains("Name"); } - [Fact] - public void CastInNewExpression() + [Test] + public async Task CastInNewExpression() { Expression> projection = e => new { e.Status, e.Name }; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Status", paths); - Assert.Contains("Name", paths); + await Assert.That(paths).Contains("Status"); + await Assert.That(paths).Contains("Name"); } - [Fact] - public void AsCast() + [Test] + public async Task AsCast() { Expression> projection = e => e.Name; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Name", paths); + await Assert.That(paths).Contains("Name"); } - [Fact] - public void NavigationThroughCast() + [Test] + public async Task NavigationThroughCast() { Expression> projection = e => e.Nav!.Value; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Nav.Value", paths); + await Assert.That(paths).Contains("Nav.Value"); } - [Fact] - public void MultipleCasts() + [Test] + public async Task MultipleCasts() { Expression> projection = _ => _.Status; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Status", paths); + await Assert.That(paths).Contains("Status"); } - [Fact] - public void NoCast() + [Test] + public async Task NoCast() { Expression> projection = e => new { e.Name, e.Status }; var paths = ProjectionAnalyzer.ExtractPropertyPaths(projection); - Assert.Contains("Name", paths); - Assert.Contains("Status", paths); + await Assert.That(paths).Contains("Name"); + await Assert.That(paths).Contains("Status"); } class Item @@ -115,21 +115,20 @@ class EntityWithItems : BaseEntity public List Items { get; set; } = null!; } - static void AssertPaths(Expression> projection, params string[] expected) => - Assert.Equal( - expected.Order(), - ProjectionAnalyzer.ExtractPropertyPaths(projection).Order()); + static async Task AssertPaths(Expression> projection, params string[] expected) => + await Assert.That(ProjectionAnalyzer.ExtractPropertyPaths(projection).Order()) + .IsEquivalentTo(expected.Order(), CollectionOrdering.Matching); // The properties are read off the lambda's own parameter, so were not recorded, and the // collection was loaded whole - [Fact] - public void CollectionSelect() => + [Test] + public Task CollectionSelect() => AssertPaths( _ => _.Items.Select(item => item.Id).ToList(), "Items", "Items.Id"); - [Fact] - public void CollectionChain() => + [Test] + public Task CollectionChain() => AssertPaths( _ => _.Items .Where(item => item.Active) @@ -138,8 +137,8 @@ public void CollectionChain() => .ToList(), "Items", "Items.Active", "Items.Name", "Items.Id"); - [Fact] - public void CollectionAggregate() => + [Test] + public Task CollectionAggregate() => AssertPaths( _ => new { @@ -149,40 +148,40 @@ public void CollectionAggregate() => "Items", "Items.Active", "Items.Name"); // The items come out, so whatever uses them can read any property - [Fact] - public void CollectionReturningItemsIsWhole() => + [Test] + public Task CollectionReturningItemsIsWhole() => AssertPaths( _ => _.Items.Where(item => item.Active).ToList(), "Items"); - [Fact] - public void CollectionReturningAnItemIsWhole() => + [Test] + public Task CollectionReturningAnItemIsWhole() => AssertPaths( _ => _.Items.FirstOrDefault(item => item.Active), "Items"); - [Fact] - public void CollectionSelectingTheItemIsWhole() => + [Test] + public Task CollectionSelectingTheItemIsWhole() => AssertPaths( _ => _.Items.Select(item => new { item, item.Name }).ToList(), "Items"); // A navigation of an item is not a column of it - [Fact] - public void CollectionReadingItemNavigationIsWhole() => + [Test] + public Task CollectionReadingItemNavigationIsWhole() => AssertPaths( _ => _.Items.Select(item => item.Nav!.Value).ToList(), "Items"); - [Fact] - public void CollectionPassingItemToMethodIsWhole() => + [Test] + public Task CollectionPassingItemToMethodIsWhole() => AssertPaths( _ => _.Items.Select(Describe).ToList(), "Items"); // Nothing says which properties a count needs, so this is unchanged - [Fact] - public void CollectionWithNoLambdaIsWhole() => + [Test] + public Task CollectionWithNoLambdaIsWhole() => AssertPaths( _ => _.Items.Count(), "Items"); diff --git a/src/Tests/PropertyCacheTests.cs b/src/Tests/PropertyCacheTests.cs index b9f0987ef..59ec39297 100644 --- a/src/Tests/PropertyCacheTests.cs +++ b/src/Tests/PropertyCacheTests.cs @@ -1,7 +1,7 @@ public class PropertyCacheTests { - [Fact] - public void Property() + [Test] + public async Task Property() { var target = new TargetForProperty { @@ -10,7 +10,7 @@ public void Property() var property = PropertyCache.GetProperty("Member"); var result = property.Func(target); - Assert.Equal("Value1", result); + await Assert.That(result).IsEqualTo("Value1"); } public class TargetForProperty @@ -18,8 +18,8 @@ public class TargetForProperty public string? Member; } - [Fact] - public void PropertyNested() + [Test] + public async Task PropertyNested() { var target = new TargetForPropertyNested { @@ -31,7 +31,7 @@ public void PropertyNested() var property = PropertyCache.GetProperty("Child.Member"); var result = property.Func(target); - Assert.Equal("Value1", result); + await Assert.That(result).IsEqualTo("Value1"); } public class TargetForPropertyNested @@ -44,8 +44,8 @@ public class TargetChildForPropertyNested public string? Member; } - [Fact] - public void PropertyOnInheritedInterface() + [Test] + public async Task PropertyOnInheritedInterface() { var target = new MultiInterfaceTarget { @@ -60,29 +60,29 @@ public void PropertyOnInheritedInterface() var a = PropertyCache.GetProperty("A").Func(target); var b = PropertyCache.GetProperty("B").Func(target); - Assert.Equal("valueA", a); - Assert.Equal("valueB", b); + await Assert.That(a).IsEqualTo("valueA"); + await Assert.That(b).IsEqualTo("valueB"); } - [Fact] - public void DeepPathIsRejected() + [Test] + public async Task DeepPathIsRejected() { // paths come from the client, and each segment becomes a join on the queryable paths var path = string.Join('.', Enumerable.Repeat("Self", 11)) + ".Public"; - var exception = Assert.Throws(() => PropertyCache.GetProperty(path)); - Assert.Contains("exceeds the maximum depth", exception.Message); + var exception = Assert.ThrowsExactly(() => PropertyCache.GetProperty(path)); + await Assert.That(exception.Message).Contains("exceeds the maximum depth"); } - [Fact] - public void PathAtMaximumDepthIsAllowed() + [Test] + public async Task PathAtMaximumDepthIsAllowed() { var path = string.Join('.', Enumerable.Repeat("Self", 9)) + ".Public"; var property = PropertyCache.GetProperty(path); - Assert.Equal(typeof(string), property.PropertyType); + await Assert.That(property.PropertyType).IsEqualTo(typeof(string)); } - [Fact] - public void CacheDoesNotGrowWithoutBound() + [Test] + public async Task CacheDoesNotGrowWithoutBound() { // a self referencing navigation can mint unlimited distinct valid paths for (var i = 1; i <= 3000; i++) @@ -95,13 +95,11 @@ public void CacheDoesNotGrowWithoutBound() PropertyCache.GetProperty(path.Replace("Self", i % 2 == 0 ? "self" : "SELF")); } - Assert.True( - PropertyCache.CachedCount <= 1000, - $"cache grew to {PropertyCache.CachedCount}"); + await Assert.That(PropertyCache.CachedCount).IsLessThanOrEqualTo(1000); } - [Fact] - public void FuncStillWorksAfterBeingCompiledLazily() + [Test] + public async Task FuncStillWorksAfterBeingCompiledLazily() { var target = new SelfReferencing { @@ -114,8 +112,8 @@ public void FuncStillWorksAfterBeingCompiledLazily() var property = PropertyCache.GetProperty("Self.Public"); // invoked twice to cover the memoised path as well as the first compile - Assert.Equal("Value1", property.Func(target)); - Assert.Equal("Value1", property.Func(target)); + await Assert.That(property.Func(target)).IsEqualTo("Value1"); + await Assert.That(property.Func(target)).IsEqualTo("Value1"); } public class SelfReferencing @@ -124,23 +122,23 @@ public class SelfReferencing public string? Public { get; set; } } - [Theory] + [Test] // paths come from the client, so non public members must not be resolvable - [InlineData("secretField")] - [InlineData("SecretProperty")] + [Arguments("secretField")] + [Arguments("SecretProperty")] // resolution is case insensitive, so casing must not be a way around it - [InlineData("SECRETFIELD")] - [InlineData("secretproperty")] + [Arguments("SECRETFIELD")] + [Arguments("secretproperty")] // nor may they be reached through a nested path - [InlineData("Child.secretField")] - public void NonPublicMembersAreNotResolved(string path) + [Arguments("Child.secretField")] + public async Task NonPublicMembersAreNotResolved(string path) { - var exception = Assert.Throws(() => PropertyCache.GetProperty(path)); - Assert.Contains("Failed to create a member expression", exception.Message); + var exception = Assert.ThrowsExactly(() => PropertyCache.GetProperty(path)); + await Assert.That(exception.Message).Contains("Failed to create a member expression"); } - [Fact] - public void PublicMembersStillResolveOnTypeWithNonPublicMembers() + [Test] + public async Task PublicMembersStillResolveOnTypeWithNonPublicMembers() { var target = new TargetWithNonPublicMembers { @@ -148,7 +146,7 @@ public void PublicMembersStillResolveOnTypeWithNonPublicMembers() }; var property = PropertyCache.GetProperty("Public"); - Assert.Equal("Value1", property.Func(target)); + await Assert.That(property.Func(target)).IsEqualTo("Value1"); } public class TargetWithNonPublicMembers diff --git a/src/Tests/SelectExpressionBuilderTests.cs b/src/Tests/SelectExpressionBuilderTests.cs index 60e1c8186..9336baffd 100644 --- a/src/Tests/SelectExpressionBuilderTests.cs +++ b/src/Tests/SelectExpressionBuilderTests.cs @@ -22,12 +22,16 @@ static Expression> Build(params string[] scalarFields) ["Id"], null, null); - Assert.True(SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression)); + if (!SelectExpressionBuilder.TryBuild(projection, keyNames, out var expression)) + { + throw new InvalidOperationException("Failed to build the select expression"); + } + return expression; } - [Fact] - public void FieldOrderDoesNotChangeTheExpression() + [Test] + public async Task FieldOrderDoesNotChangeTheExpression() { // The same fields requested in a different order must produce the same tree, otherwise EF // caches a separate compiled query for identical work. @@ -35,13 +39,11 @@ public void FieldOrderDoesNotChangeTheExpression() var reversed = Build("Gamma", "Beta", "Alpha"); var shuffled = Build("Beta", "Gamma", "Alpha"); - Assert.Equal(forward.ToString(), reversed.ToString()); - Assert.Equal(forward.ToString(), shuffled.ToString()); + await Assert.That(reversed.ToString()).IsEqualTo(forward.ToString()); + await Assert.That(shuffled.ToString()).IsEqualTo(forward.ToString()); } - [Fact] - public void DifferentFieldSetsStillDiffer() => - Assert.NotEqual( - Build("Alpha", "Beta").ToString(), - Build("Alpha", "Gamma").ToString()); + [Test] + public async Task DifferentFieldSetsStillDiffer() => + await Assert.That(Build("Alpha", "Gamma").ToString()).IsNotEqualTo(Build("Alpha", "Beta").ToString()); } diff --git a/src/Tests/SelfReferencingWhereTests.cs b/src/Tests/SelfReferencingWhereTests.cs index 31091ff40..6f9f37b2f 100644 --- a/src/Tests/SelfReferencingWhereTests.cs +++ b/src/Tests/SelfReferencingWhereTests.cs @@ -31,7 +31,7 @@ public class SelfReferencingWhereTests }, constructInstance: builder => new(builder.ThrowOnAntiPatterns().Options)); - [Fact] + [Test] public async Task List_path_into_same_type() { await using var database = await sqlInstance.Build(); @@ -40,10 +40,10 @@ public async Task List_path_into_same_type() .Where(predicate) .Select(_ => _.Name) .ToListAsync(); - Assert.Equal(["root"], names); + await Assert.That(names).IsEquivalentTo((string?[]) ["root"], CollectionOrdering.Matching); } - [Fact] + [Test] public async Task List_path_into_same_type_negated() { await using var database = await sqlInstance.Build(); @@ -53,7 +53,7 @@ public async Task List_path_into_same_type_negated() .OrderBy(_ => _.Name) .Select(_ => _.Name) .ToListAsync(); - Assert.Equal(["a", "b", "c", "other"], names); + await Assert.That(names).IsEquivalentTo((string?[]) ["a", "b", "c", "other"], CollectionOrdering.Matching); } public class Node diff --git a/src/Tests/SideBySideCollectionsTests.cs b/src/Tests/SideBySideCollectionsTests.cs index 2da14c1b8..e6b22de6f 100644 --- a/src/Tests/SideBySideCollectionsTests.cs +++ b/src/Tests/SideBySideCollectionsTests.cs @@ -11,55 +11,55 @@ static FieldProjectionInfo Projection(params (string Name, bool IsCollection, Fi static FieldProjectionInfo Empty => Projection(); - [Fact] - public void None() => - Assert.Equal(0, SideBySideCollections.Count(Projection(("Parent", false, Empty)))); + [Test] + public async Task None() => + await Assert.That(SideBySideCollections.Count(Projection(("Parent", false, Empty)))).IsEqualTo(0); - [Fact] - public void One() => - Assert.Equal(1, SideBySideCollections.Count(Projection(("Children", true, Empty)))); + [Test] + public async Task One() => + await Assert.That(SideBySideCollections.Count(Projection(("Children", true, Empty)))).IsEqualTo(1); // A row per grandchild, so the chain is one - [Fact] - public void NestedChainCountsOnce() => - Assert.Equal( - 1, - SideBySideCollections.Count( - Projection(("Children", true, Projection(("Grandchildren", true, Empty)))))); + [Test] + public async Task NestedChainCountsOnce() => + await Assert.That( + SideBySideCollections.Count( + Projection(("Children", true, Projection(("Grandchildren", true, Empty)))))) + .IsEqualTo(1); - [Fact] - public void SideBySide() => - Assert.Equal( - 2, - SideBySideCollections.Count( - Projection( - ("Children", true, Empty), - ("Owner", false, Projection(("Roles", true, Projection(("Departments", true, Empty)))))))); + [Test] + public async Task SideBySide() => + await Assert.That( + SideBySideCollections.Count( + Projection( + ("Children", true, Empty), + ("Owner", false, Projection(("Roles", true, Projection(("Departments", true, Empty)))))))) + .IsEqualTo(2); // Each child holds its grandchildren and its pets side by side - [Fact] - public void SideBySideInANestedCollection() => - Assert.Equal( - 2, - SideBySideCollections.Count( - Projection( - ("Children", true, Projection( - ("Grandchildren", true, Empty), - ("Pets", true, Empty)))))); + [Test] + public async Task SideBySideInANestedCollection() => + await Assert.That( + SideBySideCollections.Count( + Projection( + ("Children", true, Projection( + ("Grandchildren", true, Empty), + ("Pets", true, Empty)))))) + .IsEqualTo(2); - [Fact] - public void DerivedNavigations() => - Assert.Equal( - 2, - SideBySideCollections.Count( - Projection(("Children", true, Empty)) with - { - DerivedNavigations = new() + [Test] + public async Task DerivedNavigations() => + await Assert.That( + SideBySideCollections.Count( + Projection(("Children", true, Empty)) with { - [typeof(string)] = new() + DerivedNavigations = new() { - ["Items"] = new(typeof(object), true, Empty) + [typeof(string)] = new() + { + ["Items"] = new(typeof(object), true, Empty) + } } - } - })); + })) + .IsEqualTo(2); } diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index d3f17c037..d176c83ea 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,7 +1,7 @@ net11.0 - $(NoWarn);EF1000;xUnit1051 + $(NoWarn);EF1000 Exe testing GraphQL.EntityFramework.Tests @@ -15,15 +15,13 @@ - - + + - - diff --git a/src/Tests/TypeConverterTests.cs b/src/Tests/TypeConverterTests.cs index 04f68b5fe..aa72e9b61 100644 --- a/src/Tests/TypeConverterTests.cs +++ b/src/Tests/TypeConverterTests.cs @@ -2,65 +2,65 @@ public class TypeConverterTests { - [Theory] - [InlineData(typeof(int), "12", 12)] - [InlineData(typeof(int?), null, null)] - public void ConvertStringToType(Type type, string? value, object? expected) + [Test] + [Arguments(typeof(int), "12", 12)] + [Arguments(typeof(int?), null, null)] + public async Task ConvertStringToType(Type type, string? value, object? expected) { var result = TypeConverter.ConvertStringToType(value, type); - Assert.Equal(expected, result); + await Assert.That(result).IsEqualTo(expected); } - [Fact] - public void ConvertStringToGuid() + [Test] + public async Task ConvertStringToGuid() { var guid = Guid.NewGuid(); var value = guid.ToString(); var result = TypeConverter.ConvertStringToType(value, typeof(Guid)); - Assert.Equal(guid, result); + await Assert.That(result).IsEqualTo(guid); } - [Fact] - public void ConvertStringToDatetime() + [Test] + public async Task ConvertStringToDatetime() { var dateTime = DateTime.UtcNow.Date; var value = dateTime.ToString("o"); var result = TypeConverter.ConvertStringToType(value, typeof(DateTime)); - Assert.Equal(dateTime, result); + await Assert.That(result).IsEqualTo(dateTime); } - [Fact] - public void ConvertStringToDate() + [Test] + public async Task ConvertStringToDate() { var date = new Date(2020,10,1); var result = TypeConverter.ConvertStringToType(date.ToString("yyyy-MM-dd"), typeof(Date)); - Assert.Equal(date, result); + await Assert.That(result).IsEqualTo(date); } - [Fact] - public void ConvertStringToTime() + [Test] + public async Task ConvertStringToTime() { var time = new Time(10,1); var result = TypeConverter.ConvertStringToType("10:01", typeof(Time)); - Assert.Equal(time, result); + await Assert.That(result).IsEqualTo(time); } - [Fact] - public void ConvertStringToEnum() + [Test] + public async Task ConvertStringToEnum() { var day = DayOfWeek.Thursday; var value = day.ToString(); var result = TypeConverter.ConvertStringToType(value, typeof(DayOfWeek)); - Assert.Equal(day, result); + await Assert.That(result).IsEqualTo(day); } - [Fact] - public void ConvertUppercaseStringToEnum() + [Test] + public async Task ConvertUppercaseStringToEnum() { var day = DayOfWeek.Thursday; var value = day.ToString().ToUpperInvariant(); var result = TypeConverter.ConvertStringToType(value, typeof(DayOfWeek)); - Assert.Equal(day, result); + await Assert.That(result).IsEqualTo(day); } // Where values are query text, so they parse the same under every server culture, and a @@ -92,22 +92,22 @@ public void ConvertUppercaseStringToEnum() } } - [Theory] - [MemberData(nameof(CultureCases))] - public void Parses_invariant_of_culture(string culture, Type type, string value, object expected) + [Test] + [MethodDataSource(nameof(CultureCases))] + public async Task Parses_invariant_of_culture(string culture, Type type, string value, object expected) { var original = CultureInfo.CurrentCulture; CultureInfo.CurrentCulture = new(culture); try { var single = TypeConverter.ConvertStringToType(value, type); - Assert.Equal(expected, single); + await Assert.That(single).IsEqualTo(expected); var member = typeof(NullableHolder).GetProperty(type.Name)!; var list = TypeConverter.ConvertToList([value, null], member); - Assert.Equal(2, list.Count); - Assert.Equal(expected, list[0]); - Assert.Null(list[1]); + await Assert.That(list.Count).IsEqualTo(2); + await Assert.That(list[0]).IsEqualTo(expected); + await Assert.That(list[1]).IsNull(); } finally { @@ -115,20 +115,20 @@ public void Parses_invariant_of_culture(string culture, Type type, string value, } } - [Fact] - public void List_of_non_nullable_member_type() + [Test] + public async Task List_of_non_nullable_member_type() { var list = TypeConverter.ConvertToList(["1", "2"], typeof(Holder).GetProperty(nameof(Holder.Value))!); - Assert.IsType>(list); - Assert.Equal([1, 2], list.Cast()); + await Assert.That(list).IsTypeOf>(); + await Assert.That(list.Cast()).IsEquivalentTo([1, 2], CollectionOrdering.Matching); } - [Fact] - public void List_of_nullable_member_type() + [Test] + public async Task List_of_nullable_member_type() { var list = TypeConverter.ConvertToList(["1", null], typeof(Holder).GetProperty(nameof(Holder.Nullable))!); - Assert.IsType>(list); - Assert.Equal([1, null], list.Cast()); + await Assert.That(list).IsTypeOf>(); + await Assert.That(list.Cast()).IsEquivalentTo((int?[]) [1, null], CollectionOrdering.Matching); } class Holder diff --git a/src/coverage.config b/src/coverage.config new file mode 100644 index 000000000..b61aa2830 --- /dev/null +++ b/src/coverage.config @@ -0,0 +1,24 @@ + + + cobertura + false + + + + .*\.Tests\.dll$ + .*\.Test\.dll$ + .*Benchmarks\.dll$ + .*SampleWeb\.dll$ + .*SampleWeb\.Client\.dll$ + .*Snippets\.dll$ + + + + + ^System\.ObsoleteAttribute$ + ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ + ^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$ + + + + diff --git a/src/coverage.runsettings b/src/coverage.runsettings deleted file mode 100644 index 88e476227..000000000 --- a/src/coverage.runsettings +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - cobertura,opencover - [*.Tests]*,[*.Test]*,[Benchmarks]*,[SampleWeb]*,[Snippets]* - Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute - false - true - - - - - diff --git a/src/run-coverage.ps1 b/src/run-coverage.ps1 index f2daa8c17..993b6c913 100644 --- a/src/run-coverage.ps1 +++ b/src/run-coverage.ps1 @@ -1,7 +1,13 @@ # PowerShell script to run tests with coverage and generate HTML report +$resultsDirectory = "../TestResults/coverage" +if (Test-Path $resultsDirectory) { + Remove-Item $resultsDirectory -Recurse -Force +} + +# TUnit runs on Microsoft.Testing.Platform, so coverage comes from Microsoft.Testing.Extensions.CodeCoverage Write-Host "Running tests with code coverage..." -ForegroundColor Cyan -dotnet test --collect:"XPlat Code Coverage" --settings coverage.runsettings +dotnet test --solution GraphQL.EntityFramework.slnx --configuration Release --coverage --coverage-settings coverage.config --results-directory $resultsDirectory if ($LASTEXITCODE -ne 0) { Write-Host "Tests failed!" -ForegroundColor Red @@ -9,7 +15,7 @@ if ($LASTEXITCODE -ne 0) { } Write-Host "`nGenerating HTML coverage report..." -ForegroundColor Cyan -reportgenerator -reports:"**/TestResults/**/coverage.cobertura.xml" -targetdir:"../coverage-report" -reporttypes:"Html;HtmlSummary" +reportgenerator -reports:"$resultsDirectory/*.cobertura.xml" -targetdir:"../coverage-report" -reporttypes:"Html;HtmlSummary" if ($LASTEXITCODE -eq 0) { Write-Host "`nCoverage report generated successfully!" -ForegroundColor Green