Skip to content

Commit

Permalink
style: fix several style/nullable issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Jan 2, 2023
1 parent 06ca776 commit 8da176a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/MockHttp/Threading/TaskHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class TaskHelpers
{
public static T RunSync<T>(Func<Task<T>> action, TimeSpan timeout)
{
Task<T> task = null;
Task<T>? task = null;

RunSync(() =>
{
Expand All @@ -16,7 +16,7 @@ public static T RunSync<T>(Func<Task<T>> action, TimeSpan timeout)
},
timeout);

return task.Result;
return task is null ? default! : task.Result;
}

public static void RunSync(Func<Task> action, TimeSpan timeout)
Expand Down
2 changes: 1 addition & 1 deletion test/MockHttp.Tests/Extensions/IRespondsExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task When_responding_with_message_based_on_request_it_should_return
HttpResponseMessage actualResponse = await _httpCall.SendAsync(new MockHttpRequestContext(request), CancellationToken.None);

// Assert
actualResponse.Should().HaveHeader("query", request.RequestUri.Query);
actualResponse.Should().HaveHeader("query", request.RequestUri!.Query);
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/MockHttp.Tests/MockHttpHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public async Task Given_stream_response_when_sending_requests_it_should_buffer_r

_sut.Verify(_ => { }, IsSent.Exactly(2));
secondResponse.Should().NotBeNull();
firstResponse.Content.Should().NotBeSameAs(secondResponse.Content);
firstResponse.Content.Should().NotBeSameAs(secondResponse!.Content);
await (await firstResponse.Should()
.HaveContentAsync(await secondResponse.Content.ReadAsStringAsync()))
.And.HaveContentAsync(data);
Expand Down Expand Up @@ -647,8 +647,10 @@ public void Given_null_argument_when_executing_method_it_should_throw(params obj
public static IEnumerable<object[]> TestCases()
{
var mockHttp = new MockHttpHandler();
#pragma warning disable IDE0039
// ReSharper disable once ConvertToLocalFunction
Action<RequestMatching> matching = _ => { };
#pragma warning restore IDE0039
Func<IsSent> isSentFunc = IsSent.Once;
string? because = null;

Expand Down

0 comments on commit 8da176a

Please sign in to comment.