Пример #1
0
 public void WhenTheNewModelIsInvalid_ThenTheNewViewIsReturned()
 {
     ToDoController controller = new ToDoController(null);
     controller.ModelState.AddModelError("key", "value");
     var result = controller.Create(new NewTodoVM());
     Assert.That(result, Is.TypeOf(typeof(ViewResult)));
 }
Пример #2
0
        public void WhenEditIsCalledForASpecificTodo_ThenTheEditActionReturnsTheEditViewForThatTodo()
        {
            ToDoController controller = new ToDoController(null);
            var result = controller.Edit(1) as ViewResult;
            var model = result.Model as EditViewModel;

            Assert.That(model.Id, Is.EqualTo(1));
        }
Пример #3
0
        public void WhenTheIndexActionIsExecuted_ThenItShouldReturnAViewResult()
        {
            _repository.Setup(r => r.GetTodos()).Returns(new List<TodoModel.Todo>());
            var controller = new ToDoController(_repository.Object);
            var result = controller.Index();

            Assert.That(result, Is.TypeOf(typeof(ViewResult)));
        }
Пример #4
0
        public void GivenAListOfTodos_WhenTheIndexActionIsExecuted_ThenTheFullListIsReturned()
        {
            _repository.Setup(r => r.GetTodos()).Returns(new List<TodoModel.Todo> { new TodoModel.Todo() });
            var controller = new ToDoController(_repository.Object);
            var result = controller.Index() as ViewResult;
            var model = result.Model as IList<TodoIndexVM>;

            Assert.That(model.Count, Is.EqualTo(1));
        }
Пример #5
0
 public void WhenTheNewModelIsValid_ThenTheIndexViewIsRedirectedTo()
 {
     ToDoController controller = new ToDoController(null);
     var result = controller.Create(new NewTodoVM());
     Assert.That(result, Is.TypeOf(typeof(RedirectToRouteResult)));
 }