From 01874ea98fb9fa37f68db1835298f85f16412240 Mon Sep 17 00:00:00 2001 From: David Roth Date: Mon, 12 Oct 2020 12:46:49 +0200 Subject: [PATCH 1/5] Run BuiltInDataTypesNpgsqlTest again with the NodaTime plugin activated to verify that all BCL date/time types are properly supported. Closes #1490 --- ...nDataTypesWithNodaTimePluginEnabledTest.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs new file mode 100644 index 000000000..2d8cd53fc --- /dev/null +++ b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; +using Xunit; +using Xunit.Abstractions; + +namespace Npgsql.EntityFrameworkCore.PostgreSQL +{ + public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTest, IClassFixture + { + public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture, testOutputHelper) + { } + + public class BuiltInDataTypesWithNodaTimePluginEnabledFixture : BuiltInDataTypesNpgsqlFixture + { + protected override IServiceCollection AddServices(IServiceCollection serviceCollection) + => base.AddServices(serviceCollection).AddEntityFrameworkNpgsqlNodaTime(); + + public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + { + var optionsBuilder = base.AddOptions(builder); + new NpgsqlDbContextOptionsBuilder(optionsBuilder).UseNodaTime(); + + return optionsBuilder; + } + } + } +} From 0732d22a1934b6ca1692407cc6923d123aace9fa Mon Sep 17 00:00:00 2001 From: David Roth Date: Mon, 12 Oct 2020 12:51:32 +0200 Subject: [PATCH 2/5] new line --- .../BuiltInDataTypesWithNodaTimePluginEnabledTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs index 2d8cd53fc..3515317ee 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs @@ -6,7 +6,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL { - public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTest, IClassFixture + public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTest, + IClassFixture { public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper) From cc179809be6a3675d4c1a4639ac6bbb4a4ed737e Mon Sep 17 00:00:00 2001 From: David Roth Date: Fri, 16 Oct 2020 11:43:02 +0200 Subject: [PATCH 3/5] Refactor build in data types test and add BuiltInDataTypesNpgsqlTestBase. --- .../BuiltInDataTypesNpgsqlTest.cs | 50 ++++++++++++------- ...nDataTypesWithNodaTimePluginEnabledTest.cs | 24 ++++++--- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs index 6128ae4fa..14fdce541 100644 --- a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs @@ -1,31 +1,28 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Net.NetworkInformation; -using Xunit; -using Xunit.Abstractions; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; using NpgsqlTypes; +using Xunit; +using Xunit.Abstractions; namespace Npgsql.EntityFrameworkCore.PostgreSQL { - public class BuiltInDataTypesNpgsqlTest : BuiltInDataTypesTestBase + public abstract class BuiltInDataTypesNpgsqlTestBase : BuiltInDataTypesTestBase + where TFixture : BuiltInDataTypesNpgsqlTestBase.BuiltInDataTypesNpgsqlTestBaseFixture, new() { - // ReSharper disable once UnusedParameter.Local - public BuiltInDataTypesNpgsqlTest(BuiltInDataTypesNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture) + protected BuiltInDataTypesNpgsqlTestBase(TFixture fixture) : base(fixture) { - Fixture.TestSqlLoggerFactory.Clear(); - //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } [Fact] @@ -119,8 +116,8 @@ public virtual void Can_query_using_any_mapped_data_type() ImmutableDictionaryAsHstore = ImmutableDictionary.Empty.Add("c", "d"), NpgsqlRangeAsRange = new NpgsqlRange(4, true, 8, false), - IntArrayAsIntArray= new[] { 2, 3 }, - PhysicalAddressArrayAsMacaddrArray= new[] { PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04") }, + IntArrayAsIntArray = new[] { 2, 3 }, + PhysicalAddressArrayAsMacaddrArray = new[] { PhysicalAddress.Parse("08-00-2B-01-02-03"), PhysicalAddress.Parse("08-00-2B-01-02-04") }, UintAsXid = (uint)int.MaxValue + 1, @@ -423,7 +420,7 @@ public virtual void Can_query_using_any_mapped_data_types_with_nulls() Assert.Same(entity, context.Set().Single(e => e.Int == 911 && e.IntArrayAsIntArray == param33)); PhysicalAddress[] param34 = null; - Assert.Same(entity, context.Set().Single(e => e.Int == 911 && e.PhysicalAddressArrayAsMacaddrArray== param34)); + Assert.Same(entity, context.Set().Single(e => e.Int == 911 && e.PhysicalAddressArrayAsMacaddrArray == param34)); uint? param35 = null; Assert.Same(entity, context.Set().Single(e => e.Int == 911 && e.UintAsXid == param35)); @@ -705,11 +702,11 @@ static void AssertNullMappedNullableDataTypes(MappedNullableDataTypes entity, in Assert.Null(entity.Mood); } - [Fact(Skip="https://github.com/aspnet/EntityFrameworkCore/issues/14159")] - public override void Can_query_using_any_data_type_nullable_shadow() {} + [Fact(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/14159")] + public override void Can_query_using_any_data_type_nullable_shadow() { } - [Fact(Skip="https://github.com/aspnet/EntityFrameworkCore/issues/14159")] - public override void Can_query_using_any_data_type_shadow() {} + [Fact(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/14159")] + public override void Can_query_using_any_data_type_shadow() { } public override void Can_query_with_null_parameters_using_any_nullable_data_type() { @@ -915,7 +912,7 @@ public void Money_compare_parameter() void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class BuiltInDataTypesNpgsqlFixture : BuiltInDataTypesFixtureBase + public class BuiltInDataTypesNpgsqlTestBaseFixture : BuiltInDataTypesFixtureBase { public override bool StrictEquality => false; @@ -1361,6 +1358,21 @@ protected class MappedNullableDataTypes } } + + public class BuiltInDataTypesNpgsqlTest : BuiltInDataTypesNpgsqlTestBase + { + // ReSharper disable once UnusedParameter.Local + public BuiltInDataTypesNpgsqlTest(BuiltInDataTypesNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public class BuiltInDataTypesNpgsqlFixture : BuiltInDataTypesNpgsqlTestBaseFixture + { } + } + // ReSharper disable once UnusedMember.Global public enum Mood { Happy, Sad }; } diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs index 3515317ee..a181a4348 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs @@ -1,20 +1,22 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; -using Xunit; -using Xunit.Abstractions; +using static Npgsql.EntityFrameworkCore.PostgreSQL.NodaTimeTest; namespace Npgsql.EntityFrameworkCore.PostgreSQL { - public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTest, - IClassFixture + public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTestBase { - public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { } + public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + } - public class BuiltInDataTypesWithNodaTimePluginEnabledFixture : BuiltInDataTypesNpgsqlFixture + public class BuiltInDataTypesWithNodaTimePluginEnabledFixture : BuiltInDataTypesNpgsqlTestBaseFixture { + protected override string StoreName => "BuiltInDataTypesWithNodaTimeEnabled"; + protected override IServiceCollection AddServices(IServiceCollection serviceCollection) => base.AddServices(serviceCollection).AddEntityFrameworkNpgsqlNodaTime(); @@ -25,6 +27,12 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build return optionsBuilder; } + + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) + { + base.OnModelCreating(modelBuilder, context); + modelBuilder.Entity(); + } } } } From e040800f8e53aca17bd31630b571ce97e8e41770 Mon Sep 17 00:00:00 2001 From: David Roth Date: Mon, 19 Oct 2020 14:08:23 +0200 Subject: [PATCH 4/5] update to latest npgsql ci-build --- Directory.Build.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 0efbdd225..9ea64aa39 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,8 +1,8 @@ - + 5.0.0-rc.1.20451.13 5.0.0-rc.1.20451.14 - 5.0.0-ci.20201003T171056 + 5.0.0-ci.20201017T090100 From cdea083668851cc502f2b74461a24bafbb611c5b Mon Sep 17 00:00:00 2001 From: David Roth Date: Mon, 19 Oct 2020 14:12:55 +0200 Subject: [PATCH 5/5] cleanup --- .../BuiltInDataTypesWithNodaTimePluginEnabledTest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs index a181a4348..e4a300ded 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/BuiltInDataTypesWithNodaTimePluginEnabledTest.cs @@ -8,10 +8,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTestBase { public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture) - : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + : base(fixture) => Fixture.TestSqlLoggerFactory.Clear(); public class BuiltInDataTypesWithNodaTimePluginEnabledFixture : BuiltInDataTypesNpgsqlTestBaseFixture {