Skip to content

Commit d1124fa

Browse files
authored
Fix to #1015 - Remove QueryBugsTest class (#32542)
- Moving tests from QueryBugsTests to other more appropriate places (either AssertQuery - enabled or proper AdHoc suites) - Adding a bunch of AdHoc suites (navigations, splitting, filters, weird mappings) - Unified format of AdHoc tests Resolves #1015
1 parent 5d88b84 commit d1124fa

File tree

69 files changed

+14770
-13704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+14770
-13704
lines changed

test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,14 +2237,16 @@ public override async Task Multiple_collection_navigation_with_FirstOrDefault_ch
22372237

22382238
public override async Task All_true(bool async)
22392239
{
2240-
await base.All_true(async);
2240+
// Aggregates. Issue #16146.
2241+
await AssertTranslationFailed(() => base.All_true(async));
22412242

22422243
AssertSql();
22432244
}
22442245

22452246
public override async Task Not_Any_false(bool async)
22462247
{
2247-
await base.Not_Any_false(async);
2248+
// Aggregates. Issue #16146.
2249+
await AssertTranslationFailed(() => base.Not_Any_false(async));
22482250

22492251
AssertSql();
22502252
}
@@ -2329,6 +2331,64 @@ FROM root c
23292331
""");
23302332
}
23312333

2334+
public override async Task Return_type_of_singular_operator_is_preserved(bool async)
2335+
{
2336+
await base.Return_type_of_singular_operator_is_preserved(async);
2337+
2338+
AssertSql(
2339+
"""
2340+
SELECT c["CustomerID"], c["City"]
2341+
FROM root c
2342+
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
2343+
OFFSET 0 LIMIT 1
2344+
""",
2345+
//
2346+
"""
2347+
SELECT c["CustomerID"], c["City"]
2348+
FROM root c
2349+
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
2350+
OFFSET 0 LIMIT 1
2351+
""",
2352+
//
2353+
"""
2354+
SELECT c["CustomerID"], c["City"]
2355+
FROM root c
2356+
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
2357+
OFFSET 0 LIMIT 2
2358+
""",
2359+
//
2360+
"""
2361+
SELECT c["CustomerID"], c["City"]
2362+
FROM root c
2363+
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
2364+
OFFSET 0 LIMIT 2
2365+
""",
2366+
//
2367+
"""
2368+
SELECT c["CustomerID"], c["City"]
2369+
FROM root c
2370+
WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A"))
2371+
ORDER BY c["CustomerID"] DESC
2372+
OFFSET 0 LIMIT 1
2373+
""",
2374+
//
2375+
"""
2376+
SELECT c["CustomerID"], c["City"]
2377+
FROM root c
2378+
WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A"))
2379+
ORDER BY c["CustomerID"] DESC
2380+
OFFSET 0 LIMIT 1
2381+
""");
2382+
}
2383+
2384+
[ConditionalTheory(Skip = "Issue #20677")]
2385+
public override async Task Type_casting_inside_sum(bool async)
2386+
{
2387+
await base.Type_casting_inside_sum(async);
2388+
2389+
AssertSql();
2390+
}
2391+
23322392
private void AssertSql(params string[] expected)
23332393
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
23342394

test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4682,6 +4682,21 @@ FROM root c
46824682
""");
46834683
}
46844684

4685+
public override async Task Compiler_generated_local_closure_produces_valid_parameter_name(bool async)
4686+
{
4687+
await base.Compiler_generated_local_closure_produces_valid_parameter_name(async);
4688+
4689+
AssertSql(
4690+
"""
4691+
@__customerId_0='ALFKI'
4692+
@__details_City_1='Berlin'
4693+
4694+
SELECT c
4695+
FROM root c
4696+
WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = @__customerId_0) AND (c["City"] = @__details_City_1)))
4697+
""");
4698+
}
4699+
46854700
private void AssertSql(params string[] expected)
46864701
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
46874702

test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,26 @@ public override Task List_from_result_of_single_result_2(bool async)
18401840
public override Task List_from_result_of_single_result_3(bool async)
18411841
=> base.List_from_result_of_single_result_3(async);
18421842

1843+
public override async Task Entity_passed_to_DTO_constructor_works(bool async)
1844+
{
1845+
await base.Entity_passed_to_DTO_constructor_works(async);
1846+
1847+
AssertSql(
1848+
"""
1849+
SELECT c
1850+
FROM root c
1851+
WHERE (c["Discriminator"] = "Customer")
1852+
""");
1853+
}
1854+
1855+
public override async Task Set_operation_in_pending_collection(bool async)
1856+
{
1857+
// Cosmos client evaluation. Issue #17246.
1858+
await AssertTranslationFailed(() => base.Set_operation_in_pending_collection(async));
1859+
1860+
AssertSql();
1861+
}
1862+
18431863
private void AssertSql(params string[] expected)
18441864
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
18451865

