From 135e8da2109f1b5d57f333428f3fcfeb655379f3 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 28 Apr 2020 14:20:53 -0700 Subject: [PATCH] Query: Add regression test for #20731 (#20774) Fixed in #20628 --- .../Query/GearsOfWarQueryTestBase.cs | 12 ++++++++++++ .../Query/GearsOfWarQuerySqlServerTest.cs | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index f69b45002d3..2620c130b63 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -7469,6 +7469,18 @@ public virtual Task Constant_enum_with_same_underlying_value_as_previously_param .Select(g => g.Rank & MilitaryRank.Private)); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Enum_array_contains(bool async) + { + var types = new[] { (AmmunitionType?)null, AmmunitionType.Cartridge }; + + return AssertQuery( + async, + ss => ss.Set() + .Where(w => w.SynergyWith != null && types.Contains(w.SynergyWith.AmmunitionType))); + } + protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); protected virtual void ClearLog() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 77b7b7a52fd..b3b5e14b72c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -6979,6 +6979,17 @@ FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } + public override async Task Enum_array_contains(bool async) + { + await base.Enum_array_contains(async); + + AssertSql( + @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN (1) OR [w0].[AmmunitionType] IS NULL)"); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public async Task DataLength_function_for_string_parameter(bool async)