Skip to content

Commit b20fc70

Browse files
committed
Remove usages of ShouldNotBeNull and redundant With calls
1 parent 82c48a2 commit b20fc70

Some content is hidden

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

43 files changed

+299
-304
lines changed

test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ public async Task Can_create_resource_with_attributes()
6161
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
6262

6363
// Assert
64-
response.ShouldNotBeNull();
64+
response.Should().NotBeNull();
6565

6666
response.AtomicResults.Should().HaveCount(1);
6767
TeacherDataInResponse teacherDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<TeacherDataInResponse>().Which;
6868

69-
teacherDataInResponse.Attributes.ShouldNotBeNull();
69+
teacherDataInResponse.Attributes.Should().NotBeNull();
7070
teacherDataInResponse.Attributes.Name.Should().Be(newTeacher.Name);
7171
teacherDataInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress);
7272

@@ -140,12 +140,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
140140
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
141141

142142
// Assert
143-
response.ShouldNotBeNull();
143+
response.Should().NotBeNull();
144144

145145
response.AtomicResults.Should().HaveCount(1);
146146
EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<EnrollmentDataInResponse>().Which;
147147

148-
enrollmentDataInResponse.Attributes.ShouldNotBeNull();
148+
enrollmentDataInResponse.Attributes.Should().NotBeNull();
149149
enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrollment.EnrolledAt);
150150
enrollmentDataInResponse.Attributes.GraduatedAt.Should().BeNull();
151151
enrollmentDataInResponse.Attributes.HasGraduated.Should().BeFalse();

test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ public async Task Can_use_local_IDs()
172172
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
173173

174174
// Assert
175-
response.ShouldNotBeNull();
175+
response.Should().NotBeNull();
176176

177177
response.AtomicResults.Should().HaveCount(7);
178178

179179
TeacherDataInResponse teacherInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<TeacherDataInResponse>().Which;
180-
teacherInResponse.Attributes.ShouldNotBeNull();
180+
teacherInResponse.Attributes.Should().NotBeNull();
181181
teacherInResponse.Attributes.Name.Should().Be(newTeacher.Name);
182182
teacherInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress);
183183
long newTeacherId = long.Parse(teacherInResponse.Id!);
@@ -186,13 +186,13 @@ public async Task Can_use_local_IDs()
186186
response.AtomicResults.ElementAt(2).Data.Should().BeNull();
187187

188188
StudentDataInResponse studentInResponse = response.AtomicResults.ElementAt(3).Data.Should().BeOfType<StudentDataInResponse>().Which;
189-
studentInResponse.Attributes.ShouldNotBeNull();
189+
studentInResponse.Attributes.Should().NotBeNull();
190190
studentInResponse.Attributes.Name.Should().Be(newStudent.Name);
191191
studentInResponse.Attributes.EmailAddress.Should().Be(newStudent.EmailAddress);
192192
long newStudentId = long.Parse(studentInResponse.Id!);
193193

194194
EnrollmentDataInResponse enrollmentInResponse = response.AtomicResults.ElementAt(4).Data.Should().BeOfType<EnrollmentDataInResponse>().Which;
195-
enrollmentInResponse.Attributes.ShouldNotBeNull();
195+
enrollmentInResponse.Attributes.Should().NotBeNull();
196196
enrollmentInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrolledAt);
197197
long newEnrollmentId = long.Parse(enrollmentInResponse.Id!);
198198

@@ -226,7 +226,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
226226
// @formatter:wrap_chained_method_calls restore
227227

228228
enrollmentInDatabase.EnrolledAt.Should().Be(newEnrolledAt);
229-
enrollmentInDatabase.Course.ShouldNotBeNull();
229+
enrollmentInDatabase.Course.Should().NotBeNull();
230230
enrollmentInDatabase.Course.Id.Should().Be(newCourse.Id);
231231
enrollmentInDatabase.Student.Id.Should().Be(newStudentId);
232232
});

test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7979
{
8080
Enrollment enrollmentInDatabase = await dbContext.Enrollments.Include(enrollment => enrollment.Student).FirstWithIdAsync(existingEnrollment.Id);
8181

82-
enrollmentInDatabase.Student.ShouldNotBeNull();
82+
enrollmentInDatabase.Student.Should().NotBeNull();
8383
enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id);
8484
});
8585
}

