diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-11 16:12:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-11 16:12:23 +0800 |
commit | 285fe070388e48d82f008c3de5b0d7675f55ebfa (patch) | |
tree | 3e4e7de38b9f0e5832923a6bc1ce7872fc4370a5 /Timeline.Tests/Helpers/ResponseExtensions.cs | |
parent | 38ff45fcc0b58a95ad52ba43a8be4ff466694269 (diff) | |
parent | 4b0d4ba4e79c1a2e22ccf131d1abdbf113d78b6a (diff) | |
download | timeline-285fe070388e48d82f008c3de5b0d7675f55ebfa.tar.gz timeline-285fe070388e48d82f008c3de5b0d7675f55ebfa.tar.bz2 timeline-285fe070388e48d82f008c3de5b0d7675f55ebfa.zip |
Merge pull request #39 from crupest/fluent-assertion
Use FluentAssertions.
Diffstat (limited to 'Timeline.Tests/Helpers/ResponseExtensions.cs')
-rw-r--r-- | Timeline.Tests/Helpers/ResponseExtensions.cs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/Timeline.Tests/Helpers/ResponseExtensions.cs b/Timeline.Tests/Helpers/ResponseExtensions.cs deleted file mode 100644 index 46c9e81d..00000000 --- a/Timeline.Tests/Helpers/ResponseExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Newtonsoft.Json;
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Timeline.Models.Http;
-using Xunit;
-
-namespace Timeline.Tests.Helpers
-{
- public static class ResponseExtensions
- {
- public static void AssertOk(this HttpResponseMessage response)
- {
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- }
-
- public static void AssertNotFound(this HttpResponseMessage response)
- {
- Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
- }
-
- public static void AssertBadRequest(this HttpResponseMessage response)
- {
- Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
- }
-
- public static async Task AssertIsPutCreated(this HttpResponseMessage response)
- {
- Assert.Equal(HttpStatusCode.Created, response.StatusCode);
- var body = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonPutResponse.CreatedCode, body.Code);
- }
-
- public static async Task AssertIsPutModified(this HttpResponseMessage response)
- {
- response.AssertOk();
- var body = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonPutResponse.ModifiedCode, body.Code);
- }
-
-
- public static async Task AssertIsDeleteDeleted(this HttpResponseMessage response)
- {
- response.AssertOk();
- var body = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonDeleteResponse.DeletedCode, body.Code);
- }
-
- public static async Task AssertIsDeleteNotExist(this HttpResponseMessage response)
- {
- response.AssertOk();
- var body = await response.ReadBodyAsJson<CommonResponse>();
- Assert.Equal(CommonDeleteResponse.NotExistsCode, body.Code);
- }
-
- public static async Task<T> ReadBodyAsJson<T>(this HttpResponseMessage response)
- {
- return JsonConvert.DeserializeObject<T>(await response.Content.ReadAsStringAsync());
- }
- }
-}
|