Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to #21049 - Test: Consider adding Include tests with smaller datasets #23637

Merged
merged 1 commit into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public override async Task Where_math_abs_uncorrelated(bool async)
AssertSql(
@"SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""OrderDetail"") AND (10 < c[""ProductID""]))");
WHERE (((c[""Discriminator""] = ""OrderDetail"") AND (c[""UnitPrice""] < 7.0)) AND (10 < c[""ProductID""]))");
}

[ConditionalTheory(Skip = "Issue #17246")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,92 @@ public virtual Task Multiple_complex_includes_self_ref(bool async)
elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_reference_and_collection_order_by(bool async)
{
var expectedIncludes = new IExpectedInclude[]
{
new ExpectedInclude<Level1>(l1 => l1.OneToOne_Optional_FK1),
new ExpectedInclude<Level2>(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"),
};

return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(e => e.OneToOne_Optional_FK1.OneToMany_Optional2)
.OrderBy(e => e.Name),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_reference_ThenInclude_collection_order_by(bool async)
{
var expectedIncludes = new IExpectedInclude[]
{
new ExpectedInclude<Level1>(l1 => l1.OneToOne_Optional_FK1),
new ExpectedInclude<Level2>(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"),
};

return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(e => e.OneToOne_Optional_FK1)
.ThenInclude(e => e.OneToMany_Optional2)
.OrderBy(e => e.Name),
assertOrder: true,
elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_collection_then_reference(bool async)
{
var expectedIncludes = new IExpectedInclude[]
{
new ExpectedInclude<Level1>(l1 => l1.OneToMany_Optional1),
new ExpectedInclude<Level2>(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1"),
};

return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(e => e.OneToMany_Optional1)
.ThenInclude(e => e.OneToOne_Optional_FK2),
elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_reference_and_project_into_anonymous_type(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Level1>().Include(e => e.OneToOne_Optional_FK1).Select(e => new { e.Id, entity = e }),
elementSorter: e => e.Id,
elementAsserter: (e, a) =>
{
AssertInclude(e.entity, a.entity, new ExpectedInclude<Level1>(ee => ee.OneToOne_Optional_FK1));
AssertEqual(e.Id, a.Id);
});
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Include_collection_with_conditional_order_by(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Level1>()
.Include(e => e.OneToMany_Optional1)
.OrderBy(e => e.Name.EndsWith("03") ? 1 : 2)
.Select(e => e),
elementSorter: e => e.Id,
elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude<Level1>(ee => ee.OneToMany_Optional1)));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Multiple_complex_include_select(bool async)
Expand All @@ -753,10 +839,8 @@ public virtual Task Multiple_complex_include_select(bool async)
return AssertQuery(
async,
ss => ss.Set<Level1>()
.Select(e => e)
.Include(e => e.OneToOne_Optional_FK1)
.ThenInclude(e => e.OneToMany_Optional2)
.Select(e => e)
.Include(e => e.OneToMany_Optional1)
.ThenInclude(e => e.OneToOne_Optional_FK2),
elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,9 @@ public virtual Task Where_math_abs1(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Abs(od.ProductID) > 10),
entryCount: 1939);
ss => ss.Set<Product>()
.Where(od => Math.Abs(od.ProductID) > 10),
entryCount: 67);
}

[ConditionalTheory]
Expand All @@ -759,8 +760,10 @@ public virtual Task Where_math_abs2(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Abs(od.Quantity) > 10),
entryCount: 1547);
ss => ss.Set<OrderDetail>()
.Where(od => od.UnitPrice < 7)
.Where(od => Math.Abs(od.Quantity) > 10),
entryCount: 102);
}

[ConditionalTheory]
Expand All @@ -769,8 +772,10 @@ public virtual Task Where_math_abs3(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Abs(od.UnitPrice) > 10),
entryCount: 1677);
ss => ss.Set<OrderDetail>()
.Where(od => od.Quantity < 5)
.Where(od => Math.Abs(od.UnitPrice) > 10),
entryCount: 137);
}

[ConditionalTheory]
Expand All @@ -779,8 +784,10 @@ public virtual Task Where_math_abs_uncorrelated(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Abs(-10) < od.ProductID),
entryCount: 1939);
ss => ss.Set<OrderDetail>()
.Where(od => od.UnitPrice < 7)
.Where(od => Math.Abs(-10) < od.ProductID),
entryCount: 154);
}

[ConditionalTheory]
Expand All @@ -789,8 +796,10 @@ public virtual Task Where_math_ceiling1(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Ceiling(od.Discount) > 0),
entryCount: 838);
ss => ss.Set<OrderDetail>()
.Where(od => od.UnitPrice < 7)
.Where(od => Math.Ceiling(od.Discount) > 0),
entryCount: 51);
}

[ConditionalTheory]
Expand All @@ -799,8 +808,10 @@ public virtual Task Where_math_ceiling2(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Ceiling(od.UnitPrice) > 10),
entryCount: 1677);
ss => ss.Set<OrderDetail>()
.Where(od => od.Quantity < 5)
.Where(od => Math.Ceiling(od.UnitPrice) > 10),
entryCount: 137);
}

[ConditionalTheory]
Expand All @@ -809,8 +820,10 @@ public virtual Task Where_math_floor(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Floor(od.UnitPrice) > 10),
entryCount: 1658);
ss => ss.Set<OrderDetail>()
.Where(od => od.Quantity < 5)
.Where(od => Math.Floor(od.UnitPrice) > 10),
entryCount: 137);
}

[ConditionalTheory]
Expand All @@ -829,8 +842,10 @@ public virtual Task Where_math_round(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Round(od.UnitPrice) > 10),
entryCount: 1662);
ss => ss.Set<OrderDetail>()
.Where(od => od.Quantity < 5)
.Where(od => Math.Round(od.UnitPrice) > 10),
entryCount: 137);
}

[ConditionalTheory]
Expand Down Expand Up @@ -873,8 +888,10 @@ public virtual Task Where_math_truncate(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Math.Truncate(od.UnitPrice) > 10),
entryCount: 1658);
ss => ss.Set<OrderDetail>()
.Where(od => od.Quantity < 5)
.Where(od => Math.Truncate(od.UnitPrice) > 10),
entryCount: 137);
}

[ConditionalTheory]
Expand Down Expand Up @@ -1034,8 +1051,9 @@ public virtual Task Where_guid_newguid(bool async)
{
return AssertQuery(
async,
ss => ss.Set<OrderDetail>().Where(od => Guid.NewGuid() != default),
entryCount: 2155);
ss => ss.Set<Customer>()
.Where(od => Guid.NewGuid() != default),
entryCount: 91);
}

[ConditionalTheory]
Expand Down
Loading