fixing formatting
This commit is contained in:
parent
c6b2b77d8a
commit
42bb28e284
@ -57,15 +57,15 @@ namespace Flurl.Http.Testing
|
||||
return With(c => MatchesPattern(c.RequestBody, bodyPattern));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts whether calls were made containing given request body.
|
||||
/// </summary>
|
||||
/// <param name="body"></param>
|
||||
/// <returns></returns>
|
||||
public HttpCallAssertion WithRequestBodyJson(object body){
|
||||
var serializedBody = FlurlHttp.GlobalSettings.JsonSerializer.Serialize(body);
|
||||
return With(c => MatchesPattern(c.RequestBody, serializedBody));
|
||||
}
|
||||
/// <summary>
|
||||
/// Asserts whether calls were made containing given request body.
|
||||
/// </summary>
|
||||
/// <param name="body"></param>
|
||||
/// <returns></returns>
|
||||
public HttpCallAssertion WithRequestBodyJson(object body) {
|
||||
var serializedBody = FlurlHttp.GlobalSettings.JsonSerializer.Serialize(body);
|
||||
return With(c => MatchesPattern(c.RequestBody, serializedBody));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts whether calls were made with given HTTP verb.
|
||||
|
@ -18,17 +18,17 @@ namespace Flurl.Test.Http
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task can_post_object_as_json(){
|
||||
var expectedEndpoint = "http://some-api.com";
|
||||
var expectedBody = new {a = 1, b = 2};
|
||||
await expectedEndpoint.PostJsonAsync(expectedBody);
|
||||
HttpTest.ShouldHaveCalled(expectedEndpoint)
|
||||
.WithVerb(HttpMethod.Post)
|
||||
.WithContentType("application/json")
|
||||
.WithRequestBodyJson(expectedBody)
|
||||
.Times(1);
|
||||
}
|
||||
[Test]
|
||||
public async Task can_post_object_as_json() {
|
||||
var expectedEndpoint = "http://some-api.com";
|
||||
var expectedBody = new {a = 1, b = 2};
|
||||
await expectedEndpoint.PostJsonAsync(expectedBody);
|
||||
HttpTest.ShouldHaveCalled(expectedEndpoint)
|
||||
.WithVerb(HttpMethod.Post)
|
||||
.WithContentType("application/json")
|
||||
.WithRequestBodyJson(expectedBody)
|
||||
.Times(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task can_post_url_encoded() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user