Пример #1
0
 public void DataIsNullByDefault(string message)
 {
     // Exercise system
     var response = new ErrorResponse(message);
     // Verify outcome
     response.Data.Should().BeNull();
 }
Пример #2
0
 public void CodeIsNullByDefault(string message)
 {
     // Exercise system
     var response = new ErrorResponse(message);
     // Verify outcome
     response.Code.Should().NotHaveValue();
 }
 public void ResponseIsCorrectlyInitialized(string message, int? errorCode, Exception data, ApiController controller)
 {
     // Fixture setup
     var expectedResponse = new ErrorResponse(message, errorCode, data);
     // Exercise system
     var result = new JSendInternalServerErrorResult(message, errorCode, data, controller);
     // Verify outcome
     result.Response.ShouldBeEquivalentTo(expectedResponse);
 }
 public void JSendError_CreatesNewJSendError(HttpStatusCode code, string message, int? errorCode, string data,
     JSendApiController controller)
 {
     // Fixture setup
     var expectedResponse = new ErrorResponse(message, errorCode, data);
     // Exercise system
     var result = controller.JSendError(code, message, errorCode, data);
     // Verify outcome
     result.Response.ShouldBeEquivalentTo(expectedResponse);
     result.StatusCode.Should().Be(code);
 }
Пример #5
0
        public void SerializesCorrectly(string message, int code, Model data)
        {
            // Fixture setup
            var expectedSerializedResponse = new JObject
            {
                {"status", "error"},
                {"message", message},
                {"code", code},
                {"data", JObject.FromObject(data)}
            };

            var response = new ErrorResponse(message, code, data);
            // Exercise system
            var serializedResponse = JObject.FromObject(response);
            // Verify outcome
            Assert.Equal(expectedSerializedResponse, serializedResponse, JToken.EqualityComparer);
        }
Пример #6
0
 public void StatusIsError(ErrorResponse response)
 {
     // Exercise system and verify outcome
     response.Status.Should().Be("error");
 }
Пример #7
0
 public void IsJSendResponse(ErrorResponse response)
 {
     // Exercise system and verify outcome
     response.Should().BeAssignableTo<IJSendResponse>();
 }
Пример #8
0
 public void NullDataIsNotSerialized(string message)
 {
     // Fixture setup
     var response = new ErrorResponse(message);
     // Exercise system
     var serializedResponse = JObject.FromObject(response);
     // Verify outcome
     serializedResponse.Should().NotContainKey("data");
 }