Exemplo n.º 1
0
        public async Task Index_ReturnsViewResult_WithAListOfTodosAndDones()
        {
            var result = await _todosController.Index();

            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.IsAssignableFrom <TodoViewModel>(viewResult.ViewData.Model);
        }
Exemplo n.º 2
0
        public void Index()
        {
            // Arrange
            TodosController controller = new TodosController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
        public void Index_Returns_all_Todos()
        {
            //specify the mockRepo return
            _mockRepository.Setup(repo => repo.getAllTodos()).Returns(todosList);

            //instantiate the controller
            var controller = new TodosController(_mockRepository.Object, _logger);

            //Call the controller action
            var result = controller.Index();

            //Assert the result
            Assert.NotNull(result);
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = viewResult.Model;

            //Assert the model
            model.Should().BeEquivalentTo(todosList, options => options.ComparingByMembers <ToDoItemModel>());
        }