From a1109e9ac3f059e27089d981972f53bfe61e8f46 Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Thu, 31 Oct 2019 14:15:37 +0800 Subject: Complete integrated tests. --- Timeline.Tests/IntegratedTests/UserAvatarTest.cs | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Timeline.Tests/IntegratedTests/UserAvatarTest.cs') diff --git a/Timeline.Tests/IntegratedTests/UserAvatarTest.cs b/Timeline.Tests/IntegratedTests/UserAvatarTest.cs index b338665e..2310fc66 100644 --- a/Timeline.Tests/IntegratedTests/UserAvatarTest.cs +++ b/Timeline.Tests/IntegratedTests/UserAvatarTest.cs @@ -53,7 +53,7 @@ namespace Timeline.Tests.IntegratedTests { var res = await client.GetAsync("users/usernotexist/avatar"); res.Should().HaveStatusCode(404) - .And.Should().HaveCommonBody() + .And.HaveCommonBody() .Which.Code.Should().Be(Get.UserNotExist); } @@ -94,7 +94,7 @@ namespace Timeline.Tests.IntegratedTests request.Headers.TryAddWithoutValidation("If-None-Match", "\"dsdfd"); var res = await client.SendAsync(request); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Header.IfNonMatch.BadFormat); + .And.HaveCommonBody().Which.Code.Should().Be(Header.IfNonMatch.BadFormat); } { @@ -124,7 +124,7 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentLength.Missing); ; + .And.HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentLength.Missing); ; } { @@ -132,7 +132,7 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentLength = 1; var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentType.Missing); + .And.HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentType.Missing); } { @@ -141,7 +141,7 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentLength.Zero); + .And.HaveCommonBody().Which.Code.Should().Be(ErrorCodes.Http.Filter.Header.ContentLength.Zero); } { @@ -155,7 +155,7 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Content.TooBig); + .And.HaveCommonBody().Which.Code.Should().Be(Content.TooBig); } { @@ -164,7 +164,7 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Content.UnmatchedLength_Smaller); + .And.HaveCommonBody().Which.Code.Should().Be(Content.UnmatchedLength_Smaller); } { @@ -173,25 +173,25 @@ namespace Timeline.Tests.IntegratedTests content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); var res = await client.PutAsync("users/user/avatar", content); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Content.UnmatchedLength_Bigger); + .And.HaveCommonBody().Which.Code.Should().Be(Content.UnmatchedLength_Bigger); } { var res = await client.PutByteArrayAsync("users/user/avatar", new[] { (byte)0x00 }, "image/png"); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_CantDecode); + .And.HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_CantDecode); } { var res = await client.PutByteArrayAsync("users/user/avatar", mockAvatar.Data, "image/jpeg"); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_UnmatchedFormat); + .And.HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_UnmatchedFormat); } { var res = await client.PutByteArrayAsync("users/user/avatar", ImageHelper.CreatePngWithSize(100, 200), "image/png"); res.Should().HaveStatusCode(HttpStatusCode.BadRequest) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_BadSize); + .And.HaveCommonBody().Which.Code.Should().Be(Put.BadFormat_BadSize); } { @@ -221,13 +221,13 @@ namespace Timeline.Tests.IntegratedTests { var res = await client.PutByteArrayAsync("users/admin/avatar", new[] { (byte)0x00 }, "image/png"); res.Should().HaveStatusCode(HttpStatusCode.Forbidden) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Put.Forbid); + .And.HaveCommonBody().Which.Code.Should().Be(Put.Forbid); } { var res = await client.DeleteAsync("users/admin/avatar"); res.Should().HaveStatusCode(HttpStatusCode.Forbidden) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Delete.Forbid); + .And.HaveCommonBody().Which.Code.Should().Be(Delete.Forbid); } for (int i = 0; i < 2; i++) // double delete should work. @@ -254,14 +254,14 @@ namespace Timeline.Tests.IntegratedTests { var res = await client.PutByteArrayAsync("users/usernotexist/avatar", new[] { (byte)0x00 }, "image/png"); res.Should().HaveStatusCode(400) - .And.Should().HaveCommonBody() + .And.HaveCommonBody() .Which.Code.Should().Be(Put.UserNotExist); } { var res = await client.DeleteAsync("users/usernotexist/avatar"); res.Should().HaveStatusCode(400) - .And.Should().HaveCommonBody().Which.Code.Should().Be(Delete.UserNotExist); + .And.HaveCommonBody().Which.Code.Should().Be(Delete.UserNotExist); } } -- cgit v1.2.3