コード例 #1
0
        public void _Details_Returns_one_Todo()
        {
            var todo = todosList.First();

            //specify the mockRepo return
            _mockRepository.Setup(repo => repo.getTodoBy(It.IsAny <Func <ToDoItemModel, bool> >())).Returns(todo);

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

            //Call the controller action
            var result = controller._Details(todo.id);

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

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