public void TestGetAllSortedByDate_ShouldReturnCorrectly() { // Arrange var logs = new List <TrainingLog>() .AsQueryable(); var mockedLogRepository = new Mock <IRepository <TrainingLog> >(); mockedLogRepository.Setup(r => r.All) .Returns(logs); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedLogFactory = new Mock <ITrainingLogFactory>(); var mockedUserService = new Mock <IUserService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var service = new LogsService(mockedLogRepository.Object, mockedUnitOfWork.Object, mockedLogFactory.Object, mockedUserService.Object, mockedDateTimeProvider.Object); // Act var result = service.GetAllSortedByDate(); // Assert CollectionAssert.AreEqual(logs, result); }
public void TestGetAllSortedByDate_ShouldCallRepositoryAll() { // Arrange var mockedLogRepository = new Mock <IRepository <TrainingLog> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedLogFactory = new Mock <ITrainingLogFactory>(); var mockedUserService = new Mock <IUserService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var service = new LogsService(mockedLogRepository.Object, mockedUnitOfWork.Object, mockedLogFactory.Object, mockedUserService.Object, mockedDateTimeProvider.Object); // Act service.GetAllSortedByDate(); // Assert mockedLogRepository.Verify(r => r.All, Times.Once); }