public void ContainingOutputFormattersShouldNotThrowExceptionWithCorrectParametersValue() { MyController <MvcController> .Instance() .Calling(c => c.FullObjectResultAction()) .ShouldReturn() .StatusCode() .ContainingOutputFormatters(TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter()); }
public void ContainingOutputFormattersShouldNotThrowExceptionWithCorrectParametersValue() { MyMvc .Controller <MvcController>() .Calling(c => c.FullOkAction()) .ShouldReturn() .Ok() .ContainingOutputFormatters(TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter()); }
public void ContainingOutputFormatterShouldNotThrowExceptionWithCorrectValue() { var formatter = TestObjectFactory.GetOutputFormatter(); MyController <MvcController> .Instance() .Calling(c => c.ObjectActionWithFormatter(formatter)) .ShouldReturn() .StatusCode() .ContainingOutputFormatter(formatter); }
public void ContainingOutputFormatterShouldNotThrowExceptionWithCorrectValue() { var formatter = TestObjectFactory.GetOutputFormatter(); MyMvc .Controller <MvcController>() .Calling(c => c.HttpNotFoundActionWithFormatter(formatter)) .ShouldReturn() .NotFound() .ContainingOutputFormatter(formatter); }
public void AndAlsoShouldWorkCorrectly() { MyController <MvcController> .Instance() .Calling(c => c.FullHttpNotFoundAction()) .ShouldReturn() .NotFound() .WithStatusCode(201) .AndAlso() .ContainingOutputFormatters(TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter()); }
public void AndAlsoShouldWorkCorrectly() { MyMvc .Controller <MvcController>() .Calling(c => c.FullHttpBadRequestAction()) .ShouldReturn() .BadRequest() .WithStatusCode(201) .AndAlso() .ContainingOutputFormatters(TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter()); }
public void AndAlsoShouldWorkCorrectly() { MyController <MvcController> .Instance() .Calling(c => c.FullObjectResultAction()) .ShouldReturn() .StatusCode() .ContainingOutputFormatters(TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter()) .AndAlso() .WithModelOfType <IList <ResponseModel> >(); }
public void ContainingOutputFormatterShouldNotThrowExceptionWithCorrectValue() { var formatter = TestObjectFactory.GetOutputFormatter(); MyController <MvcController> .Instance() .WithoutValidation() .Calling(c => c.CreatedActionWithFormatter(formatter)) .ShouldReturn() .Created(created => created .ContainingOutputFormatter(formatter)); }
public void ContainingOutputFormattersShouldNotThrowExceptionWithCorrectValue() { MyMvc .Controller <MvcController>() .Calling(c => c.FullObjectResultAction()) .ShouldReturn() .StatusCode() .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter() }); }
public void ContainingOutputFormattersShouldNotThrowExceptionWithCorrectValue() { MyController <MvcController> .Instance() .Calling(c => c.FullOkAction()) .ShouldReturn() .Ok(ok => ok .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter() })); }
public IActionResult FullHttpNotFoundAction() { return(new NotFoundObjectResult(this.responseModel) { ContentTypes = new MediaTypeCollection { new MediaTypeHeaderValue(ContentType.ApplicationJson), new MediaTypeHeaderValue(ContentType.ApplicationXml) }, StatusCode = StatusCodes.Status201Created, Formatters = new FormatterCollection <IOutputFormatter> { TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter() }, DeclaredType = typeof(List <ResponseModel>), }); }
public void ContainingOutputFormatterShouldThrowExceptionWithIncorrectValue() { Test.AssertException <NotFoundResultAssertionException>( () => { var formatter = TestObjectFactory.GetOutputFormatter(); MyMvc .Controller <MvcController>() .Calling(c => c.HttpNotFoundActionWithFormatter(formatter)) .ShouldReturn() .NotFound() .ContainingOutputFormatter(new JsonOutputFormatter()); }, "When calling HttpNotFoundActionWithFormatter action in MvcController expected HTTP not found result output formatters to contain the provided formatter, but such was not found."); }
public void ContainingOutputFormatterShouldThrowExceptionWithIncorrectValue() { Test.AssertException <BadRequestResultAssertionException>( () => { var formatter = TestObjectFactory.GetOutputFormatter(); MyController <MvcController> .Instance() .Calling(c => c.HttpBadRequestActionWithFormatter(formatter)) .ShouldReturn() .BadRequest() .ContainingOutputFormatter(new CustomOutputFormatter()); }, "When calling HttpBadRequestActionWithFormatter action in MvcController expected bad request result output formatters to contain the provided formatter, but such was not found."); }
public void ContainingOutputFormatterShouldThrowExceptionWithIncorrectValue() { Test.AssertException <StatusCodeResultAssertionException>( () => { var formatter = TestObjectFactory.GetOutputFormatter(); MyController <MvcController> .Instance() .Calling(c => c.ObjectActionWithFormatter(formatter)) .ShouldReturn() .StatusCode() .ContainingOutputFormatter(TestObjectFactory.GetOutputFormatter()); }, "When calling ObjectActionWithFormatter action in MvcController expected status code result output formatters to contain the provided formatter, but such was not found."); }
public void ContainingOutputFormattersShouldThrowExceptionWithIncorrectCount() { Test.AssertException <NotFoundResultAssertionException>( () => { MyMvc .Controller <MvcController>() .Calling(c => c.FullHttpNotFoundAction()) .ShouldReturn() .NotFound() .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter() }); }, "When calling FullHttpNotFoundAction action in MvcController expected HTTP not found result output formatters to have 1 item, but instead found 2."); }
public void ContainingOutputFormattersShouldThrowExceptionWithIncorrectCount() { Test.AssertException <StatusCodeResultAssertionException>( () => { MyController <MvcController> .Instance() .Calling(c => c.FullObjectResultAction()) .ShouldReturn() .StatusCode() .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter() }); }, "When calling FullObjectResultAction action in MvcController expected status code result output formatters to have 1 item, but instead found 2."); }
public void ContainingOutputFormattersShouldThrowExceptionWithIncorrectCountWithMoreThanOneItem() { Test.AssertException <ObjectResultAssertionException>( () => { MyController <MvcController> .Instance() .Calling(c => c.FullObjectResultAction()) .ShouldReturn() .Object() .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter(), TestObjectFactory.GetOutputFormatter() }); }, "When calling FullObjectResultAction action in MvcController expected object result output formatters to have 3 items, but instead found 2."); }
public void CallingObjectResultApiWithStatusCodeShouldThrowException() { Test.AssertException <StatusCodeResultAssertionException>( () => { MyController <MvcController> .Instance() .Calling(c => c.StatusCodeAction()) .ShouldReturn() .StatusCode(result => result .ContainingOutputFormatters(new List <IOutputFormatter> { TestObjectFactory.GetOutputFormatter(), new CustomOutputFormatter(), TestObjectFactory.GetOutputFormatter() })); }, "When calling StatusCodeAction action in MvcController expected status code result to inherit ObjectResult, but in fact it did not."); }