public void ReturnTripDetails_FromTheRepo() { // Arrange var mockedTripRepo = new Mock <IProjectableRepositoryEf <Trip> >(); var mockedUserTripRepo = new Mock <IProjectableRepositoryEf <UsersTrips> >(); var mockedCityService = new Mock <ICityService>(); var mockedTagService = new Mock <ITagService>(); var mockedDateTimpeProvider = new Mock <IDateTimeProvider>(); var mockedMappingProvider = new Mock <IMappingProvider>(); var mockedUnitOfWork = new Mock <IUnitOfWorkEF>(); var tripService = new TripService( () => mockedUnitOfWork.Object, mockedUserTripRepo.Object, mockedCityService.Object, mockedMappingProvider.Object, mockedTagService.Object, mockedTripRepo.Object, mockedDateTimpeProvider.Object); TripDetails expected = new TripDetails() { Id = 1 }; var data = new List <Trip>() { new Trip() { Id = 1, IsDeleted = false, IsFinished = false } }; mockedTripRepo.Setup(x => x.GetFirstMapped <TripDetails>(It.IsAny <Expression <Func <Trip, bool> > >())) .Returns((Expression <Func <Trip, bool> > predicate) => { return(data.Where(predicate.Compile()) .Select(x => expected) .FirstOrDefault()); }); // Act var result = tripService.GetTripDetails(1); // Assert Assert.AreSame(expected, result); }