public IHttpActionResult OkResultWithContentNegotiatorAction() { return(new OkNegotiatedContentResult <int>( 5, TestObjectFactory.GetCustomContentNegotiator(), TestObjectFactory.GetCustomHttpRequestMessage(), TestObjectFactory.GetFormatters())); }
public void ContainingFormattersShouldNotThrowExceptionWhenActionResultHasCorrectMediaTypeFormatters() { MyWebApi .Controller <WebApiController>() .Calling(c => c.OkResultWithContentNegotiatorAction()) .ShouldReturn() .Ok() .ContainingMediaTypeFormatters(TestObjectFactory.GetFormatters().Reverse()); }
public IHttpActionResult CreatedActionWithCustomContentNegotiator() { return(new CreatedNegotiatedContentResult <ICollection <ResponseModel> >( TestObjectFactory.GetUri(), this.responseModel, TestObjectFactory.GetCustomContentNegotiator(), TestObjectFactory.GetCustomHttpRequestMessage(), TestObjectFactory.GetFormatters())); }
public IHttpActionResult ContentActionWithCustomFormatters() { return(new NegotiatedContentResult <int>( HttpStatusCode.OK, 5, TestObjectFactory.GetCustomContentNegotiator(), TestObjectFactory.GetCustomHttpRequestMessage(), TestObjectFactory.GetFormatters())); }
public void ValidateMediaTypeFormattersShouldThrowExceptionWithIncorrectMediaTypeFormatter() { var actionResultWithFormatters = new CreatedNegotiatedContentResult <int>( TestObjectFactory.GetUri(), 5, MyWebApi.Controller <WebApiController>().AndProvideTheController()); MediaTypeFormatterValidator.ValidateMediaTypeFormatters( actionResultWithFormatters, TestObjectFactory.GetFormatters(), TestObjectFactory.GetFailingValidationAction()); }
public void ContainingFormattersShouldThrowExceptionWhenActionResultHasDifferentCountOfMediaTypeFormatters() { var mediaTypeFormatters = TestObjectFactory.GetFormatters().ToList(); mediaTypeFormatters.Remove(mediaTypeFormatters.Last()); MyWebApi .Controller <WebApiController>() .Calling(c => c.CreatedActionWithCustomContentNegotiator()) .ShouldReturn() .Created() .ContainingMediaTypeFormatters(mediaTypeFormatters); }
public void ContainingFormattersShouldNotThrowExceptionWhenActionResultHasCorrectMediaTypeFormattersAsParams() { var mediaTypeFormatters = TestObjectFactory.GetFormatters().ToList(); MyWebApi .Controller <WebApiController>() .Calling(c => c.OkResultWithContentNegotiatorAction()) .ShouldReturn() .Ok() .ContainingMediaTypeFormatters( mediaTypeFormatters[0], mediaTypeFormatters[1], mediaTypeFormatters[2], mediaTypeFormatters[3], mediaTypeFormatters[4]); }