Skip to content

Commit

Permalink
Fix to #1015 - Remove QueryBugsTest class (#32542)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
maumar authored Dec 8, 2023
1 parent 5d88b84 commit d1124fa
Show file tree
Hide file tree
Showing 69 changed files with 14,770 additions and 13,704 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2237,14 +2237,16 @@ public override async Task Multiple_collection_navigation_with_FirstOrDefault_ch

public override async Task All_true(bool async)
{
await base.All_true(async);
// Aggregates. Issue #16146.
await AssertTranslationFailed(() => base.All_true(async));

AssertSql();
}

public override async Task Not_Any_false(bool async)
{
await base.Not_Any_false(async);
// Aggregates. Issue #16146.
await AssertTranslationFailed(() => base.Not_Any_false(async));

AssertSql();
}
Expand Down Expand Up @@ -2329,6 +2331,64 @@ FROM root c
""");
}

public override async Task Return_type_of_singular_operator_is_preserved(bool async)
{
await base.Return_type_of_singular_operator_is_preserved(async);

AssertSql(
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
OFFSET 0 LIMIT 1
""",
//
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
OFFSET 0 LIMIT 1
""",
//
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
OFFSET 0 LIMIT 2
""",
//
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI"))
OFFSET 0 LIMIT 2
""",
//
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A"))
ORDER BY c["CustomerID"] DESC
OFFSET 0 LIMIT 1
""",
//
"""
SELECT c["CustomerID"], c["City"]
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A"))
ORDER BY c["CustomerID"] DESC
OFFSET 0 LIMIT 1
""");
}

[ConditionalTheory(Skip = "Issue #20677")]
public override async Task Type_casting_inside_sum(bool async)
{
await base.Type_casting_inside_sum(async);

AssertSql();
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4682,6 +4682,21 @@ FROM root c
""");
}

public override async Task Compiler_generated_local_closure_produces_valid_parameter_name(bool async)
{
await base.Compiler_generated_local_closure_produces_valid_parameter_name(async);

AssertSql(
"""
@__customerId_0='ALFKI'
@__details_City_1='Berlin'

SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = @__customerId_0) AND (c["City"] = @__details_City_1)))
""");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,26 @@ public override Task List_from_result_of_single_result_2(bool async)
public override Task List_from_result_of_single_result_3(bool async)
=> base.List_from_result_of_single_result_3(async);

public override async Task Entity_passed_to_DTO_constructor_works(bool async)
{
await base.Entity_passed_to_DTO_constructor_works(async);

AssertSql(
"""
SELECT c
FROM root c
WHERE (c["Discriminator"] = "Customer")
""");
}

public override async Task Set_operation_in_pending_collection(bool async)
{
// Cosmos client evaluation. Issue #17246.
await AssertTranslationFailed(() => base.Set_operation_in_pending_collection(async));

AssertSql();
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,80 @@ public override async Task EF_Parameter_with_non_evaluatable_argument_throws(boo
AssertSql();
}

public override async Task Implicit_cast_in_predicate(bool async)
{
await base.Implicit_cast_in_predicate(async);

AssertSql(
"""
SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337"))
""",
//
"""
@__prm_Value_0='1337'

SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__prm_Value_0))
""",
//
"""
@__ToString_0='1337'

SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__ToString_0))
""",
//
"""
@__p_0='1337'

SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__p_0))
""",
//
"""
SELECT c
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337"))
""");
}

public override async Task Interface_casting_though_generic_method(bool async)
{
await base.Interface_casting_though_generic_method(async);

AssertSql(
"""
@__id_0='10252'

SELECT VALUE {"Id" : c["OrderID"]}
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = @__id_0))
""",
//
"""
SELECT VALUE {"Id" : c["OrderID"]}
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
""",
//
"""
SELECT VALUE {"Id" : c["OrderID"]}
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
""",
//
"""
SELECT VALUE {"Id" : c["OrderID"]}
FROM root c
WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252))
""");
}

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class ManyToManyHeterogeneousQueryInMemoryTest : ManyToManyHeterogeneousQueryTestBase
public class AdHocAdvancedMappingsQueryInMemoryTest : AdHocAdvancedMappingsQueryTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocManyToManyQueryInMemoryTest : AdHocManyToManyQueryTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocMiscellaneousQueryInMemoryTest : AdHocMiscellaneousQueryTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;

public override Task Explicitly_compiled_query_does_not_add_cache_entry()
=> Task.CompletedTask;

public override Task Inlined_dbcontext_is_not_leaking()
=> Task.CompletedTask;

public override Task Relational_command_cache_creates_new_entry_when_parameter_nullability_changes()
=> Task.CompletedTask;

public override Task Variable_from_closure_is_parametrized()
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocNavigationsQueryInMemoryTest : AdHocNavigationsQueryTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class AdHocQueryFiltersQueryInMemoryTest : AdHocQueryFiltersQueryTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> InMemoryTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ public override Task Join_with_result_selector_returning_queryable_throws_valida
// Expression cannot be used for return type. Issue #23302.
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));

public override Task Correlated_projection_with_first(bool async)
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ public override Task Join_with_result_selector_returning_queryable_throws_valida
// Expression cannot be used for return type. Issue #23302.
=> Assert.ThrowsAsync<ArgumentException>(
() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));

public override Task Correlated_projection_with_first(bool async)
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,21 @@ public override Task Where_compare_anonymous_types(bool async)

public override Task Subquery_inside_Take_argument(bool async)
=> Task.CompletedTask;

public override async Task Find_underlying_property_after_GroupJoin_DefaultIfEmpty(bool async)
=> Assert.Equal(
"Nullable object must have a value.",
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base
.Find_underlying_property_after_GroupJoin_DefaultIfEmpty(
async))).Message);

public override Task Join_include_coalesce_simple(bool async)
=> Task.CompletedTask;

public override Task Join_include_coalesce_nested(bool async)
=> Task.CompletedTask;

public override Task Join_include_conditional(bool async)
=> Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public MyContext(DbContextOptions options)
{
}

public DbSet<Warehouse> Warehouses { get; set; }

public void Seed()
{
Add(new Foo());
Expand Down

This file was deleted.

Loading

0 comments on commit d1124fa

Please sign in to comment.