diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index 02f1601ee7..d969cbef4a 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -347,7 +347,8 @@ public class ThePutMethod [Fact] public async Task MakesPutRequestWithData() { - string data = SimpleJson.SerializeObject(new object()); + var body = new object(); + var expectedBody = SimpleJson.SerializeObject(body); var httpClient = Substitute.For(); IResponse response = new Response(); httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response)); @@ -357,11 +358,11 @@ public async Task MakesPutRequestWithData() httpClient, Substitute.For()); - await connection.Put(new Uri("endpoint", UriKind.Relative), new object()); + await connection.Put(new Uri("endpoint", UriKind.Relative), body); httpClient.Received(1).Send(Arg.Is(req => req.BaseAddress == _exampleUri && - (string)req.Body == data && + (string)req.Body == expectedBody && req.Method == HttpMethod.Put && req.ContentType == "application/x-www-form-urlencoded" && req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken); @@ -370,7 +371,8 @@ public async Task MakesPutRequestWithData() [Fact] public async Task MakesPutRequestWithDataAndTwoFactor() { - string data = SimpleJson.SerializeObject(new object()); + var body = new object(); + var expectedBody = SimpleJson.SerializeObject(body); var httpClient = Substitute.For(); IResponse response = new Response(); httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response)); @@ -380,11 +382,11 @@ public async Task MakesPutRequestWithDataAndTwoFactor() httpClient, Substitute.For()); - await connection.Put(new Uri("endpoint", UriKind.Relative), new object(), "two-factor"); + await connection.Put(new Uri("endpoint", UriKind.Relative), body, "two-factor"); httpClient.Received(1).Send(Arg.Is(req => req.BaseAddress == _exampleUri && - (string)req.Body == data && + (string)req.Body == expectedBody && req.Method == HttpMethod.Put && req.Headers["X-GitHub-OTP"] == "two-factor" && req.ContentType == "application/x-www-form-urlencoded" &&