public void GivenExistingTodo_DeleteByIndex_RepositoryDeleteRemoveCorrectTodo() { var mockTodos = new TodoModel[] { new TodoModel() { Id = Guid.Parse("0a000300-0600-0000-0100-0000f0700001"), Title = "Test", Description = "Test Description", Status = TodoStatus.Open, DueDate = new DateTime(2021, 3, 4, 12, 30, 00), CreatedOn = new DateTime(2020, 11, 12, 11, 55, 13), }, new TodoModel() { Id = Guid.Parse("0a000300-0600-0020-0100-0000f0300002"), Title = "Second", Description = "Second Test", Status = TodoStatus.InProgress, DueDate = new DateTime(2021, 1, 24, 1, 22, 33), CreatedOn = new DateTime(2020, 10, 11, 12, 13, 14), }, }; int index = 1; MockRepository.Setup(a => a.GetAll()).Returns(mockTodos); MockRepository.Setup(a => a.GetById(mockTodos[index].Id)).Returns(mockTodos[index]); MockRepository.Setup(a => a.Delete(mockTodos[index].Id)); var service = new Service.TodoService(MockRepository.Object); var isDeleted = service.DeleteByIndex(index); MockRepository.Verify(a => a.Delete(mockTodos[index].Id), Times.Once); }
public void GivenNotExistingTodo_DeleteByIndex_ReturnsFalse() { int index = 3; var service = new Service.TodoService(MockRepository.Object); var isDeleted = service.DeleteByIndex(index); Assert.False(isDeleted); }