diff --git a/Directory.Build.props b/Directory.Build.props index 8ca72be70..63a0cdd59 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 10.0.0-preview.3 + 10.0.0-preview.4 net10.0 latest enable diff --git a/Directory.Packages.props b/Directory.Packages.props index f464b1457..180cb45b6 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,7 +1,7 @@ - 10.0.0-preview.3.25171.6 - 10.0.0-preview.3.25171.5 + 10.0.0-preview.4.25258.110 + 10.0.0-preview.4.25258.110 9.0.3 diff --git a/global.json b/global.json index d9e3bbb10..ceefd0550 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.100-preview.2.25081.1", + "version": "10.0.100-preview.4.25258.110", "rollForward": "latestMajor", "allowPrerelease": true } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs index af5a00965..b5f903902 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; -public class NonSharedModelBulkUpdatesNpgsqlTest : NonSharedModelBulkUpdatesRelationalTestBase +public class NonSharedModelBulkUpdatesNpgsqlTest(NonSharedFixture fixture) : NonSharedModelBulkUpdatesRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj b/test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj index 8050bc586..5aa457819 100644 --- a/test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj +++ b/test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj @@ -24,6 +24,11 @@ + + + + + diff --git a/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs index deb98d00e..def3b2028 100644 --- a/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs @@ -1,6 +1,7 @@ namespace Microsoft.EntityFrameworkCore; -public class EntitySplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : EntitySplittingTestBase(testOutputHelper) +public class EntitySplittingNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : EntitySplittingTestBase(fixture, testOutputHelper) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs index fb77cb47e..9c68c0d66 100644 --- a/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/JsonTypesNpgsqlTest.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore; -public class JsonTypesNpgsqlTest : JsonTypesRelationalTestBase +public class JsonTypesNpgsqlTest(NonSharedFixture fixture) : JsonTypesRelationalTestBase(fixture) { #region Nested collections (unsupported) diff --git a/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs index 10b2911ac..48e9f5bd7 100644 --- a/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs @@ -1,7 +1,7 @@ namespace Microsoft.EntityFrameworkCore; -public class MaterializationInterceptionNpgsqlTest : - MaterializationInterceptionTestBase +public class MaterializationInterceptionNpgsqlTest(NonSharedFixture fixture) : + MaterializationInterceptionTestBase(fixture) { public class NpgsqlLibraryContext(DbContextOptions options) : LibraryContext(options) { diff --git a/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderGenericTest.cs b/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderGenericTest.cs index c5050eb38..2350593ab 100644 --- a/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderGenericTest.cs +++ b/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderGenericTest.cs @@ -22,6 +22,13 @@ protected override TestModelBuilder CreateModelBuilder( => new GenericTestModelBuilder(Fixture, configure); } + public class NpgsqlGenericComplexCollection(NpgsqlModelBuilderFixture fixture) : NpgsqlComplexCollection(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action? configure) + => new GenericTestModelBuilder(Fixture, configure); + } + public class NpgsqlGenericInheritance(NpgsqlModelBuilderFixture fixture) : NpgsqlInheritance(fixture) { protected override TestModelBuilder CreateModelBuilder( diff --git a/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderTestBase.cs b/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderTestBase.cs index 265cd2858..d9d6de800 100644 --- a/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderTestBase.cs +++ b/test/EFCore.PG.FunctionalTests/ModelBuilding/NpgsqlModelBuilderTestBase.cs @@ -8,6 +8,9 @@ public abstract class NpgsqlNonRelationship(NpgsqlModelBuilderFixture fixture) public abstract class NpgsqlComplexType(NpgsqlModelBuilderFixture fixture) : RelationalComplexTypeTestBase(fixture), IClassFixture; + public abstract class NpgsqlComplexCollection(NpgsqlModelBuilderFixture fixture) + : RelationalComplexCollectionTestBase(fixture), IClassFixture; + public abstract class NpgsqlInheritance(NpgsqlModelBuilderFixture fixture) : RelationalInheritanceTestBase(fixture), IClassFixture; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocAdvancedMappingsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocAdvancedMappingsQueryNpgsqlTest.cs index 068361685..6d9c52e36 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocAdvancedMappingsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocAdvancedMappingsQueryNpgsqlTest.cs @@ -1,6 +1,7 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocAdvancedMappingsQueryNpgsqlTest : AdHocAdvancedMappingsQueryRelationalTestBase +public class AdHocAdvancedMappingsQueryNpgsqlTest(NonSharedFixture fixture) + : AdHocAdvancedMappingsQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocComplexTypeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocComplexTypeQueryNpgsqlTest.cs index 06eacc738..b83a30a83 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocComplexTypeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocComplexTypeQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocComplexTypeQueryNpgsqlTest : AdHocComplexTypeQueryTestBase +public class AdHocComplexTypeQueryNpgsqlTest(NonSharedFixture fixture) : AdHocComplexTypeQueryTestBase(fixture) { public override async Task Complex_type_equals_parameter_with_nested_types_with_property_of_same_name() { diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs index 47004e2f8..e613d913c 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocJsonQueryNpgsqlTest.cs @@ -1,18 +1,20 @@ +using Xunit.Sdk; + namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class AdHocJsonQueryNpgsqlTest : AdHocJsonQueryRelationalTestBase +public class AdHocJsonQueryNpgsqlTest(NonSharedFixture fixture) : AdHocJsonQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; protected override async Task Seed29219(DbContext ctx) { - var entity1 = new MyEntity29219 + var entity1 = new Context29219.MyEntity { Id = 1, - Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, + Reference = new Context29219.MyJsonEntity { NonNullableScalar = 10, NullableScalar = 11 }, Collection = [ new() { NonNullableScalar = 100, NullableScalar = 101 }, @@ -21,10 +23,10 @@ protected override async Task Seed29219(DbContext ctx) ] }; - var entity2 = new MyEntity29219 + var entity2 = new Context29219.MyEntity { Id = 2, - Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, + Reference = new Context29219.MyJsonEntity { NonNullableScalar = 20, NullableScalar = null }, Collection = [new() { NonNullableScalar = 1001, NullableScalar = null }] }; @@ -84,52 +86,6 @@ protected override async Task Seed33046(DbContext ctx) VALUES('[{"RoundNumber":11,"SubRounds":[{"SubRoundNumber":111},{"SubRoundNumber":112}]}]', 1) """); - protected override async Task SeedArrayOfPrimitives(DbContext ctx) - { - var entity1 = new MyEntityArrayOfPrimitives - { - Id = 1, - Reference = new MyJsonEntityArrayOfPrimitives - { - IntArray = [1, 2, 3], - ListOfString = - [ - "Foo", - "Bar", - "Baz" - ] - }, - Collection = - [ - new() { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, - new() { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } - ] - }; - - var entity2 = new MyEntityArrayOfPrimitives - { - Id = 2, - Reference = new MyJsonEntityArrayOfPrimitives - { - IntArray = [10, 20, 30], - ListOfString = - [ - "A", - "B", - "C" - ] - }, - Collection = - [ - new() { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, - new() { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } - ] - }; - - ctx.AddRange(entity1, entity2); - await ctx.SaveChangesAsync(); - } - protected override async Task SeedJunkInJson(DbContext ctx) => await ctx.Database.ExecuteSqlAsync( $$$""" @@ -186,11 +142,17 @@ await ctx.Database.ExecuteSqlAsync( // PostgreSQL stores JSON as jsonb, which doesn't allow badly-formed JSON; so the following tests are irrelevant. - public override Task Bad_json_properties_duplicated_navigations_tracking() - => Assert.ThrowsAsync(() => base.Bad_json_properties_duplicated_navigations_tracking()); - - public override Task Bad_json_properties_duplicated_navigations_no_tracking() - => Assert.ThrowsAsync(() => base.Bad_json_properties_duplicated_navigations_no_tracking()); + public override async Task Bad_json_properties_duplicated_navigations(bool noTracking) + { + if (noTracking) + { + await Assert.ThrowsAsync(() => base.Bad_json_properties_duplicated_navigations(noTracking: true)); + } + else + { + await base.Bad_json_properties_duplicated_navigations(noTracking: false); + } + } public override Task Bad_json_properties_duplicated_scalars(bool noTracking) => Assert.ThrowsAsync(() => base.Bad_json_properties_duplicated_scalars(noTracking)); @@ -202,10 +164,10 @@ public override Task Bad_json_properties_empty_scalars(bool noTracking) => Assert.ThrowsAsync(() => base.Bad_json_properties_empty_scalars(noTracking)); public override Task Bad_json_properties_null_navigations(bool noTracking) - => Assert.ThrowsAsync(() => base.Bad_json_properties_null_navigations(noTracking)); + => Assert.ThrowsAsync(() => base.Bad_json_properties_null_navigations(noTracking)); public override Task Bad_json_properties_null_scalars(bool noTracking) - => Assert.ThrowsAsync(() => base.Bad_json_properties_null_scalars(noTracking)); + => Assert.ThrowsAsync(() => base.Bad_json_properties_null_scalars(noTracking)); protected override Task SeedBadJsonProperties(ContextBadJsonProperties ctx) => throw new NotSupportedException("PostgreSQL stores JSON as jsonb, which doesn't allow badly-formed JSON"); @@ -304,10 +266,10 @@ public override Task Project_entity_with_json_null_values() => Assert.ThrowsAsync(() => base.Project_entity_with_json_null_values()); public override Task Try_project_collection_but_JSON_is_entity() - => Assert.ThrowsAsync(() => base.Try_project_collection_but_JSON_is_entity()); + => Assert.ThrowsAsync(() => base.Try_project_collection_but_JSON_is_entity()); public override Task Try_project_reference_but_JSON_is_collection() - => Assert.ThrowsAsync(() => base.Try_project_reference_but_JSON_is_collection()); + => Assert.ThrowsAsync(() => base.Try_project_reference_but_JSON_is_collection()); public override Task Project_entity_with_optional_json_entity_owned_by_required_json() => Assert.ThrowsAsync(() => base.Project_entity_with_optional_json_entity_owned_by_required_json()); diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocManyToManyQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocManyToManyQueryNpgsqlTest.cs index 86dab276d..c06db71b4 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocManyToManyQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocManyToManyQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocManyToManyQueryNpgsqlTest : AdHocManyToManyQueryRelationalTestBase +public class AdHocManyToManyQueryNpgsqlTest(NonSharedFixture fixture) : AdHocManyToManyQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocMiscellaneousQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocMiscellaneousQueryNpgsqlTest.cs index 6725b8fa8..d7e4c45a2 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocMiscellaneousQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocMiscellaneousQueryNpgsqlTest.cs @@ -2,7 +2,7 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocMiscellaneousQueryNpgsqlTest : AdHocMiscellaneousQueryRelationalTestBase +public class AdHocMiscellaneousQueryNpgsqlTest(NonSharedFixture fixture) : AdHocMiscellaneousQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocNavigationsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocNavigationsQueryNpgsqlTest.cs index 5e17a52f3..023bd30ec 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocNavigationsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocNavigationsQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocNavigationsQueryNpgsqlTest : AdHocNavigationsQueryRelationalTestBase +public class AdHocNavigationsQueryNpgsqlTest(NonSharedFixture fixture) : AdHocNavigationsQueryRelationalTestBase(fixture) { // Cannot write DateTime with Kind=Local to PostgreSQL type 'timestamp with time zone', only UTC is supported. public override Task Reference_include_on_derived_type_with_sibling_works() diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocPrecompiledQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocPrecompiledQueryNpgsqlTest.cs index 4fed4cbec..f593297f4 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocPrecompiledQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocPrecompiledQueryNpgsqlTest.cs @@ -2,8 +2,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocPrecompiledQueryNpgsqlTest(ITestOutputHelper testOutputHelper) - : AdHocPrecompiledQueryRelationalTestBase(testOutputHelper) +public class AdHocPrecompiledQueryNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : AdHocPrecompiledQueryRelationalTestBase(fixture, testOutputHelper) { protected override bool AlwaysPrintGeneratedSources => false; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocQueryFiltersQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocQueryFiltersQueryNpgsqlTest.cs index 02238b137..ac65f0f1f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocQueryFiltersQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocQueryFiltersQueryNpgsqlTest.cs @@ -1,6 +1,7 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class AdHocQueryFiltersQueryNpgsqlTest : AdHocQueryFiltersQueryRelationalTestBase +public class AdHocQueryFiltersQueryNpgsqlTest(NonSharedFixture fixture) + : AdHocQueryFiltersQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/AdHocQuerySplittingQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/AdHocQuerySplittingQueryNpgsqlTest.cs index 8de31fe1e..49d04a010 100644 --- a/test/EFCore.PG.FunctionalTests/Query/AdHocQuerySplittingQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/AdHocQuerySplittingQueryNpgsqlTest.cs @@ -5,8 +5,14 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class AdHocQuerySplittingQueryNpgsqlTest : AdHocQuerySplittingQueryTestBase +public class AdHocQuerySplittingQueryNpgsqlTest(NonSharedFixture fixture) : AdHocQuerySplittingQueryTestBase(fixture) { + protected override ITestStoreFactory TestStoreFactory + => NpgsqlTestStoreFactory.Instance; + + private static readonly FieldInfo _querySplittingBehaviorFieldInfo = + typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance); + protected override DbContextOptionsBuilder SetQuerySplittingBehavior( DbContextOptionsBuilder optionsBuilder, QuerySplittingBehavior splittingBehavior) @@ -33,9 +39,10 @@ protected override DbContextOptionsBuilder ClearQuerySplittingBehavior(DbContext return optionsBuilder; } - private static readonly FieldInfo _querySplittingBehaviorFieldInfo = - typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance); - - protected override ITestStoreFactory TestStoreFactory - => NpgsqlTestStoreFactory.Instance; + protected override TestStore CreateTestStore25225() + { + var testStore = NpgsqlTestStore.Create(StoreName); + testStore.UseConnectionString = true; + return testStore; + } } diff --git a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs index bb1ebda32..381b0370e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs @@ -1,11 +1,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class EntitySplittingQueryNpgsqlTest : EntitySplittingQueryTestBase +public class EntitySplittingQueryNpgsqlTest(NonSharedFixture fixture) + : EntitySplittingQueryTestBase(fixture) { - public EntitySplittingQueryNpgsqlTest(ITestOutputHelper testOutputHelper) - { - } - [ConditionalFact] public virtual void Check_all_tests_overridden() => TestHelpers.AssertAllMethodsOverridden(GetType()); diff --git a/test/EFCore.PG.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryNpgsqlTest.cs index 1ab90888b..d63e0da48 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryNpgsqlTest.cs @@ -2,7 +2,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NonSharedPrimitiveCollectionsQueryNpgsqlTest : NonSharedPrimitiveCollectionsQueryRelationalTestBase +public class NonSharedPrimitiveCollectionsQueryNpgsqlTest(NonSharedFixture fixture) + : NonSharedPrimitiveCollectionsQueryRelationalTestBase(fixture) { #region Support for specific element types diff --git a/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs index 67797915c..7d453214f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs @@ -2,7 +2,7 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class OperatorsQueryNpgsqlTest : OperatorsQueryTestBase +public class OperatorsQueryNpgsqlTest(NonSharedFixture fixture) : OperatorsQueryTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/OwnedEntityQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/OwnedEntityQueryNpgsqlTest.cs index d99acaa34..3f540a3b3 100644 --- a/test/EFCore.PG.FunctionalTests/Query/OwnedEntityQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/OwnedEntityQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class OwnedEntityQueryNpgsqlTest : OwnedEntityQueryRelationalTestBase +public class OwnedEntityQueryNpgsqlTest(NonSharedFixture fixture) : OwnedEntityQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs index bc5b94d72..5daa92b91 100644 --- a/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs @@ -2083,6 +2083,21 @@ WHERE CASE """); } + public override async Task Values_of_enum_casted_to_underlying_value(bool async) + { + await base.Values_of_enum_casted_to_underlying_value(async); + + AssertSql( + """ +SELECT p."Id", p."Bool", p."Bools", p."DateTime", p."DateTimes", p."Enum", p."Enums", p."Int", p."Ints", p."NullableInt", p."NullableInts", p."NullableString", p."NullableStrings", p."NullableWrappedId", p."NullableWrappedIdWithNullableComparer", p."String", p."Strings", p."WrappedId" +FROM "PrimitiveCollectionsEntity" AS p +WHERE ( + SELECT count(*)::int + FROM (VALUES (0::int), (1), (2), (3)) AS v("Value") + WHERE v."Value" = p."Int") > 0 +"""); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Array_remove(bool async) diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/ComplexRelationshipsNpgsqlFixture.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/ComplexRelationshipsNpgsqlFixture.cs index 7d5c735cf..27151bf56 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/ComplexRelationshipsNpgsqlFixture.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/ComplexRelationshipsNpgsqlFixture.cs @@ -3,7 +3,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Relationships; -public class ComplexRelationshipsNpgsqlFixture : ComplexRelationsjipsRelationalFixtureBase, ITestSqlLoggerFactory +public class ComplexRelationshipsNpgsqlFixture : ComplexRelationshipsRelationalFixtureBase, ITestSqlLoggerFactory { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Include/NavigationIncludeNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Include/NavigationIncludeNpgsqlTest.cs index d06efe57b..da60da5e1 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Include/NavigationIncludeNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Include/NavigationIncludeNpgsqlTest.cs @@ -29,8 +29,7 @@ public override async Task Include_trunk_required(bool async) public override async Task Include_trunk_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Include_trunk_optional(async)); + await base.Include_trunk_optional(async); AssertSql( """ @@ -70,8 +69,7 @@ public override async Task Include_trunk_required_optional_and_collection(bool a public override async Task Include_branch_required_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Include_branch_required_required(async)); + await base.Include_branch_required_required(async); AssertSql( """ @@ -98,8 +96,7 @@ public override async Task Include_branch_required_collection(bool async) public override async Task Include_branch_optional_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Include_branch_optional_optional(async)); + await base.Include_branch_optional_optional(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationNoTrackingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationNoTrackingProjectionNpgsqlTest.cs index 1c238615f..be4d5f9d5 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationNoTrackingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationNoTrackingProjectionNpgsqlTest.cs @@ -72,8 +72,7 @@ public override async Task Select_branch_optional_collection(bool async) public override async Task Select_multiple_branch_leaf(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_multiple_branch_leaf(async)); + await base.Select_multiple_branch_leaf(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationProjectionNpgsqlTest.cs index a3217c1d5..8be146381 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/NavigationProjectionNpgsqlTest.cs @@ -72,8 +72,7 @@ public override async Task Select_branch_optional_collection(bool async) public override async Task Select_multiple_branch_leaf(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_multiple_branch_leaf(async)); + await base.Select_multiple_branch_leaf(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedNoTrackingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedNoTrackingProjectionNpgsqlTest.cs index f40535886..013a0ff88 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedNoTrackingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedNoTrackingProjectionNpgsqlTest.cs @@ -25,8 +25,7 @@ public override async Task Select_trunk_collection(bool async) public override async Task Select_branch_required_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_required_collection(async)); + await base.Select_branch_required_collection(async); AssertSql( """ @@ -43,8 +42,7 @@ LEFT JOIN ( public override async Task Select_branch_optional_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_optional_collection(async)); + await base.Select_branch_optional_collection(async); AssertSql( """ @@ -61,8 +59,7 @@ LEFT JOIN ( public override async Task Select_multiple_branch_leaf(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_multiple_branch_leaf(async)); + await base.Select_multiple_branch_leaf(async); AssertSql( """ @@ -108,8 +105,7 @@ public override Task Select_subquery_root_set_complex_projection_including_refer public override async Task Select_subquery_root_set_complex_projection_FirstOrDefault_project_reference_to_outer(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_subquery_root_set_complex_projection_FirstOrDefault_project_reference_to_outer(async)); + await base.Select_subquery_root_set_complex_projection_FirstOrDefault_project_reference_to_outer(async); AssertSql( """ @@ -156,8 +152,7 @@ WHEN r0."OptionalReferenceBranch_Name" IS NOT NULL THEN r0."Id1" public override async Task SelectMany_required_trunk_reference_branch_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.SelectMany_required_trunk_reference_branch_collection(async)); + await base.SelectMany_required_trunk_reference_branch_collection(async); AssertSql( """ @@ -171,8 +166,7 @@ public override async Task SelectMany_required_trunk_reference_branch_collection public override async Task SelectMany_optional_trunk_reference_branch_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.SelectMany_optional_trunk_reference_branch_collection(async)); + await base.SelectMany_optional_trunk_reference_branch_collection(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedReferenceNoTrackingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedReferenceNoTrackingProjectionNpgsqlTest.cs index e0d458d70..386421c81 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedReferenceNoTrackingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedReferenceNoTrackingProjectionNpgsqlTest.cs @@ -25,8 +25,7 @@ public override async Task Select_root(bool async) public override async Task Select_trunk_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_trunk_optional(async)); + await base.Select_trunk_optional(async); AssertSql( """ @@ -51,8 +50,7 @@ WHEN r."OptionalReferenceTrunk_RequiredReferenceBranch_Name" IS NOT NULL THEN r. public override async Task Select_trunk_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_trunk_required(async)); + await base.Select_trunk_required(async); AssertSql( """ @@ -73,8 +71,7 @@ WHEN r."RequiredReferenceTrunk_OptionalReferenceBranch_Name" IS NOT NULL THEN r. public override async Task Select_branch_required_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_required_required(async)); + await base.Select_branch_required_required(async); AssertSql( """ @@ -87,8 +84,7 @@ public override async Task Select_branch_required_required(bool async) public override async Task Select_branch_required_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_required_optional(async)); + await base.Select_branch_required_optional(async); AssertSql( """ @@ -103,8 +99,7 @@ WHEN r."RequiredReferenceTrunk_OptionalReferenceBranch_Name" IS NOT NULL THEN r. public override async Task Select_branch_optional_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_optional_required(async)); + await base.Select_branch_optional_required(async); AssertSql( """ @@ -117,8 +112,7 @@ public override async Task Select_branch_optional_required(bool async) public override async Task Select_branch_optional_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_optional_optional(async)); + await base.Select_branch_optional_optional(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingNoTrackingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingNoTrackingProjectionNpgsqlTest.cs index a62de6b3a..6d894a435 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingNoTrackingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingNoTrackingProjectionNpgsqlTest.cs @@ -81,8 +81,7 @@ public override async Task SelectMany_trunk_collection(bool async) public override async Task SelectMany_required_trunk_reference_branch_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.SelectMany_required_trunk_reference_branch_collection(async)); + await base.SelectMany_required_trunk_reference_branch_collection(async); AssertSql( """ @@ -99,8 +98,7 @@ public override async Task SelectMany_required_trunk_reference_branch_collection public override async Task SelectMany_optional_trunk_reference_branch_collection(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.SelectMany_optional_trunk_reference_branch_collection(async)); + await base.SelectMany_optional_trunk_reference_branch_collection(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingReferenceProjectionNoTrackingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingReferenceProjectionNoTrackingNpgsqlTest.cs index f5f570270..0baad4027 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingReferenceProjectionNoTrackingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Relationships/Projection/OwnedTableSplittingReferenceProjectionNoTrackingNpgsqlTest.cs @@ -41,8 +41,7 @@ public override async Task Select_trunk_required(bool async) public override async Task Select_branch_required_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_required_required(async)); + await base.Select_branch_required_required(async); AssertSql( """ @@ -59,8 +58,7 @@ public override async Task Select_branch_required_required(bool async) public override async Task Select_branch_required_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_required_optional(async)); + await base.Select_branch_required_optional(async); AssertSql( """ @@ -77,8 +75,7 @@ public override async Task Select_branch_required_optional(bool async) public override async Task Select_branch_optional_required(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_optional_required(async)); + await base.Select_branch_optional_required(async); AssertSql( """ @@ -95,8 +92,7 @@ public override async Task Select_branch_optional_required(bool async) public override async Task Select_branch_optional_optional(bool async) { - // https://github.com/dotnet/efcore/pull/35942 - await Assert.ThrowsAsync(() => base.Select_branch_optional_optional(async)); + await base.Select_branch_optional_optional(async); AssertSql( """ diff --git a/test/EFCore.PG.FunctionalTests/Query/SharedTypeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/SharedTypeQueryNpgsqlTest.cs index f77b5c0d1..f217715c7 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SharedTypeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SharedTypeQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class SharedTypeQueryNpgsqlTest : SharedTypeQueryRelationalTestBase +public class SharedTypeQueryNpgsqlTest(NonSharedFixture fixture) : SharedTypeQueryRelationalTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs index 5caf912d0..96ea46d87 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ToSqlQueryNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class ToSqlQuerySqlServerTest : ToSqlQueryTestBase +public class ToSqlQuerySqlServerTest(NonSharedFixture fixture) : ToSqlQueryTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs index 4b58db5a2..af2eb6514 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Translations/StringTranslationsNpgsqlTest.cs @@ -131,6 +131,10 @@ WHERE strpos(b."String", 'eattl') - 1 <> -1 """); } + // TODO: #3547 + public override Task IndexOf_Char(bool async) + => Assert.ThrowsAsync(() => base.IndexOf_Char(async)); + public override async Task IndexOf_with_empty_string(bool async) { await base.IndexOf_with_empty_string(async); @@ -155,17 +159,38 @@ public override async Task IndexOf_with_one_parameter_arg(bool async) FROM "BasicTypesEntities" AS b WHERE strpos(b."String", @pattern) - 1 = 1 """); + } + + public override async Task IndexOf_with_one_parameter_arg_char(bool async) + { + await base.IndexOf_with_one_parameter_arg_char(async); + AssertSql( + """ +@pattern='e' (DbType = String) + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE strpos(b."String", @pattern) - 1 = 1 +"""); } // PostgreSQL does not have strpos with starting position public override Task IndexOf_with_constant_starting_position(bool async) => AssertTranslationFailed(() => base.IndexOf_with_constant_starting_position(async)); + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_constant_starting_position_char(bool async) + => AssertTranslationFailed(() => base.IndexOf_with_constant_starting_position_char(async)); + // PostgreSQL does not have strpos with starting position public override Task IndexOf_with_parameter_starting_position(bool async) => AssertTranslationFailed(() => base.IndexOf_with_parameter_starting_position(async)); + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_parameter_starting_position_char(bool async) + => AssertTranslationFailed(() => base.IndexOf_with_parameter_starting_position_char(async)); + public override async Task IndexOf_after_ToString(bool async) { await base.IndexOf_after_ToString(async); @@ -206,6 +231,10 @@ WHERE replace(b."String", 'Sea', 'Rea') = 'Reattle' """); } + // TODO: #3547 + public override Task Replace_Char(bool async) + => AssertTranslationFailed(() => base.Replace_Char(async)); + public override async Task Replace_with_empty_string(bool async) { await base.Replace_with_empty_string(async); @@ -400,6 +429,10 @@ WHERE b."String" LIKE 'Se%' """); } + // TODO: #3547 + public override Task StartsWith_Literal_Char(bool async) + => AssertTranslationFailed(() => base.StartsWith_Literal_Char(async)); + public override async Task StartsWith_Parameter(bool async) { await base.StartsWith_Parameter(async); @@ -414,6 +447,9 @@ WHERE b."String" LIKE @pattern_startswith """); } + public override Task StartsWith_Parameter_Char(bool async) + => AssertTranslationFailed(() => base.StartsWith_Parameter_Char(async)); + public override async Task StartsWith_Column(bool async) { await base.StartsWith_Column(async); @@ -463,6 +499,10 @@ WHERE b."String" LIKE '%le' """); } + // TODO: #3547 + public override Task EndsWith_Literal_Char(bool async) + => AssertTranslationFailed(() => base.EndsWith_Literal_Char(async)); + public override async Task EndsWith_Parameter(bool async) { await base.EndsWith_Parameter(async); @@ -477,6 +517,10 @@ WHERE b."String" LIKE @pattern_endswith """); } + // TODO: #3547 + public override Task EndsWith_Parameter_Char(bool async) + => AssertTranslationFailed(() => base.EndsWith_Parameter_Char(async)); + public override async Task EndsWith_Column(bool async) { // SQL Server trims trailing whitespace for length calculations, making our EndsWith() column translation not work reliably in that @@ -533,6 +577,10 @@ WHERE b."String" LIKE '%eattl%' """); } + // TODO: #3547 + public override Task Contains_Literal_Char(bool async) + => AssertTranslationFailed(() => base.Contains_Literal_Char(async)); + public override async Task Contains_Column(bool async) { await base.Contains_Column(async); diff --git a/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs index 8276866fd..7c35b9b24 100644 --- a/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs @@ -1,6 +1,7 @@ namespace Microsoft.EntityFrameworkCore; -public class TPTTableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : TPTTableSplittingTestBase(testOutputHelper) +public class TPTTableSplittingNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : TPTTableSplittingTestBase(fixture, testOutputHelper) { public override Task Can_insert_dependent_with_just_one_parent() // This scenario is not valid for TPT diff --git a/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs index a53c1955d..ca7b8f12c 100644 --- a/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; [MinimumPostgresVersion(12, 0)] // Test suite uses computed columns -public class TableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : TableSplittingTestBase(testOutputHelper) +public class TableSplittingNpgsqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : TableSplittingTestBase(fixture, testOutputHelper) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStore.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStore.cs index 9bfe6413f..172704d34 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStore.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStore.cs @@ -9,7 +9,6 @@ public class NpgsqlTestStore : RelationalTestStore { private readonly string? _scriptPath; private readonly string? _additionalSql; - private readonly string? _connectionString; private const string Northwind = "Northwind"; @@ -28,9 +27,8 @@ public static NpgsqlTestStore GetOrCreate( string name, string? scriptPath = null, string? additionalSql = null, - string? connectionStringOptions = null, - bool useConnectionString = false) - => new(name, scriptPath, additionalSql, connectionStringOptions, useConnectionString: useConnectionString); + string? connectionStringOptions = null) + => new(name, scriptPath, additionalSql, connectionStringOptions); public static NpgsqlTestStore Create(string name, string? connectionStringOptions = null) => new(name, connectionStringOptions: connectionStringOptions, shared: false); @@ -43,15 +41,9 @@ public NpgsqlTestStore( string? scriptPath = null, string? additionalSql = null, string? connectionStringOptions = null, - bool shared = true, - bool useConnectionString = false) + bool shared = true) : base(name, shared, CreateConnection(name, connectionStringOptions)) { - if (useConnectionString) - { - _connectionString = CreateConnectionString(name, connectionStringOptions); - } - Name = name; if (scriptPath is not null) @@ -119,12 +111,9 @@ public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuild // sorts NULLs last by default. This configures the provider to emit NULLS FIRST. .ReverseNullOrdering(); - // The default mode in the EF tests is to use a DbConnection, but in Npgsql we have certain test suites which require that - // we use a connection string instead, because an NpgsqlDataSource is required internally (e.g. enums or plugins - // are used). - return _connectionString is null - ? builder.UseNpgsql(Connection, npgsqlOptionsBuilder) - : builder.UseNpgsql(_connectionString, npgsqlOptionsBuilder); + return UseConnectionString + ? builder.UseNpgsql(ConnectionString, npgsqlOptionsBuilder) + : builder.UseNpgsql(Connection, npgsqlOptionsBuilder); } private async Task CreateDatabaseAsync(Func? clean) diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStoreFactory.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStoreFactory.cs index 59756e26e..06082bacf 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStoreFactory.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlTestStoreFactory.cs @@ -9,10 +9,10 @@ public class NpgsqlTestStoreFactory( public static NpgsqlTestStoreFactory Instance { get; } = new(); public override TestStore Create(string storeName) - => new NpgsqlTestStore(storeName, scriptPath, additionalSql, connectionStringOptions, shared: false, useConnectionString); + => new NpgsqlTestStore(storeName, scriptPath, additionalSql, connectionStringOptions, shared: false) { UseConnectionString = useConnectionString }; public override TestStore GetOrCreate(string storeName) - => new NpgsqlTestStore(storeName, scriptPath, additionalSql, connectionStringOptions, shared: true, useConnectionString); + => new NpgsqlTestStore(storeName, scriptPath, additionalSql, connectionStringOptions, shared: true) { UseConnectionString = useConnectionString }; public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkNpgsql(); diff --git a/test/EFCore.PG.FunctionalTests/Update/NonSharedModelUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Update/NonSharedModelUpdatesNpgsqlTest.cs index 3aae00faf..9d4a5206b 100644 --- a/test/EFCore.PG.FunctionalTests/Update/NonSharedModelUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Update/NonSharedModelUpdatesNpgsqlTest.cs @@ -1,6 +1,6 @@ namespace Microsoft.EntityFrameworkCore.Update; -public class NonSharedModelUpdatesNpgsqlTest : NonSharedModelUpdatesTestBase +public class NonSharedModelUpdatesNpgsqlTest(NonSharedFixture fixture) : NonSharedModelUpdatesTestBase(fixture) { protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/Update/StoredProcedureUpdateNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Update/StoredProcedureUpdateNpgsqlTest.cs index f17781363..065590461 100644 --- a/test/EFCore.PG.FunctionalTests/Update/StoredProcedureUpdateNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Update/StoredProcedureUpdateNpgsqlTest.cs @@ -3,7 +3,7 @@ namespace Microsoft.EntityFrameworkCore.Update; [MinimumPostgresVersion(14, 0)] -public class StoredProcedureUpdateNpgsqlTest : StoredProcedureUpdateTestBase +public class StoredProcedureUpdateNpgsqlTest(NonSharedFixture fixture) : StoredProcedureUpdateTestBase(fixture) { public override async Task Insert_with_output_parameter(bool async) { diff --git a/test/EFCore.PG.Tests/EFCore.PG.Tests.csproj b/test/EFCore.PG.Tests/EFCore.PG.Tests.csproj index 201184440..a61023ba1 100644 --- a/test/EFCore.PG.Tests/EFCore.PG.Tests.csproj +++ b/test/EFCore.PG.Tests/EFCore.PG.Tests.csproj @@ -25,4 +25,9 @@ + + + + + diff --git a/test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs b/test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs index 7e23c0a65..ce41173e5 100644 --- a/test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlRelationalConnectionTest.cs @@ -407,7 +407,8 @@ public static NpgsqlRelationalConnection CreateConnection(DbContextOptions? opti new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()), new NpgsqlSingletonOptions()), new ExceptionDetector(), - new LoggingOptions()))), + new LoggingOptions())), + new ExceptionDetector()), new NpgsqlDataSourceManager([]), dbContextOptions); }