Skip to content

Commit ae8b75b

Browse files
author
Bart Koelman
committed
Fixed new warnings
1 parent 07b5824 commit ae8b75b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

test/JsonApiDotNetCoreExampleTests/IntegrationTests/ResourceHooks/ResourceHookTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public async Task Can_create_user_with_password()
7777
User responseUser = GetResponseDeserializer().DeserializeSingle<User>(responseDocument).Data;
7878
var document = JsonConvert.DeserializeObject<Document>(responseDocument);
7979

80-
document.SingleData.Attributes.Should().NotContainKey("password");
80+
document.Should().NotBeNull();
81+
document!.SingleData.Attributes.Should().NotContainKey("password");
8182
document.SingleData.Attributes["userName"].Should().Be(newUser.UserName);
8283

8384
await _testContext.RunOnDatabaseAsync(async dbContext =>

test/JsonApiDotNetCoreExampleTests/IntegrationTests/Serialization/SerializationTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ public async Task Cannot_get_unknown_primary_resource_by_ID()
283283
httpResponse.Should().HaveStatusCode(HttpStatusCode.NotFound);
284284

285285
var jObject = JsonConvert.DeserializeObject<JObject>(responseDocument);
286-
string errorId = jObject["errors"].Should().NotBeNull().And.Subject.Select(element => (string)element["id"]).Single();
286+
jObject.Should().NotBeNull();
287+
288+
string errorId = jObject!["errors"].Should().NotBeNull().And.Subject.Select(element => (string)element["id"]).Single();
287289

288290
responseDocument.Should().BeJson(@"{
289291
""errors"": [

test/TestBuildingBlocks/HttpResponseMessageExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static async Task<string> GetFormattedContentAsync(HttpResponseMessage r
4747
{
4848
if (text.Length > 0)
4949
{
50-
return JsonConvert.DeserializeObject<JObject>(text).ToString();
50+
return JsonConvert.DeserializeObject<JObject>(text)?.ToString();
5151
}
5252
}
5353
#pragma warning disable AV1210 // Catch a specific exception instead of Exception, SystemException or ApplicationException

0 commit comments

Comments
 (0)