Skip to content

Commit

Permalink
Add regression test for issue#8999
Browse files Browse the repository at this point in the history
Close #8999
  • Loading branch information
smitpatel committed Sep 9, 2019
1 parent 6d6fbc5 commit cce9a7e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,5 +865,17 @@ public override Task Project_non_nullable_value_after_FirstOrDefault_on_empty_co
{
return base.Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(isAsync);
}

[ConditionalTheory(Skip = "Issue#17246")]
public override Task Filtered_collection_projection_is_tracked(bool isAsync)
{
return base.Filtered_collection_projection_is_tracked(isAsync);
}

[ConditionalTheory(Skip = "Issue#17246")]
public override Task Filtered_collection_projection_with_to_list_is_tracked(bool isAsync)
{
return base.Filtered_collection_projection_with_to_list_is_tracked(isAsync);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1258,5 +1258,55 @@ public override bool Equals(object obj)

public override int GetHashCode() => HashCode.Combine(Id, City);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Filtered_collection_projection_is_tracked(bool isAsync)
{
using (var context = CreateContext())
{
var query = context.Customers
.Where(c => c.CustomerID.StartsWith("A"))
.Select(c =>
new
{
Customer = c,
FilteredOrders = c.Orders.Where(o => o.OrderID > 11000)
});

var result = isAsync
? (await query.ToListAsync())
: query.ToList();

Assert.Equal(4, result.Count);
Assert.True(result.All(r => (r.Customer.Orders?.Count ?? 0) == r.FilteredOrders.Count()));
Assert.Equal(6, context.ChangeTracker.Entries().Count());
}
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Filtered_collection_projection_with_to_list_is_tracked(bool isAsync)
{
using (var context = CreateContext())
{
var query = context.Customers
.Where(c => c.CustomerID.StartsWith("A"))
.Select(c =>
new
{
Customer = c,
FilteredOrders = c.Orders.Where(o => o.OrderID > 11000).ToList()
});

var result = isAsync
? (await query.ToListAsync())
: query.ToList();

Assert.Equal(4, result.Count);
Assert.True(result.All(r => (r.Customer.Orders?.Count ?? 0) == r.FilteredOrders.Count));
Assert.Equal(6, context.ChangeTracker.Entries().Count());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1033,5 +1033,37 @@ public override async Task Member_binding_after_ctor_arguments_fails_with_client
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(isAsync))).Message));
}

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

AssertSql(
@"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate]
FROM [Customers] AS [c]
LEFT JOIN (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
FROM [Orders] AS [o]
WHERE [o].[OrderID] > 11000
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE [c].[CustomerID] LIKE N'A%'
ORDER BY [c].[CustomerID], [t].[OrderID]");
}

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

AssertSql(
@"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate]
FROM [Customers] AS [c]
LEFT JOIN (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
FROM [Orders] AS [o]
WHERE [o].[OrderID] > 11000
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE [c].[CustomerID] LIKE N'A%'
ORDER BY [c].[CustomerID], [t].[OrderID]");
}
}
}

0 comments on commit cce9a7e

Please sign in to comment.