Skip to content

Commit afede2f

Browse files
committed
Query: Add TPT variant for GearsOfWarQueryTests
Part of #21510
1 parent da5ed2e commit afede2f

File tree

9 files changed

+9140
-10
lines changed

9 files changed

+9140
-10
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
5+
using Microsoft.EntityFrameworkCore.TestUtilities;
6+
7+
namespace Microsoft.EntityFrameworkCore.Query
8+
{
9+
public abstract class TPTGearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureBase
10+
{
11+
protected override string StoreName { get; } = "TPTGearsOfWarQueryTest";
12+
public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore;
13+
14+
public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory;
15+
16+
protected override bool ShouldLogCategory(string logCategory)
17+
=> logCategory == DbLoggerCategory.Query.Name;
18+
19+
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
20+
{
21+
base.OnModelCreating(modelBuilder, context);
22+
23+
modelBuilder.Entity<Gear>().ToTable("Gears");
24+
modelBuilder.Entity<Officer>().ToTable("Officers");
25+
26+
modelBuilder.Entity<Faction>().ToTable("Factions");
27+
modelBuilder.Entity<LocustHorde>().ToTable("LocustHordes");
28+
29+
modelBuilder.Entity<LocustLeader>().ToTable("LocustLeaders");
30+
modelBuilder.Entity<LocustCommander>().ToTable("LocustCommanders");
31+
}
32+
}
33+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace Microsoft.EntityFrameworkCore.Query
5+
{
6+
public abstract class TPTGearsOfWarQueryRelationalTestBase<TFixture> : GearsOfWarQueryRelationalTestBase<TFixture>
7+
where TFixture : TPTGearsOfWarQueryRelationalFixture, new()
8+
{
9+
protected TPTGearsOfWarQueryRelationalTestBase(TFixture fixture)
10+
: base(fixture)
11+
{
12+
}
13+
}
14+
}

test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void AssertBaseline(string[] expected)
8686
Logger.TestOutputHelper?.WriteLine("---- New Baseline -------------------------------------------------------------------");
8787
Logger.TestOutputHelper?.WriteLine(newBaseLine);
8888

89-
var contents = testInfo + newBaseLine + FileNewLine + FileNewLine;
89+
var contents = testInfo + newBaseLine + FileNewLine + "--------------------" + FileNewLine;
9090

9191
File.AppendAllText(logFile, contents);
9292
}

test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Linq;
65
using System.Threading.Tasks;
76
using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
5+
using Microsoft.EntityFrameworkCore.TestUtilities;
6+
7+
namespace Microsoft.EntityFrameworkCore.Query
8+
{
9+
public class TPTGearsOfWarQuerySqlServerFixture : TPTGearsOfWarQueryRelationalFixture
10+
{
11+
protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance;
12+
13+
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
14+
{
15+
base.OnModelCreating(modelBuilder, context);
16+
17+
modelBuilder.Entity<City>().Property(g => g.Location).HasColumnType("varchar(100)");
18+
}
19+
}
20+
}

test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs

Lines changed: 8840 additions & 0 deletions
Large diffs are not rendered by default.

test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,28 +182,28 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async)
182182
WHERE ""s"".""Banner5"" = @__byteArrayParam_0");
183183
}
184184

185-
[ConditionalTheory(Skip = "PR #19774")]
185+
[ConditionalTheory(Skip = "Issue#18844")]
186186
public override Task TimeSpan_Hours(bool async) => base.TimeSpan_Hours(async);
187187

188-
[ConditionalTheory(Skip = "PR #19774")]
188+
[ConditionalTheory(Skip = "Issue#18844")]
189189
public override Task TimeSpan_Minutes(bool async) => base.TimeSpan_Minutes(async);
190190

191-
[ConditionalTheory(Skip = "PR #19774")]
191+
[ConditionalTheory(Skip = "Issue#18844")]
192192
public override Task TimeSpan_Seconds(bool async) => base.TimeSpan_Seconds(async);
193193

194-
[ConditionalTheory(Skip = "PR #19774")]
194+
[ConditionalTheory(Skip = "Issue#18844")]
195195
public override Task TimeSpan_Milliseconds(bool async) => base.TimeSpan_Milliseconds(async);
196196

197-
[ConditionalTheory(Skip = "PR #19774")]
197+
[ConditionalTheory(Skip = "Issue#18844")]
198198
public override Task Where_TimeSpan_Hours(bool async) => base.Where_TimeSpan_Hours(async);
199199

