示例#1
0
        public void Add_POST_ReturnsRedirectToActionResultIfModelStateIsValid()
        {
            //arrange
            var rep        = new Mock <ITicketRepository>();
            var controller = new TicketingController(rep.Object);
            var model      = new TicketViewModel();

            //act
            var result = controller.Add(model);

            //assert
            Assert.IsType <RedirectToActionResult>(result);
        }
示例#2
0
        public void Add_POST_ReturnsViewResultIfModelStateIsInValid()
        {
            //arrange
            var rep        = new Mock <ITicketRepository>();
            var controller = new TicketingController(rep.Object);
            var model      = new TicketViewModel();

            //act
            controller.ModelState.AddModelError("Error", "This is a fake error");
            var result = controller.Add(model);

            //assert
            Assert.IsType <ViewResult>(result);
        }