public void ReviewTasksReturnTasks() { _repository.Setup(x => x.GetTasksForReview()).Returns(new List <Tasks> { new Tasks { TasksId = 1, Title = "Hello", Description = "Bananas", Complete = false }, new Tasks { TasksId = 2, Title = "Greetings", Description = "Bananas", Complete = false }, new Tasks { TasksId = 3, Title = "Bye", Description = "Bananas", Complete = false } }); _controller = new DeveloperController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.ReviewTasks() as ViewResult; Assert.IsNotNull(res); CollectionAssert.AllItemsAreInstancesOfType((ICollection)res.ViewData.Model, typeof(Tasks), "Not tasks"); _repository.Verify(x => x.GetTasksForReview(), Times.Exactly(1)); }
public void ReviewTasksPostDataUpdateNoError() { _repository.Setup(x => x.CompleteTask(It.IsAny <Tasks>())); _controller = new DeveloperController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.ReviewTasks(new Tasks()); Assert.IsNotNull(res); _repository.VerifyAll(); Assert.IsInstanceOfType(res, typeof(RedirectToActionResult)); }
public void ReviewTasksPostDataUpdateError() { _repository.Setup(x => x.CompleteTask(It.IsAny <Tasks>())).Throws(new Exception()); _controller = new DeveloperController(_repository.Object) { ControllerContext = MockHelper.FakeControllerContext(false) }; var res = _controller.ReviewTasks(new Tasks()); Assert.IsNotNull(res); _repository.VerifyAll(); _repository.Verify(x => x.CompleteTask(It.IsAny <Tasks>()), Times.Exactly(1)); }