200-
[ConditionalTheory(Skip = "PR #19774")]
200+
[ConditionalTheory(Skip = "Issue#18844")]
201201
public override Task Where_TimeSpan_Minutes(bool async) => base.Where_TimeSpan_Minutes(async);
202202

203-
[ConditionalTheory(Skip = "PR #19774")]
203+
[ConditionalTheory(Skip = "Issue#18844")]
204204
public override Task Where_TimeSpan_Seconds(bool async) => base.Where_TimeSpan_Seconds(async);
205205

206-
[ConditionalTheory(Skip = "PR #19774")]
206+
[ConditionalTheory(Skip = "Issue#18844")]
207207
public override Task Where_TimeSpan_Milliseconds(bool async) => base.Where_TimeSpan_Milliseconds(async);
208208

209209
private void AssertSql(params string[] expected)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.EntityFrameworkCore.TestUtilities;
5+
6+
namespace Microsoft.EntityFrameworkCore.Query
7+
{
8+
public class TPTGearsOfWarQuerySqliteFixture : TPTGearsOfWarQueryRelationalFixture
9+
{
10+
protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance;
11+
}
12+
}
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Threading.Tasks;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace Microsoft.EntityFrameworkCore.Query
9+
{
10+
public class TPTGearsOfWarQuerySqliteTest : TPTGearsOfWarQueryRelationalTestBase<TPTGearsOfWarQuerySqliteFixture>
11+
{
12+
public TPTGearsOfWarQuerySqliteTest(TPTGearsOfWarQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper)
13+
: base(fixture)
14+
{
15+
Fixture.TestSqlLoggerFactory.Clear();
16+
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
17+
}
18+
19+
public override Task Where_datetimeoffset_date_component(bool async)
20+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async));
21+
22+
public override Task Where_datetimeoffset_day_component(bool async)
23+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async));
24+
25+
public override Task Where_datetimeoffset_dayofyear_component(bool async)
26+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async));
27+
28+
public override Task Where_datetimeoffset_hour_component(bool async)
29+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async));
30+
31+
public override Task Where_datetimeoffset_millisecond_component(bool async)
32+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async));
33+
34+
public override Task Where_datetimeoffset_minute_component(bool async)
35+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async));
36+
37+
public override Task Where_datetimeoffset_month_component(bool async)
38+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async));
39+
40+
public override Task Where_datetimeoffset_now(bool async)
41+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_now(async));
42+
43+
public override Task Where_datetimeoffset_second_component(bool async)
44+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async));
45+
46+
public override Task Where_datetimeoffset_utcnow(bool async)
47+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async));
48+
49+
public override Task Where_datetimeoffset_year_component(bool async)
50+
=> AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async));
51+
52+
public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)
53+
=> AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async));
54+
55+
public override Task DateTimeOffset_Date_returns_datetime(bool async)
56+
=> AssertTranslationFailed(() => base.DateTimeOffset_Date_returns_datetime(async));
57+
58+
// Sqlite does not support cross/outer apply
59+
public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) => null;
60+
61+
public override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) => null;
62+
63+
public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) => null;
64+
65+
public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) => null;
66+
67+
public override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) => null;
68+
69+
public override Task Outer_parameter_in_join_key(bool async) => null;
70+
71+
public override Task Outer_parameter_in_join_key_inner_and_outer(bool async) => null;
72+
73+
public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) => null;
74+
75+
public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) => null;
76+
77+
public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) => null;
78+
79+
public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) => null;
80+
81+
public override async Task Negate_on_binary_expression(bool async)
82+
{
83+
await base.Negate_on_binary_expression(async);
84+
85+
AssertSql(
86+
@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
87+
FROM ""Squads"" AS ""s""
88+
WHERE ""s"".""Id"" = -(""s"".""Id"" + ""s"".""Id"")");
89+
}
90+
91+
public override async Task Negate_on_column(bool async)
92+
{
93+
await base.Negate_on_column(async);
94+
95+
AssertSql(
96+
@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
97+
FROM ""Squads"" AS ""s""
98+
WHERE ""s"".""Id"" = -""s"".""Id""");
99+
}
100+
101+
public override async Task Negate_on_like_expression(bool async)
102+
{
103+
await base.Negate_on_like_expression(async);
104+
105+
AssertSql(
106+
@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
107+
FROM ""Squads"" AS ""s""
108+
WHERE ""s"".""Name"" IS NOT NULL AND NOT (""s"".""Name"" LIKE 'us%')");
109+
}
110+
111+
public override async Task Select_datetimeoffset_comparison_in_projection(bool async)
112+
{
113+
await base.Select_datetimeoffset_comparison_in_projection(async);
114+
115+
AssertSql(
116+
@"SELECT ""m"".""Timeline""
117+
FROM ""Missions"" AS ""m""");
118+
}
119+
120+
public override async Task Byte_array_contains_literal(bool async)
121+
{
122+
await base.Byte_array_contains_literal(async);
123+
124+
AssertSql(
125+
@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
126+
FROM ""Squads"" AS ""s""
127+
WHERE instr(""s"".""Banner"", X'01') > 0");
128+
}
129+
130+
public override async Task Byte_array_contains_parameter(bool async)
131+
{
132+
await base.Byte_array_contains_parameter(async);
133+
134+
AssertSql(
135+
@"@__someByte_0='1' (DbType = String)
136+
137+
SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
138+
FROM ""Squads"" AS ""s""
139+
WHERE instr(""s"".""Banner"", char(@__someByte_0)) > 0");
140+
}
141+
142+
public override async Task Byte_array_filter_by_length_literal(bool async)
143+
{
144+
await base.Byte_array_filter_by_length_literal(async);
145+
146+
AssertSql(@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
147+
FROM ""Squads"" AS ""s""
148+
WHERE length(""s"".""Banner"") = 1");
149+
}
150+
151+
public override async Task Byte_array_filter_by_length_parameter(bool async)
152+
{
153+
await base.Byte_array_filter_by_length_parameter(async);
154+
155+
AssertSql(@"@__p_0='1' (DbType = String)
156+
157+
SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
158+
FROM ""Squads"" AS ""s""
159+
WHERE length(""s"".""Banner"") = @__p_0");
160+
}
161+
162+
public override void Byte_array_filter_by_length_parameter_compiled()
163+
{
164+
base.Byte_array_filter_by_length_parameter_compiled();
165+
166+
AssertSql(
167+
@"@__byteArrayParam='0x2A80' (Size = 2) (DbType = String)
168+
169+
SELECT COUNT(*)
170+
FROM ""Squads"" AS ""s""
171+
WHERE length(""s"".""Banner"") = length(@__byteArrayParam)");
172+
}
173+
174+
public override async Task Byte_array_filter_by_SequenceEqual(bool async)
175+
{
176+
await base.Byte_array_filter_by_SequenceEqual(async);
177+
178+
AssertSql(@"@__byteArrayParam_0='0x0405060708' (Size = 5) (DbType = String)
179+
180+
SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name""
181+
FROM ""Squads"" AS ""s""
182+
WHERE ""s"".""Banner5"" = @__byteArrayParam_0");
183+
}
184+
185+
[ConditionalTheory(Skip = "Issue#18844")]
186+
public override Task TimeSpan_Hours(bool async) => base.TimeSpan_Hours(async);
187+
188+
[ConditionalTheory(Skip = "Issue#18844")]
189+
public override Task TimeSpan_Minutes(bool async) => base.TimeSpan_Minutes(async);
190+
191+
[ConditionalTheory(Skip = "Issue#18844")]
192+
public override Task TimeSpan_Seconds(bool async) => base.TimeSpan_Seconds(async);
193+
194+
[ConditionalTheory(Skip = "Issue#18844")]
195+
public override Task TimeSpan_Milliseconds(bool async) => base.TimeSpan_Milliseconds(async);
196+
197+
[ConditionalTheory(Skip = "Issue#18844")]
198+
public override Task Where_TimeSpan_Hours(bool async) => base.Where_TimeSpan_Hours(async);
199+
200+
[ConditionalTheory(Skip = "Issue#18844")]
201+
public override Task Where_TimeSpan_Minutes(bool async) => base.Where_TimeSpan_Minutes(async);
202+
203+
[ConditionalTheory(Skip = "Issue#18844")]
204+
public override Task Where_TimeSpan_Seconds(bool async) => base.Where_TimeSpan_Seconds(async);
205+
206+
[ConditionalTheory(Skip = "Issue#18844")]
207+
public override Task Where_TimeSpan_Milliseconds(bool async) => base.Where_TimeSpan_Milliseconds(async);
208+
209+
private void AssertSql(params string[] expected)
210+
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
211+
}
212+
}

0 commit comments

Comments
 (0)