mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 12:03:19 +00:00
adding passing tests: ConnectionTests.ThePutMethod can submit PUT requests with no data (i.e. empty body).
This commit is contained in:
@@ -368,6 +368,31 @@ namespace Octokit.Tests.Http
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithNoData()
|
||||
{
|
||||
var body = ApiConnection.EmptyBody;
|
||||
var expectedBody = SimpleJson.SerializeObject(body);
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response();
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
Substitute.For<ICredentialStore>(),
|
||||
httpClient,
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
await connection.Put<string>(new Uri("endpoint", UriKind.Relative), body);
|
||||
|
||||
Console.WriteLine(expectedBody);
|
||||
|
||||
httpClient.Received(1).Send(Arg.Is<IRequest>(req =>
|
||||
req.BaseAddress == _exampleUri &&
|
||||
(string)req.Body == expectedBody &&
|
||||
req.Method == HttpMethod.Put &&
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithDataAndTwoFactor()
|
||||
{
|
||||
@@ -392,6 +417,30 @@ namespace Octokit.Tests.Http
|
||||
req.ContentType == "application/x-www-form-urlencoded" &&
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithNoDataAndTwoFactor()
|
||||
{
|
||||
var body = ApiConnection.EmptyBody ;
|
||||
var expectedBody = SimpleJson.SerializeObject(body);
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response();
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var connection = new Connection(new ProductHeaderValue("OctokitTests"),
|
||||
_exampleUri,
|
||||
Substitute.For<ICredentialStore>(),
|
||||
httpClient,
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
await connection.Put<string>(new Uri("endpoint", UriKind.Relative), body, "two-factor");
|
||||
|
||||
httpClient.Received(1).Send(Arg.Is<IRequest>(req =>
|
||||
req.BaseAddress == _exampleUri &&
|
||||
(string)req.Body == expectedBody &&
|
||||
req.Method == HttpMethod.Put &&
|
||||
req.Headers["X-GitHub-OTP"] == "two-factor" &&
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
public class ThePostMethod
|
||||
|
||||
Reference in New Issue
Block a user