public void TestTodoService_GetAll_ShouldCallFindAllRepositoryAndAutoMapper() { // Arrange var expectedTodos = new TodoModel[] { }; Mock <IRepository <TodoModel> > todoRepository = new Mock <IRepository <TodoModel> >(); todoRepository.Setup(x => x.FindAll()) .Returns(expectedTodos.AsQueryable()); var mapperMock = new Mock <IMapper>(); mapperMock.Setup(m => m.Map <IEnumerable <Todo> >(It.IsAny <IEnumerable <TodoModel> >())) .Returns(It.IsAny <IEnumerable <Todo> >()); var cacheMock = new Mock <ICacheProvider>(); var todoService = new TodoService(todoRepository.Object, mapperMock.Object, cacheMock.Object); // Act var results = todoService.GetAllData(); // Assert todoRepository.Verify(x => x.FindAll(), Times.Once); mapperMock.Verify(x => x.Map <IEnumerable <Todo> >(It.IsAny <IEnumerable <TodoModel> >()), Times.Once); }