test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
7575
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
7676

7777
// Assert
78-
response.ShouldNotBeNull();
78+
response.Should().NotBeNull();
7979

8080
response.AtomicResults.Should().HaveCount(1);
8181
StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<StudentDataInResponse>().Which;
8282

8383
studentDataInResponse.Id.Should().Be(existingStudent.StringId);
84-
studentDataInResponse.Attributes.ShouldNotBeNull();
84+
studentDataInResponse.Attributes.Should().NotBeNull();
8585
studentDataInResponse.Attributes.Name.Should().Be(newName);
8686
studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress);
8787

@@ -139,13 +139,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
139139
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
140140

141141
// Assert
142-
response.ShouldNotBeNull();
142+
response.Should().NotBeNull();
143143

144144
response.AtomicResults.Should().HaveCount(1);
145145
StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<StudentDataInResponse>().Which;
146146

147147
studentDataInResponse.Id.Should().Be(existingStudent.StringId);
148-
studentDataInResponse.Attributes.ShouldNotBeNull();
148+
studentDataInResponse.Attributes.Should().NotBeNull();
149149
studentDataInResponse.Attributes.Name.Should().Be(existingStudent.Name);
150150
studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress);
151151

@@ -222,13 +222,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
222222
OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody);
223223

224224
// Assert
225-
response.ShouldNotBeNull();
225+
response.Should().NotBeNull();
226226

227227
response.AtomicResults.Should().HaveCount(1);
228228
EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType<EnrollmentDataInResponse>().Which;
229229

230230
enrollmentDataInResponse.Id.Should().Be(existingEnrollment.StringId);
231-
enrollmentDataInResponse.Attributes.ShouldNotBeNull();
231+
enrollmentDataInResponse.Attributes.Should().NotBeNull();
232232
enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrolledAt);
233233
enrollmentDataInResponse.Attributes.GraduatedAt.Should().Be((Date)existingEnrollment.GraduatedAt!.Value);
234234
enrollmentDataInResponse.Attributes.HasGraduated.Should().Be(existingEnrollment.HasGraduated);
@@ -250,10 +250,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
250250
enrollmentInDatabase.GraduatedAt.Should().Be(existingEnrollment.GraduatedAt);
251251
enrollmentInDatabase.HasGraduated.Should().Be(existingEnrollment.HasGraduated);
252252

253-
enrollmentInDatabase.Student.ShouldNotBeNull();
253+
enrollmentInDatabase.Student.Should().NotBeNull();
254254
enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id);
255255

256-
enrollmentInDatabase.Course.ShouldNotBeNull();
256+
enrollmentInDatabase.Course.Should().NotBeNull();
257257
enrollmentInDatabase.Course.Id.Should().Be(existingCourse.Id);
258258
});
259259
}

test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require
6363
error.Status.Should().Be("422");
6464
error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required.");
6565
error.Detail.Should().BeNull();
66-
error.Source.ShouldNotBeNull();
66+
error.Source.Should().NotBeNull();
6767
error.Source.Pointer.Should().Be("/data");
6868
}
6969

@@ -130,9 +130,9 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_allowed()
130130
GamePrimaryResponseDocument? document = await apiClient.Games.PostAsync(requestBody);
131131

132132
// Assert
133-
document.ShouldNotBeNull();
134-
document.Data.ShouldNotBeNull();
135-
document.Data.Id.ShouldNotBeNull();
133+
document.Should().NotBeNull();
134+
document.Data.Should().NotBeNull();
135+
document.Data.Id.Should().NotBeNull();
136136
document.Data.Id.Value.Should().NotBe(Guid.Empty);
137137

138138
await _testContext.RunOnDatabaseAsync(async dbContext =>
@@ -252,8 +252,8 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden(
252252
PlayerGroupPrimaryResponseDocument? document = await apiClient.PlayerGroups.PostAsync(requestBody);
253253

254254
// Assert
255-
document.ShouldNotBeNull();
256-
document.Data.ShouldNotBeNull();
255+
document.Should().NotBeNull();
256+
document.Data.Should().NotBeNull();
257257
document.Data.Id.Should().NotBeNullOrEmpty();
258258

259259
long newPlayerGroupId = long.Parse(document.Data.Id);

test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
8383
CountryCollectionResponseDocument? response = await apiClient.Countries.GetAsync(configuration => configuration.Options.Add(headerInspector));
8484

8585
// Assert
86-
response.ShouldNotBeNull();
86+
response.Should().NotBeNull();
8787

8888
string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray();
8989
eTagHeaderValues.Should().HaveCount(1);
@@ -153,7 +153,7 @@ public async Task Returns_no_ETag_for_POST_request()
153153
await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector));
154154

