diff options
author | crupest <crupest@outlook.com> | 2020-01-19 22:45:43 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-19 22:45:43 +0800 |
commit | 40eea04e1ec9b71c5215e9dce5a6963ea60cafaa (patch) | |
tree | 1fa3969a53138becb76a7eef7bafdafc7046c12c /Timeline.Tests/Helpers/ResponseAssertions.cs | |
parent | 4ec507df6251bc1dae5204fdc6aaf14ddbb268f6 (diff) | |
download | timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.tar.gz timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.tar.bz2 timeline-40eea04e1ec9b71c5215e9dce5a6963ea60cafaa.zip |
Basically finish refactor of error codes.
Diffstat (limited to 'Timeline.Tests/Helpers/ResponseAssertions.cs')
-rw-r--r-- | Timeline.Tests/Helpers/ResponseAssertions.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Timeline.Tests/Helpers/ResponseAssertions.cs b/Timeline.Tests/Helpers/ResponseAssertions.cs index 301ceef6..be0043dc 100644 --- a/Timeline.Tests/Helpers/ResponseAssertions.cs +++ b/Timeline.Tests/Helpers/ResponseAssertions.cs @@ -3,6 +3,7 @@ using FluentAssertions.Execution; using FluentAssertions.Formatting;
using FluentAssertions.Primitives;
using System;
+using System.Globalization;
using System.Net;
using System.Net.Http;
using System.Text;
@@ -147,14 +148,21 @@ namespace Timeline.Tests.Helpers body.Data.Delete.Should().Be(delete);
}
+ public static void HaveCommonResponseBody(this HttpResponseMessageAssertions assertions, int code, string message = null, params object[] messageArgs)
+ {
+ message = string.IsNullOrEmpty(message) ? "" : ", " + string.Format(CultureInfo.CurrentCulture, message, messageArgs);
+ var body = assertions.HaveJsonBody<CommonResponse>("Response body should be CommonResponse{0}", message).Which;
+ body.Code.Should().Be(code, "Response body code is not the specified one{0}", message);
+ }
+
public static void BeInvalidModel(this HttpResponseMessageAssertions assertions, string message = null)
{
message = string.IsNullOrEmpty(message) ? "" : ", " + message;
assertions.HaveStatusCode(400, "Invalid Model Error must have 400 status code{0}", message)
.And.HaveCommonBody("Invalid Model Error must have CommonResponse body{0}", message)
- .Which.Code.Should().Be(ErrorCodes.Http.Common.InvalidModel,
+ .Which.Code.Should().Be(ErrorCodes.Common.InvalidModel,
"Invalid Model Error must have code {0} in body{1}",
- ErrorCodes.Http.Common.InvalidModel, message);
+ ErrorCodes.Common.InvalidModel, message);
}
}
}
|