From 26392cdd2028eff2132948d5cc5e36e08a2d69a9 Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Sun, 11 Aug 2019 15:34:59 +0800 Subject: Add FluentAssertions. --- Timeline.Tests/Helpers/ResponseExtensions.cs | 61 ---------------------------- 1 file changed, 61 deletions(-) delete mode 100644 Timeline.Tests/Helpers/ResponseExtensions.cs (limited to 'Timeline.Tests/Helpers/ResponseExtensions.cs') 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(); - Assert.Equal(CommonPutResponse.CreatedCode, body.Code); - } - - public static async Task AssertIsPutModified(this HttpResponseMessage response) - { - response.AssertOk(); - var body = await response.ReadBodyAsJson(); - Assert.Equal(CommonPutResponse.ModifiedCode, body.Code); - } - - - public static async Task AssertIsDeleteDeleted(this HttpResponseMessage response) - { - response.AssertOk(); - var body = await response.ReadBodyAsJson(); - Assert.Equal(CommonDeleteResponse.DeletedCode, body.Code); - } - - public static async Task AssertIsDeleteNotExist(this HttpResponseMessage response) - { - response.AssertOk(); - var body = await response.ReadBodyAsJson(); - Assert.Equal(CommonDeleteResponse.NotExistsCode, body.Code); - } - - public static async Task ReadBodyAsJson(this HttpResponseMessage response) - { - return JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - } - } -} -- cgit v1.2.3