public async Task FindByIdAsync_MakesCorrectCallsAndReturnsCorrectObject() { // Arrange var expectedPrimaryKeyId = 1; var expectedTodoDTO = new TodoDTO() { Id = expectedPrimaryKeyId, Name = "Test Todo", IsComplete = true }; var todo = new Todo(); var mockedRepository = new Mock <ITodosRepository>(); var mockedMapper = new Mock <IMapper>(); mockedRepository.Setup(r => r.FindByIdAsync(expectedPrimaryKeyId)).ReturnsAsync(todo); mockedMapper.Setup(m => m.Map <Todo, TodoDTO>(todo)).Returns(expectedTodoDTO); var service = new TodosService(mockedMapper.Object, mockedRepository.Object); // Action var actualTodoDTO = await service.FindByIdAsync(expectedPrimaryKeyId); // Assert Assert.NotNull(actualTodoDTO); Assert.Equal(expectedTodoDTO, actualTodoDTO); mockedRepository.Verify(r => r.FindByIdAsync(expectedPrimaryKeyId), Times.Once()); mockedMapper.Verify(m => m.Map <Todo, TodoDTO>(todo), Times.Once()); }