public void GetAll_WhenNoneFound_ShouldReturnAnEmptyCollection() { // Arrange MockToDoTaskRepository.Setup(r => r.GetAll()).Returns(new List <ToDoTask>()); var controller = new ToDoTasksController(MockToDoTaskRepository.Object, MockLogger.Object); // Act var result = controller.GetAll().ToList(); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.Count()); }
public void GetAll_WhenTasksFound_ShouldReturnTasks() { // Arrange MockToDoTaskRepository.Setup(r => r.GetAll()).Returns(MockTodosList); var controller = new ToDoTasksController(MockToDoTaskRepository.Object, MockLogger.Object); // Act var result = controller.GetAll().ToList(); // Assert Assert.IsNotNull(result); Assert.AreEqual(2, result.Count()); Assert.AreEqual(MockTodosList[0].Id, result[0].Id); Assert.AreEqual(MockTodosList[0].TaskDescription, result[0].TaskDescription); Assert.AreEqual(MockTodosList[0].TaskCreationTime, result[0].TaskCreationTime); Assert.AreEqual(MockTodosList[0].TaskCompleted, result[0].TaskCompleted); Assert.AreEqual(MockTodosList[1].Id, result[1].Id); Assert.AreEqual(MockTodosList[1].TaskDescription, result[1].TaskDescription); Assert.AreEqual(MockTodosList[1].TaskCreationTime, result[1].TaskCreationTime); Assert.AreEqual(MockTodosList[1].TaskCompleted, result[1].TaskCompleted); }