public void PostShouldValidateModelState() { controller .Calling(c => c.Post(TestObjectFactory.GetInvalidModel())) .ShouldHave() .ModelStateFor <SaveProjectRequestModel>() .ContainingModelStateErrorFor(m => m.Name); }
public void PostShouldValidateModelStateByIvo() { MyWebApi .Controller <ProjectsController>() .WithResolvedDependencyFor(TestObjectFactory.GetProjectsService()) .Calling(c => c.Post(TestObjectFactory.GetInvalidModel())) .ShouldHave() .InvalidModelState(); }
public void PostShouldReturnBadRequestWithInvalidModel() { controller .Calling(c => c.Post(TestObjectFactory.GetInvalidModel())) .ShouldReturn() .BadRequest() .WithModelStateFor <SaveProjectRequestModel>() .ContainingModelStateErrorFor(m => m.Name); }
public void PostShouldReturnBadRequestWithInvalidModel() { MyWebApi .Controller <ProjectsController>() .WithResolvedDependencyFor(TestObjectFactory.GetProjectsService()) .Calling(c => c.Post(TestObjectFactory.GetInvalidModel())) .ShouldReturn() .BadRequest() .WithModelStateFor <SaveProjectRequestModel>() .ContainingModelStateErrorFor(m => m.Name); }
public void PostShouldReturnBadRequestWithInvalidModel() { var controller = new ProjectsController(TestObjectFactory.GetProjectsService()); controller.Configuration = new HttpConfiguration(); var model = TestObjectFactory.GetInvalidModel(); controller.Validate(model); var result = controller.Post(model); Assert.AreEqual(typeof(InvalidModelStateResult), result.GetType()); }
public void PostShouldValidateModelState() { var controller = new ProjectsController(TestObjectFactory.GetProjectsService()); controller.Configuration = new HttpConfiguration(); var model = TestObjectFactory.GetInvalidModel(); controller.Validate(model); var result = controller.Post(model); Assert.IsFalse(controller.ModelState.IsValid); }
public void PostShouldValidateModelState() { MyWebApi .Controller <ProjectsController>() .WithResolvedDependencyFor(TestObjectFactory.GetProjectsService()) .Calling(c => c.Post(TestObjectFactory.GetInvalidModel())) .ShouldHave() .InvalidModelState(); //var controller = new ProjectsController(TestObjectFactory.GetProjectsService()); //controller.Configuration = new HttpConfiguration(); //var model = TestObjectFactory.GetInvalidModel(); //controller.Validate(model); //var result = controller.Post(model); //Assert.IsFalse(controller.ModelState.IsValid); }