public void ShouldReturnResultShouldThrowExceptionWithIncorrectModelType() { Test.AssertException <InvocationResultAssertionException>( () => { MyViewComponent <StringComponent> .InvokedWith(c => c.Invoke()) .ShouldReturn() .Result(TestObjectFactory.GetListOfResponseModels()); }, "When invoking StringComponent expected result to be List<ResponseModel>, but instead received String."); }
public void ShouldReturnResultShouldThrowExceptionWithIncorrectModelType() { Test.AssertException <ActionResultAssertionException>( () => { MyMvc .Controller <MvcController>() .Calling(c => c.GenericInterfaceAction()) .ShouldReturn() .Result(TestObjectFactory.GetListOfResponseModels()); }, "When calling GenericInterfaceAction action in MvcController expected action result to be List<ResponseModel>, but instead received ResponseModel."); }
public void WithResponseModelShouldThrowExceptionWithDeeplyUnequalResponseModel() { var another = TestObjectFactory.GetListOfResponseModels(); another.Add(new ResponseModel()); MyWebApi .Controller <WebApiController>() .Calling(c => c.HttpResponseMessageAction()) .ShouldReturn() .HttpResponseMessage() .WithResponseModel(another); }
public void WithModelShouldThrowExceptionWithNullModel() { Test.AssertException <ResponseModelAssertionException>( () => { MyViewComponent <ViewResultComponent> .InvokedWith(c => c.Invoke("All")) .ShouldReturn() .View(view => view .WithModel(TestObjectFactory.GetListOfResponseModels())); }, "When invoking ViewResultComponent expected response model to be List<ResponseModel>, but instead received ResponseModel."); }
public void WithModelShouldThrowExceptionWithNullModelForPartials() { Test.AssertException <ResponseModelAssertionException>( () => { MyController <MvcController> .Instance() .Calling(c => c.DefaultPartialView()) .ShouldReturn() .PartialView() .WithModel(TestObjectFactory.GetListOfResponseModels()); }, "When calling DefaultPartialView action in MvcController expected response model to be of List<ResponseModel> type, but instead received null."); }
public void WithGenericModelShouldThrowExceptionWithListOfModels() { Test.AssertException <ResponseModelAssertionException>( () => { MyViewComponent <ViewResultComponent> .Instance() .InvokedWith(c => c.Invoke("All")) .ShouldReturn() .View("SomeView") .WithModel <List <ResponseModel> >(TestObjectFactory.GetListOfResponseModels()); }, "When invoking ViewResultComponent expected response model to be of List<ResponseModel> type, but instead received ResponseModel."); }
public void ShouldReturnResultShouldThrowExceptionWithDifferentModel() { Test.AssertException <InvocationResultAssertionException>( () => { var model = TestObjectFactory.GetListOfResponseModels(); model.Add(new ResponseModel()); MyController <MvcController> .Instance() .Calling(c => c.GenericInterfaceAction()) .ShouldReturn() .Result(model); }, "When calling GenericInterfaceAction action in MvcController expected result to be List<ResponseModel>, but instead received ResponseModel."); }
public void WithModelShouldThrowExceptionWithIncorrectModel() { Test.AssertException <ResponseModelAssertionException>( () => { var model = TestObjectFactory.GetListOfResponseModels(); model[0].IntegerValue = int.MaxValue; MyController <MvcController> .Instance() .Calling(c => c.IndexView()) .ShouldReturn() .View("Index") .WithModel(model); }, "When calling IndexView action in MvcController expected response model List<ResponseModel> to be the given model, but in fact it was a different one."); }
public void WithModelShouldThrowExceptionWithIncorrectModelForPartials() { Test.AssertException <ResponseModelAssertionException>( () => { var model = TestObjectFactory.GetListOfResponseModels(); model[0].IntegerValue = int.MaxValue; MyController <MvcController> .Instance() .Calling(c => c.IndexPartialView()) .ShouldReturn() .PartialView(partialView => partialView .WithModel(model)); }, "When calling IndexPartialView action in MvcController expected response model List<ResponseModel> to be the given model, but in fact it was a different one. Difference occurs at 'List<ResponseModel>[0].IntegerValue'. Expected a value of '2147483647', but in fact it was '1'."); }
public dynamic DynamicResult() { return(TestObjectFactory.GetListOfResponseModels()); }
public List <ResponseModel> GenericActionWithListCollection() { return(TestObjectFactory.GetListOfResponseModels()); }
public MvcController(IInjectedService injectedService) { this.InjectedService = injectedService; this.responseModel = TestObjectFactory.GetListOfResponseModels(); }
public ResponseMessageHandler() { this.responseModel = TestObjectFactory.GetListOfResponseModels(); }