155155
// Assert
156-
response.ShouldNotBeNull();
156+
response.Should().NotBeNull();
157157

158158
headerInspector.ResponseHeaders.Should().NotContainKey(HeaderNames.ETag);
159159
}
@@ -230,7 +230,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
230230
});
231231

232232
// Assert
233-
response.ShouldNotBeNull();
233+
response.Should().NotBeNull();
234234

235235
string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray();
236236
eTagHeaderValues.Should().HaveCount(1);

test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public async Task Returns_Location_for_post_resource_request()
5858
await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector));
5959

6060
// Assert
61-
response.ShouldNotBeNull();
62-
response.Data.ShouldNotBeNull();
61+
response.Should().NotBeNull();
62+
response.Data.Should().NotBeNull();
6363

6464
string[] locationHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray();
6565
locationHeaderValues.Should().HaveCount(1);

test/OpenApiKiotaEndToEndTests/Links/AlternateOpenApiRouteTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
4848
ExcursionPrimaryResponseDocument? response = await apiClient.Excursions[excursion.StringId!].GetAsync();
4949

5050
// Assert
51-
response.ShouldNotBeNull();
52-
response.Links.ShouldNotBeNull();
51+
response.Should().NotBeNull();
52+
response.Links.Should().NotBeNull();
5353
response.Links.Describedby.Should().Be("/api-docs/v1/swagger.yaml");
5454
}
5555

test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public async Task Cannot_exceed_length_constraint(string firstName)
6565
ErrorObject errorObject = document.Errors.First();
6666
errorObject.Title.Should().Be("Input validation failed.");
6767
errorObject.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'.");
68-
errorObject.Source.ShouldNotBeNull();
68+
errorObject.Source.Should().NotBeNull();
6969
errorObject.Source.Pointer.Should().Be("/data/attributes/firstName");
7070
}
7171

@@ -103,7 +103,7 @@ public async Task Cannot_exceed_string_length_constraint(string userName)
103103
ErrorObject errorObject = document.Errors.First();
104104
errorObject.Title.Should().Be("Input validation failed.");
105105
errorObject.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18.");
106-
errorObject.Source.ShouldNotBeNull();
106+
errorObject.Source.Should().NotBeNull();
107107
errorObject.Source.Pointer.Should().Be("/data/attributes/userName");
108108
}
109109

@@ -139,7 +139,7 @@ public async Task Cannot_violate_regular_expression_constraint()
139139
ErrorObject errorObject = document.Errors.First();
140140
errorObject.Title.Should().Be("Input validation failed.");
141141
errorObject.Detail.Should().Be("Only letters are allowed.");
142-
errorObject.Source.ShouldNotBeNull();
142+
errorObject.Source.Should().NotBeNull();
143143
errorObject.Source.Pointer.Should().Be("/data/attributes/userName");
144144
}
145145

@@ -175,7 +175,7 @@ public async Task Cannot_use_invalid_credit_card_number()
175175
ErrorObject errorObject = document.Errors.First();
176176
errorObject.Title.Should().Be("Input validation failed.");
177177
errorObject.Detail.Should().Be("The CreditCard field is not a valid credit card number.");
178-
errorObject.Source.ShouldNotBeNull();
178+
errorObject.Source.Should().NotBeNull();
179179
errorObject.Source.Pointer.Should().Be("/data/attributes/creditCard");
180180
}
181181

@@ -211,7 +211,7 @@ public async Task Cannot_use_invalid_email_address()
211211
ErrorObject errorObject = document.Errors.First();
212212
errorObject.Title.Should().Be("Input validation failed.");
213213
errorObject.Detail.Should().Be("The Email field is not a valid e-mail address.");
214-
errorObject.Source.ShouldNotBeNull();
214+
errorObject.Source.Should().NotBeNull();
215215
errorObject.Source.Pointer.Should().Be("/data/attributes/email");
216216
}
217217

