@@ -62,12 +62,10 @@ public void OrderBy_ThenBy_OrdersByPrimaryThenSecondary()
6262 [ TestMethod ]
6363 public void OrderBy_String_RespectsCollationCaseInsensitive ( )
6464 {
65- using var context = new TestDbContext ( TestDbContext . CreatePeopleSimulation ( ) ) ;
66- context . People . AddRange (
65+ using var context = new TestDbContext ( TestDbContext . CreatePeopleSimulation ( ) ) . WithSaved (
6766 new Person { Id = 1 , Name = "B" } ,
6867 new Person { Id = 2 , Name = "a" } ,
6968 new Person { Id = 3 , Name = "C" } ) ;
70- _ = context . SaveChanges ( ) ;
7169
7270 // Default collation case-insensitive: 'a' sorts with 'A', so order is a, B, C.
7371 var names = context . People . OrderBy ( p => p . Name ) . Select ( p => p . Name ) . ToArray ( ) ;
@@ -133,13 +131,11 @@ public void Distinct_OnSingleColumn_RemovesDuplicates()
133131 [ TestMethod ]
134132 public void Distinct_OnMultiColumn_DedupesByTuple ( )
135133 {
136- using var context = new TestDbContext ( TestDbContext . CreatePeopleSimulation ( ) ) ;
137- context . People . AddRange (
134+ using var context = new TestDbContext ( TestDbContext . CreatePeopleSimulation ( ) ) . WithSaved (
138135 new Person { Id = 1 , Name = "Alice" , Code = "A" } ,
139136 new Person { Id = 2 , Name = "Alice" , Code = "A" } , // duplicate (Name, Code)
140137 new Person { Id = 3 , Name = "Alice" , Code = "B" } , // different Code
141138 new Person { Id = 4 , Name = "Bob" , Code = "A" } ) ;
142- _ = context . SaveChanges ( ) ;
143139
144140 var pairs = context . People
145141 . Select ( p => new { p . Name , p . Code } )
@@ -165,12 +161,10 @@ public async Task OrderBy_FirstAsync_ReturnsLowestKey()
165161 [ TestMethod ]
166162 public void OrderBy_DateTime_ReturnsChronologicalOrder ( )
167163 {
168- using var context = new TestDbContext ( TestDbContext . CreateEventsSimulation ( ) ) ;
169- context . Events . AddRange (
164+ using var context = new TestDbContext ( TestDbContext . CreateEventsSimulation ( ) ) . WithSaved (
170165 new Event { Id = 1 , CreatedAt = new DateTime ( 2026 , 5 , 4 ) } ,
171166 new Event { Id = 2 , CreatedAt = new DateTime ( 2024 , 1 , 15 ) } ,
172167 new Event { Id = 3 , CreatedAt = new DateTime ( 2025 , 7 , 22 ) } ) ;
173- _ = context . SaveChanges ( ) ;
174168
175169 var times = context . Events
176170 . OrderByDescending ( e => e . CreatedAt )
0 commit comments