Skip to content

Commit fe2254e

Browse files
committed
Remove ShouldNotBeNull and redundant With calls
1 parent f54403c commit fe2254e

File tree

141 files changed

+2073
-2068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2073
-2068
lines changed

test/DapperTests/IntegrationTests/AtomicOperations/AtomicOperationsTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ public async Task Can_use_multiple_operations()
170170

171171
responseDocument.Results.Should().HaveCount(7);
172172

173-
responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("people"));
174-
responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("people"));
175-
responseDocument.Results[2].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("tags"));
176-
responseDocument.Results[3].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("todoItems"));
173+
responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("people");
174+
responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("people");
175+
responseDocument.Results[2].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("tags");
176+
responseDocument.Results[3].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("todoItems");
177177
responseDocument.Results[4].Data.Value.Should().BeNull();
178-
responseDocument.Results[5].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("todoItems"));
178+
responseDocument.Results[5].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("todoItems");
179179
responseDocument.Results[6].Data.Value.Should().BeNull();
180180

181-
long newOwnerId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull());
182-
long newAssigneeId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull());
183-
long newTagId = long.Parse(responseDocument.Results[2].Data.SingleValue!.Id.ShouldNotBeNull());
184-
long newTodoItemId = long.Parse(responseDocument.Results[3].Data.SingleValue!.Id.ShouldNotBeNull());
181+
long newOwnerId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject);
182+
long newAssigneeId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject);
183+
long newTagId = long.Parse(responseDocument.Results[2].Data.SingleValue!.Id.Should().NotBeNull().And.Subject);
184+
long newTodoItemId = long.Parse(responseDocument.Results[3].Data.SingleValue!.Id.Should().NotBeNull().And.Subject);
185185

186186
await _testContext.RunOnDatabaseAsync(async dbContext =>
187187
{
@@ -203,7 +203,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
203203
todoItemInDatabase.CreatedAt.Should().Be(DapperTestContext.FrozenTime);
204204
todoItemInDatabase.LastModifiedAt.Should().Be(DapperTestContext.FrozenTime);
205205

206-
todoItemInDatabase.Owner.ShouldNotBeNull();
206+
todoItemInDatabase.Owner.Should().NotBeNull();
207207
todoItemInDatabase.Owner.Id.Should().Be(newOwnerId);
208208
todoItemInDatabase.Assignee.Should().BeNull();
209209
todoItemInDatabase.Tags.Should().HaveCount(1);
@@ -475,7 +475,7 @@ public async Task Can_rollback_on_error()
475475
error.StatusCode.Should().Be(HttpStatusCode.NotFound);
476476
error.Title.Should().Be("A related resource does not exist.");
477477
error.Detail.Should().Be($"Related resource of type 'todoItems' with ID '{unknownTodoItemId}' in relationship 'assignedTodoItems' does not exist.");
478-
error.Source.ShouldNotBeNull();
478+
error.Source.Should().NotBeNull();
479479
error.Source.Pointer.Should().Be("/atomic:operations[1]");
480480

481481
await _testContext.RunOnDatabaseAsync(async dbContext =>
@@ -509,7 +509,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
509509
"""));
510510

511511
command.Parameters.Should().HaveCount(1);
512-
command.Parameters.Should().ContainKey("@p1").WhoseValue.ShouldNotBeNull();
512+
command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull();
513513
});
514514

515515
store.SqlCommands[2].With(command =>
@@ -522,7 +522,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
522522
"""));
523523

524524
command.Parameters.Should().HaveCount(1);
525-
command.Parameters.Should().ContainKey("@p1").WhoseValue.ShouldNotBeNull();
525+
command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull();
526526
});
527527

