Skip to content

Commit fa95483

Browse files
committed
Fix to #25834 - Query/Test: northwind tests don't have predefined entity asserters
Also minor test fixes that were found as a result of fixing this. Fixes #25834
1 parent 7912a3a commit fa95483

File tree

5 files changed

+180
-2
lines changed

5 files changed

+180
-2
lines changed

test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,23 @@ public IReadOnlyDictionary<Type, object> GetEntityAsserters()
338338
}
339339
}
340340
},
341+
{
342+
typeof(NestedReferenceDerived), (e, a) =>
343+
{
344+
Assert.Equal(e == null, a == null);
345+
346+
if (a != null)
347+
{
348+
var ee = (NestedReferenceDerived)e;
349+
var aa = (NestedReferenceDerived)a;
350+
351+
Assert.Equal(ee.Id, aa.Id);
352+
Assert.Equal(ee.Name, aa.Name);
353+
Assert.Equal(ee.ParentReferenceId, aa.ParentReferenceId);
354+
Assert.Equal(ee.ParentCollectionId, aa.ParentCollectionId);
355+
}
356+
}
357+
},
341358
{
342359
typeof(NonEntityBase), (e, a) =>
343360
{

test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.EntityFrameworkCore.Infrastructure;
1010
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
1111
using Microsoft.EntityFrameworkCore.TestUtilities;
12+
using Xunit;
1213

1314
namespace Microsoft.EntityFrameworkCore.Query
1415
{
@@ -90,7 +91,150 @@ public IReadOnlyDictionary<Type, object> GetEntitySorters()
9091
}.ToDictionary(e => e.Key, e => (object)e.Value);
9192

9293
public IReadOnlyDictionary<Type, object> GetEntityAsserters()
93-
=> null;
94+
=> new Dictionary<Type, Action<object, object>>
95+
{
96+
{
97+
typeof(Customer), (e, a) =>
98+
{
99+
Assert.Equal(e == null, a == null);
100+
101+
if (a != null)
102+
{
103+
var ee = (Customer)e;
104+
var aa = (Customer)a;
105+
106+
Assert.Equal(ee.CustomerID, aa.CustomerID);
107+
Assert.Equal(ee.Address, aa.Address);
108+
Assert.Equal(ee.CompanyName, aa.CompanyName);
109+
Assert.Equal(ee.ContactName, aa.ContactName);
110+
Assert.Equal(ee.ContactTitle, aa.ContactTitle);
111+
Assert.Equal(ee.Country, aa.Country);
112+
Assert.Equal(ee.Fax, aa.Fax);
113+
Assert.Equal(ee.Phone, aa.Phone);
114+
Assert.Equal(ee.PostalCode, aa.PostalCode);
115+
}
116+
}
117+
},
118+
{
119+
typeof(CustomerQuery), (e, a) =>
120+
{
121+
Assert.Equal(e == null, a == null);
122+
123+
if (a != null)
124+
{
125+
var ee = (CustomerQuery)e;
126+
var aa = (CustomerQuery)a;
127+
128+
Assert.Equal(ee.CompanyName, aa.CompanyName);
129+
Assert.Equal(ee.Address, aa.Address);
130+
Assert.Equal(ee.City, aa.City);
131+
Assert.Equal(ee.ContactName, aa.ContactName);
132+
Assert.Equal(ee.ContactTitle, aa.ContactTitle);
133+
}
134+
}
135+
},
136+
{
137+
typeof(Order), (e, a) =>
138+
{
139+
Assert.Equal(e == null, a == null);
140+
141+
if (a != null)
142+
{
143+
var ee = (Order)e;
144+
var aa = (Order)a;
145+
146+
Assert.Equal(ee.OrderID, aa.OrderID);
147+
Assert.Equal(ee.CustomerID, aa.CustomerID);
148+
Assert.Equal(ee.EmployeeID, aa.EmployeeID);
149+
Assert.Equal(ee.OrderDate, aa.OrderDate);
150+
}
151+
}
152+
},
153+
{
154+
typeof(OrderQuery), (e, a) =>
155+
{
156+
Assert.Equal(e == null, a == null);
157+
158+
if (a != null)
159+
{
160+
var ee = (OrderQuery)e;
161+
var aa = (OrderQuery)a;
162+
163+
Assert.Equal(ee.CustomerID, aa.CustomerID);
164+
}
165+
}
166+
},
167+
{
168+
typeof(Employee), (e, a) =>
169+
{
170+
Assert.Equal(e == null, a == null);
171+
172+
if (a != null)
173+
{
174+
var ee = (Employee)e;
175+
var aa = (Employee)a;
176+
177+
Assert.Equal(ee.EmployeeID, aa.EmployeeID);
178+
Assert.Equal(ee.Title, aa.Title);
179+
Assert.Equal(ee.City, aa.City);
180+
Assert.Equal(ee.Country, aa.Country);
181+
Assert.Equal(ee.FirstName, aa.FirstName);
182+
}
183+
}
184+
},
185+
{
186+
typeof(Product), (e, a) =>
187+
{
188+
Assert.Equal(e == null, a == null);
189+
190+
if (a != null)
191+
{
192+
var ee = (Product)e;
193+
var aa = (Product)a;
194+
195+
Assert.Equal(ee.ProductID, aa.ProductID);
196+
Assert.Equal(ee.ProductName, aa.ProductName);
197+
Assert.Equal(ee.SupplierID, aa.SupplierID);
198+
Assert.Equal(ee.UnitPrice, aa.UnitPrice);
199+
Assert.Equal(ee.UnitsInStock, aa.UnitsInStock);
200+
}
201+
}
202+
},
203+
{
204+
typeof(ProductQuery), (e, a) =>
205+
{
206+
Assert.Equal(e == null, a == null);
207+
208+
if (a != null)
209+
{
210+
var ee = (ProductQuery)e;
211+
var aa = (ProductQuery)a;
212+
213+
Assert.Equal(ee.ProductID, aa.ProductID);
214+
Assert.Equal(ee.CategoryName, aa.CategoryName);
215+
Assert.Equal(ee.ProductName, aa.ProductName);
216+
}
217+
}
218+
},
219+
{
220+
typeof(OrderDetail), (e, a) =>
221+
{
222+
Assert.Equal(e == null, a == null);
223+
224+
if (a != null)
225+
{
226+
var ee = (OrderDetail)e;
227+
var aa = (OrderDetail)a;
228+
229+
Assert.Equal(ee.OrderID, aa.OrderID);
230+
Assert.Equal(ee.ProductID, aa.ProductID);
231+
Assert.Equal(ee.Quantity, aa.Quantity);
232+
Assert.Equal(ee.UnitPrice, aa.UnitPrice);
233+
Assert.Equal(ee.Discount, aa.Discount);
234+
}
235+
}
236+
},
237+
}.ToDictionary(e => e.Key, e => (object)e.Value);
94238

95239
protected override string StoreName { get; } = "Northwind";
96240

test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ public virtual Task Collection_include_over_result_of_single_non_scalar(bool asy
22402240
elementSorter: e => e.c.CustomerID,
22412241
elementAsserter: (e, a) =>
22422242
{
2243-
AssertInclude(e, a,
2243+
AssertInclude(e.c, a.c,
22442244
new ExpectedInclude<Customer>(c => c.Orders),
22452245
new ExpectedInclude<Order>(o => o.OrderDetails, "Orders"));
22462246
AssertInclude(e.SingleOrder, a.SingleOrder, new ExpectedInclude<Order>(o => o.OrderDetails));

test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,10 @@ private void AssertIncludeEntity<TElement>(TElement expected, TElement actual, I
16981698
((Action<TElement, TElement>)asserter)(expected, actual);
16991699
ProcessIncludes(expected, actual, expectedIncludes);
17001700
}
1701+
else
1702+
{
1703+
throw new InvalidOperationException($"Couldn't find entity asserter for entity type: '{typeof(TElement).Name}'.");
1704+
}
17011705
}
17021706

17031707
private void AssertIncludeCollection<TElement>(

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.EntityFrameworkCore.TestUtilities;
5+
using Xunit;
56
using Xunit.Abstractions;
67

78
namespace Microsoft.EntityFrameworkCore.Query
@@ -18,5 +19,17 @@ public NorthwindSplitIncludeNoTrackingQuerySqlServerTest(
1819
Fixture.TestSqlLoggerFactory.Clear();
1920
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
2021
}
22+
23+
[ConditionalTheory(Skip = "Issue#21202")]
24+
public override async Task Include_collection_skip_take_no_order_by(bool async)
25+
{
26+
await base.Include_collection_skip_take_no_order_by(async);
27+
}
28+
29+
[ConditionalTheory(Skip = "Issue#21202")]
30+
public override async Task Include_collection_skip_no_order_by(bool async)
31+
{
32+
await base.Include_collection_skip_no_order_by(async);
33+
}
2134
}
2235
}

0 commit comments

Comments
 (0)