test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,6 +2995,80 @@ public override async Task EF_Parameter_with_non_evaluatable_argument_throws(boo
29952995
AssertSql();
29962996
}
29972997

2998+
public override async Task Implicit_cast_in_predicate(bool async)
2999+
{
3000+
await base.Implicit_cast_in_predicate(async);
3001+
3002+
AssertSql(
3003+
"""
3004+
SELECT c
3005+
FROM root c
3006+
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337"))
3007+
""",
3008+
//
3009+
"""
3010+
@__prm_Value_0='1337'
3011+
3012+
SELECT c
3013+
FROM root c
3014+
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__prm_Value_0))
3015+
""",
3016+
//
3017+
"""
3018+
@__ToString_0='1337'
3019+
3020+
SELECT c
3021+
FROM root c
3022+
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__ToString_0))
3023+
""",
3024+
//
3025+
"""
3026+
@__p_0='1337'
3027+
3028+
SELECT c
3029+
FROM root c
3030+
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__p_0))
3031+
""",
3032+
//
3033+
"""
3034+
SELECT c
3035+
FROM root c
3036+
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337"))
3037+
""");
3038+
}
3039+
3040+
public override async Task Interface_casting_though_generic_method(bool async)
3041+
{
3042+
await base.Interface_casting_though_generic_method(async);
3043+
3044+
AssertSql(
3045+
"""
3046+
@__id_0='10252'
3047+
3048+
SELECT VALUE {"Id" : c["OrderID"]}
3049+
FROM root c
3050+
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = @__id_0))
3051+
""",
3052+
//
3053+
"""
3054+
SELECT VALUE {"Id" : c["OrderID"]}
3055+
FROM root c
3056+
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
3057+
""",
3058+
//
3059+
"""
3060+
SELECT VALUE {"Id" : c["OrderID"]}
3061+
FROM root c
3062+
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
3063+
""",
3064+
//
3065+
"""
3066+
SELECT VALUE {"Id" : c["OrderID"]}
3067+
FROM root c
3068+
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
3069+
""");
3070+
}
3071+
29983072
private void AssertSql(params string[] expected)
29993073
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
30003074

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Microsoft.EntityFrameworkCore.Query;
55

6-
public class ManyToManyHeterogeneousQueryInMemoryTest : ManyToManyHeterogeneousQueryTestBase
6+
public class AdHocAdvancedMappingsQueryInMemoryTest : AdHocAdvancedMappingsQueryTestBase
77
{
88
protected override ITestStoreFactory TestStoreFactory
99
=> InMemoryTestStoreFactory.Instance;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.EntityFrameworkCore.Query;
5+
6+
public class AdHocManyToManyQueryInMemoryTest : AdHocManyToManyQueryTestBase
7+
{
8+
protected override ITestStoreFactory TestStoreFactory
9+
=> InMemoryTestStoreFactory.Instance;
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.EntityFrameworkCore.Query;
5+
6+
public class AdHocMiscellaneousQueryInMemoryTest : AdHocMiscellaneousQueryTestBase
7+
{
8+
protected override ITestStoreFactory TestStoreFactory
9+
=> InMemoryTestStoreFactory.Instance;
10+
11+
public override Task Explicitly_compiled_query_does_not_add_cache_entry()
12+
=> Task.CompletedTask;
13+
14+
public override Task Inlined_dbcontext_is_not_leaking()
15+
=> Task.CompletedTask;
16+
17+
public override Task Relational_command_cache_creates_new_entry_when_parameter_nullability_changes()
18+
=> Task.CompletedTask;
19+
20+
public override Task Variable_from_closure_is_parametrized()
21+
=> Task.CompletedTask;
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.EntityFrameworkCore.Query;
5+
6+
public class AdHocNavigationsQueryInMemoryTest : AdHocNavigationsQueryTestBase
7+
{
8+
protected override ITestStoreFactory TestStoreFactory
9+
=> InMemoryTestStoreFactory.Instance;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.EntityFrameworkCore.Query;
5+
6+
public class AdHocQueryFiltersQueryInMemoryTest : AdHocQueryFiltersQueryTestBase
7+
{
8+
protected override ITestStoreFactory TestStoreFactory
9+
=> InMemoryTestStoreFactory.Instance;
10+
}

test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ public override Task Join_with_result_selector_returning_queryable_throws_valida
1515
// Expression cannot be used for return type. Issue #23302.
1616
=> Assert.ThrowsAsync<ArgumentException>(
1717
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));
18+
19+
public override Task Correlated_projection_with_first(bool async)
20+
=> Task.CompletedTask;
1821
}

0 commit comments

Comments
 (0)