528528
store.SqlCommands[3].With(command =>
@@ -534,7 +534,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
534534
"""));
535535

536536
command.Parameters.Should().HaveCount(2);
537-
command.Parameters.Should().ContainKey("@p1").WhoseValue.ShouldNotBeNull();
537+
command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull();
538538
command.Parameters.Should().Contain("@p2", unknownTodoItemId);
539539
});
540540

test/DapperTests/IntegrationTests/QueryStrings/IncludeTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
6262
{
6363
relationships.Should().ContainKey("owner").WhoseValue.With(value =>
6464
{
65-
value.ShouldNotBeNull();
66-
value.Data.SingleValue.ShouldNotBeNull();
65+
value.Should().NotBeNull();
66+
value.Data.SingleValue.Should().NotBeNull();
6767
value.Data.SingleValue.Type.Should().Be("people");
6868
value.Data.SingleValue.Id.Should().Be(todoItems[0].Owner.StringId);
6969
});
7070

7171
relationships.Should().ContainKey("assignee").WhoseValue.With(value =>
7272
{
73-
value.ShouldNotBeNull();
73+
value.Should().NotBeNull();
7474
value.Data.SingleValue.Should().BeNull();
7575
});
7676

7777
relationships.Should().ContainKey("tags").WhoseValue.With(value =>
7878
{
79-
value.ShouldNotBeNull();
79+
value.Should().NotBeNull();
8080
value.Data.ManyValue.Should().HaveCount(2);
8181
value.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags"));
8282
value.Data.ManyValue[0].Id.Should().Be(todoItems[0].Tags.ElementAt(0).StringId);
@@ -90,23 +90,23 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
9090
{
9191
relationships.Should().ContainKey("owner").WhoseValue.With(value =>
9292
{
93-
value.ShouldNotBeNull();
94-
value.Data.SingleValue.ShouldNotBeNull();
93+
value.Should().NotBeNull();
94+
value.Data.SingleValue.Should().NotBeNull();
9595
value.Data.SingleValue.Type.Should().Be("people");
9696
value.Data.SingleValue.Id.Should().Be(todoItems[1].Owner.StringId);
9797
});
9898

9999
relationships.Should().ContainKey("assignee").WhoseValue.With(value =>
100100
{
101-
value.ShouldNotBeNull();
102-
value.Data.SingleValue.ShouldNotBeNull();
101+
value.Should().NotBeNull();
102+
value.Data.SingleValue.Should().NotBeNull();
103103
value.Data.SingleValue.Type.Should().Be("people");
104104
value.Data.SingleValue.Id.Should().Be(todoItems[1].Assignee!.StringId);
105105
});
106106

107107
relationships.Should().ContainKey("tags").WhoseValue.With(value =>
108108
{
109-
value.ShouldNotBeNull();
109+
value.Should().NotBeNull();
110110
value.Data.ManyValue.Should().HaveCount(2);
111111
value.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags"));
112112
value.Data.ManyValue[0].Id.Should().Be(todoItems[1].Tags.ElementAt(0).StringId);

test/DapperTests/IntegrationTests/QueryStrings/SparseFieldSets.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
5151
responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems");
5252
responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.StringId);
5353
responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(2);
54-
responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.With(value => value.Should().Be(todoItem.Description));
55-
responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("durationInHours").WhoseValue.With(value => value.Should().Be(todoItem.DurationInHours));
54+
responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description);
55+
responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(todoItem.DurationInHours);
5656
responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(2);
5757

5858
responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("owner").WhoseValue.With(value =>
5959
{
60-
value.ShouldNotBeNull();
61-
value.Data.SingleValue.ShouldNotBeNull();
60+
value.Should().NotBeNull();
61+
value.Data.SingleValue.Should().NotBeNull();
6262
value.Data.SingleValue.Type.Should().Be("people");
6363
value.Data.SingleValue.Id.Should().Be(todoItem.Owner.StringId);
6464
});
6565

6666
responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("assignee").WhoseValue.With(value =>
6767
{
68-
value.ShouldNotBeNull();
69-
value.Data.SingleValue.ShouldNotBeNull();
68+
value.Should().NotBeNull();
69+
value.Data.SingleValue.Should().NotBeNull();
7070
value.Data.SingleValue.Type.Should().Be("people");
7171
value.Data.SingleValue.Id.Should().Be(todoItem.Assignee.StringId);
7272
});
@@ -76,12 +76,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7676

7777
responseDocument.Included[0].Id.Should().Be(todoItem.Owner.StringId);
7878
responseDocument.Included[0].Attributes.Should().HaveCount(1);
79-
responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.With(value => value.Should().Be(todoItem.Owner.LastName));
79+
responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItem.Owner.LastName);
8080
responseDocument.Included[0].Relationships.Should().BeNull();
8181

8282
responseDocument.Included[1].Id.Should().Be(todoItem.Assignee.StringId);
8383
responseDocument.Included[1].Attributes.Should().HaveCount(1);
84-
responseDocument.Included[1].Attributes.Should().ContainKey("lastName").WhoseValue.With(value => value.Should().Be(todoItem.Assignee.LastName));
84+
responseDocument.Included[1].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItem.Assignee.LastName);
8585
responseDocument.Included[1].Relationships.Should().BeNull();
8686

8787
store.SqlCommands.Should().HaveCount(2);
@@ -134,11 +134,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
134134
// Assert
135135
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
136136

137-
responseDocument.Data.SingleValue.ShouldNotBeNull();
137+
responseDocument.Data.SingleValue.Should().NotBeNull();
138138
responseDocument.Data.SingleValue.Type.Should().Be("todoItems");
139139
responseDocument.Data.SingleValue.Id.Should().Be(todoItem.StringId);
140140
responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1);
141-
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.With(value => value.Should().Be(todoItem.Description));
141+
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description);
142142
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
143143

144144
store.SqlCommands.Should().HaveCount(1);
@@ -189,7 +189,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
189189

190190
responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("color").WhoseValue.With(value =>
191191
{
192-
value.ShouldNotBeNull();
192+
value.Should().NotBeNull();
193193
value.Data.Value.Should().BeNull();
194194
});
195195

@@ -246,7 +246,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
246246
// Assert
247247
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
248248

249-
responseDocument.Data.SingleValue.ShouldNotBeNull();
249+
responseDocument.Data.SingleValue.Should().NotBeNull();
250250
responseDocument.Data.SingleValue.Type.Should().Be("people");
251251
responseDocument.Data.SingleValue.Id.Should().Be(person.StringId);
252252
responseDocument.Data.SingleValue.Attributes.Should().BeNull();
@@ -290,7 +290,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
290290
// Assert
291291
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
292292

293-
responseDocument.Data.SingleValue.ShouldNotBeNull();
293+
responseDocument.Data.SingleValue.Should().NotBeNull();
294294
responseDocument.Data.SingleValue.Type.Should().Be("people");
295295
responseDocument.Data.SingleValue.Id.Should().Be(person.StringId);
296296
responseDocument.Data.SingleValue.Attributes.Should().BeNull();
@@ -334,11 +334,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
334334
// Assert
335335
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
336336

337-
responseDocument.Data.SingleValue.ShouldNotBeNull();
337+
responseDocument.Data.SingleValue.Should().NotBeNull();
338338
responseDocument.Data.SingleValue.Type.Should().Be("people");
339339
responseDocument.Data.SingleValue.Id.Should().Be(person.StringId);
340340
responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1);
341-
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.With(value => value.Should().Be(person.DisplayName));
341+
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(person.DisplayName);
342342
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
343343

344344
store.SqlCommands.Should().HaveCount(1);
@@ -381,11 +381,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
381381
// Assert
382382
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
383383

384-
responseDocument.Data.SingleValue.ShouldNotBeNull();
384+
responseDocument.Data.SingleValue.Should().NotBeNull();
385385
responseDocument.Data.SingleValue.Type.Should().Be("todoItems");
386386
responseDocument.Data.SingleValue.Id.Should().Be(todoItem.StringId);
387387
responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1);
388-
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.With(value => value.Should().Be(todoItem.Description));
388+
responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description);
389389
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
390390

391391
responseDocument.Included.Should().HaveCount(2);

test/DapperTests/IntegrationTests/ReadWrite/Relationships/FetchRelationshipTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
4646
// Assert
4747
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
4848

49-
responseDocument.Data.SingleValue.ShouldNotBeNull();
49+
responseDocument.Data.SingleValue.Should().NotBeNull();
5050
responseDocument.Data.SingleValue.Type.Should().Be("people");
5151
responseDocument.Data.SingleValue.Id.Should().Be(todoItem.Owner.StringId);
5252

test/DapperTests/IntegrationTests/ReadWrite/Relationships/UpdateToOneRelationshipTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
475475
{
476476
Person personInDatabase = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson.Id);
477477

478-
personInDatabase.Account.ShouldNotBeNull();
478+
personInDatabase.Account.Should().NotBeNull();
479479
personInDatabase.Account.Id.Should().Be(existingLoginAccount.Id);
480480
});
481481

@@ -562,7 +562,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
562562
LoginAccount loginAccountInDatabase =
563563
await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Person).FirstWithIdAsync(existingLoginAccount.Id);
564564

565-
loginAccountInDatabase.Person.ShouldNotBeNull();
565+
loginAccountInDatabase.Person.Should().NotBeNull();
566566
loginAccountInDatabase.Person.Id.Should().Be(existingPerson.Id);
567567
});
568568

@@ -635,7 +635,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
635635
{
636636
TodoItem todoItemInDatabase = await dbContext.TodoItems.Include(todoItem => todoItem.Assignee).FirstWithIdAsync(existingTodoItem.Id);
637637

638-
todoItemInDatabase.Assignee.ShouldNotBeNull();
638+
todoItemInDatabase.Assignee.Should().NotBeNull();
639639
todoItemInDatabase.Assignee.Id.Should().Be(existingPerson.Id);
640640
});
641641

@@ -711,7 +711,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
711711
{
712712
Person personInDatabase1 = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson1.Id);
713713

714-
personInDatabase1.Account.ShouldNotBeNull();
714+
personInDatabase1.Account.Should().NotBeNull();
715715
personInDatabase1.Account.Id.Should().Be(existingPerson2.Account.Id);
716716

717717
Person personInDatabase2 = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson2.Id);
@@ -805,7 +805,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
805805
LoginAccount loginAccountInDatabase1 =
806806
await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Person).FirstWithIdAsync(existingLoginAccount1.Id);
807807

808-
loginAccountInDatabase1.Person.ShouldNotBeNull();
808+
loginAccountInDatabase1.Person.Should().NotBeNull();
809809
loginAccountInDatabase1.Person.Id.Should().Be(existingLoginAccount2.Person.Id);
810810

811811
LoginAccount loginAccountInDatabase2 =
@@ -898,7 +898,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
898898
LoginAccount loginAccountInDatabase1 =
899899
await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Recovery).FirstWithIdAsync(existingLoginAccount1.Id);
900900

901-
loginAccountInDatabase1.Recovery.ShouldNotBeNull();
901+
loginAccountInDatabase1.Recovery.Should().NotBeNull();
902902
loginAccountInDatabase1.Recovery.Id.Should().Be(existingLoginAccount2.Recovery.Id);
903903

904904
LoginAccount? loginAccountInDatabase2 = await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Recovery)
@@ -989,7 +989,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
989989
AccountRecovery accountRecoveryInDatabase1 =
990990
await dbContext.AccountRecoveries.Include(recovery => recovery.Account).FirstWithIdAsync(existingAccountRecovery1.Id);
991991

992-
accountRecoveryInDatabase1.Account.ShouldNotBeNull();
992+
accountRecoveryInDatabase1.Account.Should().NotBeNull();
993993
accountRecoveryInDatabase1.Account.Id.Should().Be(existingAccountRecovery2.Account.Id);
994994

995995
AccountRecovery accountRecoveryInDatabase2 =
@@ -1081,7 +1081,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
10811081
{
10821082
TodoItem todoItemInDatabase1 = await dbContext.TodoItems.Include(todoItem => todoItem.Assignee).FirstWithIdAsync(existingTodoItem1.Id);
10831083

1084-
todoItemInDatabase1.Assignee.ShouldNotBeNull();
1084+
todoItemInDatabase1.Assignee.Should().NotBeNull();
10851085
todoItemInDatabase1.Assignee.Id.Should().Be(existingTodoItem2.Assignee.Id);
10861086
});
10871087

@@ -1155,7 +1155,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
11551155
{
11561156
TodoItem todoItemInDatabase1 = await dbContext.TodoItems.Include(todoItem => todoItem.Owner).FirstWithIdAsync(existingTodoItem1.Id);
11571157

1158-
todoItemInDatabase1.Owner.ShouldNotBeNull();
1158+
todoItemInDatabase1.Owner.Should().NotBeNull();
11591159
todoItemInDatabase1.Owner.Id.Should().Be(existingTodoItem2.Owner.Id);
11601160
});
11611161

0 commit comments

Comments
 (0)