diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-11 15:34:59 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-11 15:34:59 +0800 |
commit | 4d15f7d696825f332884bb23e67760d6d1f5a736 (patch) | |
tree | 233518dd41d7747c8932eac67d48a62aa4203d53 /Timeline.Tests/Helpers/InvalidModelTestHelpers.cs | |
parent | d97185e6152a327f6ef3b1873bfd86f1a3aac3a1 (diff) | |
download | timeline-4d15f7d696825f332884bb23e67760d6d1f5a736.tar.gz timeline-4d15f7d696825f332884bb23e67760d6d1f5a736.tar.bz2 timeline-4d15f7d696825f332884bb23e67760d6d1f5a736.zip |
Add FluentAssertions.
Diffstat (limited to 'Timeline.Tests/Helpers/InvalidModelTestHelpers.cs')
-rw-r--r-- | Timeline.Tests/Helpers/InvalidModelTestHelpers.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Timeline.Tests/Helpers/InvalidModelTestHelpers.cs b/Timeline.Tests/Helpers/InvalidModelTestHelpers.cs index 1c079d0e..af432095 100644 --- a/Timeline.Tests/Helpers/InvalidModelTestHelpers.cs +++ b/Timeline.Tests/Helpers/InvalidModelTestHelpers.cs @@ -1,8 +1,6 @@ -using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Timeline.Models.Http;
-using Xunit;
namespace Timeline.Tests.Helpers
{
@@ -11,17 +9,15 @@ namespace Timeline.Tests.Helpers public static async Task TestPostInvalidModel<T>(HttpClient client, string url, T body)
{
var response = await client.PostAsJsonAsync(url, body);
- Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
- var responseBody = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonResponse.ErrorCodes.InvalidModel, responseBody.Code);
+ response.Should().HaveStatusCodeBadRequest()
+ .And.Should().HaveBodyAsCommonResponseWithCode(CommonResponse.ErrorCodes.InvalidModel);
}
public static async Task TestPutInvalidModel<T>(HttpClient client, string url, T body)
{
var response = await client.PutAsJsonAsync(url, body);
- Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
- var responseBody = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonResponse.ErrorCodes.InvalidModel, responseBody.Code);
+ response.Should().HaveStatusCodeBadRequest()
+ .And.Should().HaveBodyAsCommonResponseWithCode(CommonResponse.ErrorCodes.InvalidModel);
}
}
}
|