From 5668178d21dd388f9ac1356a8f5eac88bc1843a5 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Thu, 19 Aug 2021 19:17:36 +0200 Subject: [PATCH] Add test --- .../Query/GearsOfWarQueryTestBase.cs | 10 ++++++++++ .../TestModels/GearsOfWarModel/Faction.cs | 3 +++ .../Query/GearsOfWarQuerySqlServerTest.cs | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index 2374fc3ed5e..ee21cd42a2f 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Net; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; @@ -8997,6 +8998,15 @@ public virtual Task Include_on_entity_that_is_not_present_in_final_projection_bu }); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Comparison_with_value_converted_subclass(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Where(f => f.ServerAddress == IPAddress.Loopback)); + } + protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Faction.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Faction.cs index 3a68f6a65d2..c878dde59ae 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Faction.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Faction.cs @@ -1,12 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Net; + namespace Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel { public abstract class Faction { public int Id { get; set; } public string Name { get; set; } + public IPAddress ServerAddress { get; set; } public string CapitalName { get; set; } public City Capital { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 34a2f65fa36..e377a548733 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -8154,6 +8154,16 @@ END AS [IsOfficer] FROM [Gears] AS [g]"); } + public override async Task Comparison_with_value_converted_subclass(bool async) + { + await base.Comparison_with_value_converted_subclass(async); + + AssertSql( + @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +WHERE [f].[ServerAddress] = CAST(N'127.0.0.1' AS nvarchar(45))"); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); }