mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Fixed merge conflicts
This commit is contained in:
@@ -349,7 +349,8 @@ namespace Octokit.Tests.Http
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithData()
|
||||
{
|
||||
string data = SimpleJson.SerializeObject(new object());
|
||||
var body = new object();
|
||||
var expectedBody = SimpleJson.SerializeObject(body);
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response();
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
@@ -359,20 +360,21 @@ namespace Octokit.Tests.Http
|
||||
httpClient,
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
await connection.Put<string>(new Uri("endpoint", UriKind.Relative), new object());
|
||||
await connection.Put<string>(new Uri("endpoint", UriKind.Relative), body);
|
||||
|
||||
httpClient.Received(1).Send(Arg.Is<IRequest>(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);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithDataAndTwoFactor()
|
||||
public async Task MakesPutRequestWithNoData()
|
||||
{
|
||||
string data = SimpleJson.SerializeObject(new object());
|
||||
var body = RequestBody.Empty;
|
||||
var expectedBody = SimpleJson.SerializeObject(body);
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
IResponse response = new Response();
|
||||
httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
@@ -382,16 +384,65 @@ namespace Octokit.Tests.Http
|
||||
httpClient,
|
||||
Substitute.For<IJsonSerializer>());
|
||||
|
||||
await connection.Put<string>(new Uri("endpoint", UriKind.Relative), new object(), "two-factor");
|
||||
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 == data &&
|
||||
(string)req.Body == expectedBody &&
|
||||
req.Method == HttpMethod.Put &&
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithDataAndTwoFactor()
|
||||
{
|
||||
var body = new object();
|
||||
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.ContentType == "application/x-www-form-urlencoded" &&
|
||||
req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MakesPutRequestWithNoDataAndTwoFactor()
|
||||
{
|
||||
var body = RequestBody.Empty;
|
||||
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