public void GetHttpActionResultForDelete_NotFound_ShouldReturnNotFoundResult() { var result = ErrorResultExtensions.ToNotFound(); var actionResult = WebApiControllerHelper.GetHttpActionResultForDelete(result, Substitute.For <ApiController>()); var notFoundResult = actionResult as NotFoundResult; notFoundResult.ShouldNotBeNull(); }
public void GetHttpActionResultForPut_Ok_ShouldReturnOkResult() { var result = Result <Error> .Ok(); var actionResult = WebApiControllerHelper.GetHttpActionResultForPut(result, Substitute.For <ApiController>()); var okResult = actionResult as OkResult; okResult.ShouldNotBeNull(); }
public void GetHttpActionResultForDelete_NotFound_ShouldReturnNotFoundResult() { var result = ((NonEmptyString)"error").ToNotFound(); var actionResult = WebApiControllerHelper.GetHttpActionResultForDelete(result, GetController()); var notFoundResult = actionResult as StatusCodeTextPlainActionResult; notFoundResult.ShouldNotBeNull(); notFoundResult.StatusCode.ShouldBe(HttpStatusCode.NotFound); }
public void GetHttpActionResult_PreconditionFailed_ShouldReturnStatusCodeResult() { var result = ((NonEmptyString)"error").ToRowVersionMismatch <string>(); var actionResult = WebApiControllerHelper.GetHttpActionResult(result, GetController()); var statusCodeResult = actionResult as StatusCodeTextPlainActionResult; statusCodeResult.ShouldNotBeNull(); statusCodeResult.StatusCode.ShouldBe(HttpStatusCode.PreconditionFailed); }
public void GetHttpActionResultForPut_Generic_ShouldReturnBadRequestErrorMessageResult() { const string error = "error"; var result = ((NonEmptyString)error).ToGeneric(); var actionResult = WebApiControllerHelper.GetHttpActionResultForPut(result, Substitute.For <ApiController>()); var badRequestErrorMessageResult = actionResult as BadRequestErrorMessageResult; badRequestErrorMessageResult.ShouldNotBeNull(); badRequestErrorMessageResult?.Message.ShouldBe(error); }
public void GetHttpActionResultForDelete_Ok_ShouldReturnStatusCodeResult() { var result = Result <Error> .Ok(); var actionResult = WebApiControllerHelper.GetHttpActionResultForDelete(result, Substitute.For <ApiController>()); var statusCodeResult = actionResult as StatusCodeResult; statusCodeResult.ShouldNotBeNull(); statusCodeResult?.StatusCode.ShouldBe(HttpStatusCode.NoContent); }
public void GetHttpActionResult_Ok_ShouldReturnOkNegotiatedContentResult() { const string content = "Ok"; var result = Result <string, Error> .Ok(content); var actionResult = WebApiControllerHelper.GetHttpActionResult(result, Substitute.For <ApiController>()); var okNegotiatedContentResult = actionResult as OkNegotiatedContentResult <string>; okNegotiatedContentResult.ShouldNotBeNull(); okNegotiatedContentResult?.Content.ShouldBe(content); }
public void GetHttpActionResultForDelete_Generic_ShouldReturnBadRequestResult() { const string error = "error"; var result = ((NonEmptyString)error).ToGeneric(); var actionResult = WebApiControllerHelper.GetHttpActionResultForDelete(result, GetController()); var badRequestErrorMessageResult = actionResult as StatusCodeTextPlainActionResult; badRequestErrorMessageResult.ShouldNotBeNull(); badRequestErrorMessageResult.StatusCode.ShouldBe(HttpStatusCode.BadRequest); badRequestErrorMessageResult.Message.ShouldBe(error); }