-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query: Add TPT variant for FilterInheritanceQueryTests
Part of #21510
- Loading branch information
Showing
5 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
test/EFCore.Relational.Specification.Tests/Query/TPTFiltersInheritanceQueryTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class TPTFiltersInheritanceQueryTestBase<TFixture> : FiltersInheritanceQueryTestBase<TFixture> | ||
where TFixture : TPTInheritanceQueryFixture, new() | ||
{ | ||
public TPTFiltersInheritanceQueryTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class TPTFiltersInheritanceQuerySqlServerFixture : TPTInheritanceQuerySqlServerFixture | ||
{ | ||
protected override bool EnableFilters => true; | ||
} | ||
} |
180 changes: 180 additions & 0 deletions
180
test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Xunit.Abstractions; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class TPTFiltersInheritanceQuerySqlServerTest : TPTFiltersInheritanceQueryTestBase<TPTFiltersInheritanceQuerySqlServerFixture> | ||
{ | ||
public TPTFiltersInheritanceQuerySqlServerTest(TPTFiltersInheritanceQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
Fixture.TestSqlLoggerFactory.Clear(); | ||
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); | ||
} | ||
|
||
public override void Can_use_of_type_animal() | ||
{ | ||
base.Can_use_of_type_animal(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE [a].[CountryId] = 1 | ||
ORDER BY [a].[Species]"); | ||
} | ||
|
||
public override void Can_use_is_kiwi() | ||
{ | ||
base.Can_use_is_kiwi(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND [k].[Species] IS NOT NULL"); | ||
} | ||
|
||
public override void Can_use_is_kiwi_with_other_predicate() | ||
{ | ||
base.Can_use_is_kiwi_with_other_predicate(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND ([k].[Species] IS NOT NULL AND ([a].[CountryId] = 1))"); | ||
} | ||
|
||
public override void Can_use_is_kiwi_in_projection() | ||
{ | ||
base.Can_use_is_kiwi_in_projection(); | ||
|
||
AssertSql( | ||
@"SELECT CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE [a].[CountryId] = 1"); | ||
} | ||
|
||
public override void Can_use_of_type_bird() | ||
{ | ||
base.Can_use_of_type_bird(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND ([e].[Species] IS NOT NULL OR [k].[Species] IS NOT NULL) | ||
ORDER BY [a].[Species]"); | ||
} | ||
|
||
public override void Can_use_of_type_bird_predicate() | ||
{ | ||
base.Can_use_of_type_bird_predicate(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE (([a].[CountryId] = 1) AND ([a].[CountryId] = 1)) AND ([e].[Species] IS NOT NULL OR [k].[Species] IS NOT NULL) | ||
ORDER BY [a].[Species]"); | ||
} | ||
|
||
public override void Can_use_of_type_bird_with_projection() | ||
{ | ||
base.Can_use_of_type_bird_with_projection(); | ||
|
||
AssertSql( | ||
@"SELECT [b].[EagleId] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND ([e].[Species] IS NOT NULL OR [k].[Species] IS NOT NULL)"); | ||
} | ||
|
||
public override void Can_use_of_type_bird_first() | ||
{ | ||
base.Can_use_of_type_bird_first(); | ||
|
||
AssertSql( | ||
@"SELECT TOP(1) [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [e].[Group], [k].[FoundOn], CASE | ||
WHEN [e].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsEagle], CASE | ||
WHEN [k].[Species] IS NOT NULL THEN CAST(1 AS bit) | ||
ELSE CAST(0 AS bit) | ||
END AS [IsKiwi] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND ([e].[Species] IS NOT NULL OR [k].[Species] IS NOT NULL) | ||
ORDER BY [a].[Species]"); | ||
} | ||
|
||
public override void Can_use_of_type_kiwi() | ||
{ | ||
base.Can_use_of_type_kiwi(); | ||
|
||
AssertSql( | ||
@"SELECT [a].[Species], [a].[CountryId], [a].[Name], [b].[EagleId], [b].[IsFlightless], [k].[FoundOn] | ||
FROM [Animals] AS [a] | ||
LEFT JOIN [Birds] AS [b] ON [a].[Species] = [b].[Species] | ||
LEFT JOIN [Eagle] AS [e] ON [a].[Species] = [e].[Species] | ||
LEFT JOIN [Kiwi] AS [k] ON [a].[Species] = [k].[Species] | ||
WHERE ([a].[CountryId] = 1) AND [k].[Species] IS NOT NULL"); | ||
} | ||
|
||
private void AssertSql(params string[] expected) | ||
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class TPTFiltersInheritanceQuerySqliteFixture : TPTInheritanceQuerySqliteFixture | ||
{ | ||
protected override bool EnableFilters => true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class TPTFiltersInheritanceQuerySqliteTest : TPTFiltersInheritanceQueryTestBase<TPTFiltersInheritanceQuerySqliteFixture> | ||
{ | ||
public TPTFiltersInheritanceQuerySqliteTest(TPTFiltersInheritanceQuerySqliteFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
} | ||
} |