コード例 #1
0
 public void PostShouldValidateModelState()
 {
     controller
     .Calling(c => c.Post(TestObjectFactory.GetInvalidModel()))
     .ShouldHave()
     .ModelStateFor <SaveProjectRequestModel>()
     .ContainingModelStateErrorFor(m => m.Name);
 }
コード例 #2
0
 public void PostShouldValidateModelStateByIvo()
 {
     MyWebApi
     .Controller <ProjectsController>()
     .WithResolvedDependencyFor(TestObjectFactory.GetProjectsService())
     .Calling(c => c.Post(TestObjectFactory.GetInvalidModel()))
     .ShouldHave()
     .InvalidModelState();
 }
コード例 #3
0
 public void PostShouldReturnBadRequestWithInvalidModel()
 {
     controller
     .Calling(c => c.Post(TestObjectFactory.GetInvalidModel()))
     .ShouldReturn()
     .BadRequest()
     .WithModelStateFor <SaveProjectRequestModel>()
     .ContainingModelStateErrorFor(m => m.Name);
 }
コード例 #4
0
 public void PostShouldReturnBadRequestWithInvalidModel()
 {
     MyWebApi
     .Controller <ProjectsController>()
     .WithResolvedDependencyFor(TestObjectFactory.GetProjectsService())
     .Calling(c => c.Post(TestObjectFactory.GetInvalidModel()))
     .ShouldReturn()
     .BadRequest()
     .WithModelStateFor <SaveProjectRequestModel>()
     .ContainingModelStateErrorFor(m => m.Name);
 }
コード例 #5
0
        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());
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }