Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that BCL Types work with NodaTime plugin activated #1532

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<Project>
<PropertyGroup>
<EFCoreVersion>5.0.0-rc.1.20451.13</EFCoreVersion>
<MicrosoftExtensionsVersion>5.0.0-rc.1.20451.14</MicrosoftExtensionsVersion>
<NpgsqlVersion>5.0.0-ci.20201003T171056</NpgsqlVersion>
<NpgsqlVersion>5.0.0-ci.20201017T090100</NpgsqlVersion>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to update to pull these changes in.

</PropertyGroup>

<ItemGroup>
Expand Down
50 changes: 31 additions & 19 deletions test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
Original file line number Diff line number Diff line change
@@ -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<BuiltInDataTypesNpgsqlTest.BuiltInDataTypesNpgsqlFixture>
public abstract class BuiltInDataTypesNpgsqlTestBase<TFixture> : BuiltInDataTypesTestBase<TFixture>
where TFixture : BuiltInDataTypesNpgsqlTestBase<TFixture>.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]
Expand Down Expand Up @@ -119,8 +116,8 @@ public virtual void Can_query_using_any_mapped_data_type()
ImmutableDictionaryAsHstore = ImmutableDictionary<string, string>.Empty.Add("c", "d"),
NpgsqlRangeAsRange = new NpgsqlRange<int>(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,

Expand Down Expand Up @@ -423,7 +420,7 @@ public virtual void Can_query_using_any_mapped_data_types_with_nulls()
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.IntArrayAsIntArray == param33));

PhysicalAddress[] param34 = null;
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.PhysicalAddressArrayAsMacaddrArray== param34));
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.PhysicalAddressArrayAsMacaddrArray == param34));

uint? param35 = null;
Assert.Same(entity, context.Set<MappedNullableDataTypes>().Single(e => e.Int == 911 && e.UintAsXid == param35));
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -1361,6 +1358,21 @@ protected class MappedNullableDataTypes
}
}


public class BuiltInDataTypesNpgsqlTest : BuiltInDataTypesNpgsqlTestBase<BuiltInDataTypesNpgsqlTest.BuiltInDataTypesNpgsqlFixture>
{
// ReSharper disable once UnusedParameter.Local
public BuiltInDataTypesNpgsqlTest(BuiltInDataTypesNpgsqlFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment copied over from line 28 in main branch. Should I remove it?

}

public class BuiltInDataTypesNpgsqlFixture : BuiltInDataTypesNpgsqlTestBaseFixture
{ }
}

// ReSharper disable once UnusedMember.Global
public enum Mood { Happy, Sad };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
using static Npgsql.EntityFrameworkCore.PostgreSQL.NodaTimeTest;

namespace Npgsql.EntityFrameworkCore.PostgreSQL
{
public class BuiltInDataTypesWithNodaTimePluginEnabledTest : BuiltInDataTypesNpgsqlTestBase<BuiltInDataTypesWithNodaTimePluginEnabledTest.BuiltInDataTypesWithNodaTimePluginEnabledFixture>
{
public BuiltInDataTypesWithNodaTimePluginEnabledTest(BuiltInDataTypesWithNodaTimePluginEnabledFixture fixture)
: base(fixture) => Fixture.TestSqlLoggerFactory.Clear();

public class BuiltInDataTypesWithNodaTimePluginEnabledFixture : BuiltInDataTypesNpgsqlTestBaseFixture
{
protected override string StoreName => "BuiltInDataTypesWithNodaTimeEnabled";

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;
}

protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);
modelBuilder.Entity<NodaTimeTypes>();
}
}
}
}