public void DataIsNullByDefault(string message) { // Exercise system var response = new ErrorResponse(message); // Verify outcome response.Data.Should().BeNull(); }
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); }
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); }
public void StatusIsError(ErrorResponse response) { // Exercise system and verify outcome response.Status.Should().Be("error"); }
public void IsJSendResponse(ErrorResponse response) { // Exercise system and verify outcome response.Should().BeAssignableTo<IJSendResponse>(); }
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"); }