@@ -250,7 +250,7 @@ public async Task Cannot_exceed_min_length_constraint()
250250
ErrorObject errorObject = document.Errors.First();
251251
errorObject.Title.Should().Be("Input validation failed.");
252252
errorObject.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'.");
253-
errorObject.Source.ShouldNotBeNull();
253+
errorObject.Source.Should().NotBeNull();
254254
errorObject.Source.Pointer.Should().Be("/data/attributes/password");
255255
}
256256

@@ -288,7 +288,7 @@ public async Task Cannot_exceed_max_length_constraint()
288288
ErrorObject errorObject = document.Errors.First();
289289
errorObject.Title.Should().Be("Input validation failed.");
290290
errorObject.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'.");
291-
errorObject.Source.ShouldNotBeNull();
291+
errorObject.Source.Should().NotBeNull();
292292
errorObject.Source.Pointer.Should().Be("/data/attributes/password");
293293
}
294294

@@ -324,7 +324,7 @@ public async Task Cannot_use_invalid_base64()
324324
ErrorObject errorObject = document.Errors.First();
325325
errorObject.Title.Should().Be("Input validation failed.");
326326
errorObject.Detail.Should().Be("The Password field is not a valid Base64 encoding.");
327-
errorObject.Source.ShouldNotBeNull();
327+
errorObject.Source.Should().NotBeNull();
328328
errorObject.Source.Pointer.Should().Be("/data/attributes/password");
329329
}
330330

@@ -364,7 +364,7 @@ public async Task Cannot_use_double_outside_of_valid_range(double age)
364364
ErrorObject errorObject = document.Errors.First();
365365
errorObject.Title.Should().Be("Input validation failed.");
366366
errorObject.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive.");
367-
errorObject.Source.ShouldNotBeNull();
367+
errorObject.Source.Should().NotBeNull();
368368
errorObject.Source.Pointer.Should().Be("/data/attributes/age");
369369
}
370370

@@ -400,7 +400,7 @@ public async Task Cannot_use_relative_url()
400400
ErrorObject errorObject = document.Errors.First();
401401
errorObject.Title.Should().Be("Input validation failed.");
402402
errorObject.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL.");
403-
errorObject.Source.ShouldNotBeNull();
403+
errorObject.Source.Should().NotBeNull();
404404
errorObject.Source.Pointer.Should().Be("/data/attributes/backgroundPicture");
405405
}
406406

@@ -438,7 +438,7 @@ public async Task Cannot_exceed_collection_length_constraint(int length)
438438
ErrorObject errorObject = document.Errors.First();
439439
errorObject.Title.Should().Be("Input validation failed.");
440440
errorObject.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'.");
441-
errorObject.Source.ShouldNotBeNull();
441+
errorObject.Source.Should().NotBeNull();
442442
errorObject.Source.Pointer.Should().Be("/data/attributes/tags");
443443
}
444444

@@ -474,7 +474,7 @@ public async Task Cannot_use_non_allowed_value()
474474
ErrorObject errorObject = document.Errors.First();
475475
errorObject.Title.Should().Be("Input validation failed.");
476476
errorObject.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute.");
477-
errorObject.Source.ShouldNotBeNull();
477+
errorObject.Source.Should().NotBeNull();
478478
errorObject.Source.Pointer.Should().Be("/data/attributes/countryCode");
479479
}
480480

@@ -510,7 +510,7 @@ public async Task Cannot_use_denied_value()
510510
ErrorObject errorObject = document.Errors.First();
511511
errorObject.Title.Should().Be("Input validation failed.");
512512
errorObject.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute.");
513-
errorObject.Source.ShouldNotBeNull();
513+
errorObject.Source.Should().NotBeNull();
514514
errorObject.Source.Pointer.Should().Be("/data/attributes/planet");
515515
}
516516

@@ -546,7 +546,7 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range()
546546
ErrorObject errorObject = document.Errors.First();
547547
errorObject.Title.Should().Be("Input validation failed.");
548548
errorObject.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00.");
549-
errorObject.Source.ShouldNotBeNull();
549+
errorObject.Source.Should().NotBeNull();
550550
errorObject.Source.Pointer.Should().Be("/data/attributes/nextRevalidation");
551551
}
552552

0 commit comments

Comments
 (0)