Esempio n. 1
0
        public async Task WhenNoPreviousDates_ReturnsMovementDate()
        {
            var movementDate = new DateTime(2015, 1, 1);
            var movement     = new Movement(1, AnyGuid, movementDate, userId);
            var dateService  = new OriginalMovementDate(historyRepository);

            Assert.Equal(movementDate, await dateService.Get(movement));
        }
        public async Task WhenNoPreviousDates_ReturnsMovementDate()
        {
            var movementDate = new DateTime(2015, 1, 1);
            var movement = new Movement(1, AnyGuid, movementDate, userId);
            var dateService = new OriginalMovementDate(historyRepository);

            Assert.Equal(movementDate, await dateService.Get(movement));
        }
Esempio n. 3
0
        public async Task WhenOnePreviousDate_ReturnsPreviousDate()
        {
            var movement = new Movement(1, AnyGuid, AnyDate, userId);

            var previousDate = new DateTime(2015, 1, 2);

            A.CallTo(() => historyRepository.GetByMovementId(A <Guid> .Ignored))
            .Returns(new[]
            {
                new MovementDateHistory(AnyGuid, previousDate)
            });

            var dateService = new OriginalMovementDate(historyRepository);

            Assert.Equal(previousDate, await dateService.Get(movement));
        }
        public async Task WhenOnePreviousDate_ReturnsPreviousDate()
        {
            var movement = new Movement(1, AnyGuid, AnyDate, userId);

            var previousDate = new DateTime(2015, 1, 2);

            A.CallTo(() => historyRepository.GetByMovementId(A<Guid>.Ignored))
                .Returns(new[]
                {
                    new MovementDateHistory(AnyGuid, previousDate)
                });

            var dateService = new OriginalMovementDate(historyRepository);

            Assert.Equal(previousDate, await dateService.Get(movement));
        }
        public async Task WhenMultiPreviousDates_ReturnsOldestPreviousDate()
        {
            var movement = new Movement(1, AnyGuid, AnyDate, userId);

            var oldestDateHistory = new MovementDateHistory(AnyGuid, new DateTime(2015, 1, 5));
            ObjectInstantiator<MovementDateHistory>.SetProperty(m => m.DateChanged, new DateTime(2015, 10, 10), oldestDateHistory);

            var otherDateHistory = new MovementDateHistory(AnyGuid, new DateTime(2015, 1, 3));
            ObjectInstantiator<MovementDateHistory>.SetProperty(m => m.DateChanged, new DateTime(2015, 10, 11), otherDateHistory);

            A.CallTo(() => historyRepository.GetByMovementId(A<Guid>.Ignored))
                .Returns(new[]
                {
                    oldestDateHistory,
                    otherDateHistory
                });

            var dateService = new OriginalMovementDate(historyRepository);

            Assert.Equal(oldestDateHistory.PreviousDate, await dateService.Get(movement));
        }
Esempio n. 6
0
        public async Task WhenMultiPreviousDates_ReturnsOldestPreviousDate()
        {
            var movement = new Movement(1, AnyGuid, AnyDate, userId);

            var oldestDateHistory = new MovementDateHistory(AnyGuid, new DateTime(2015, 1, 5));

            ObjectInstantiator <MovementDateHistory> .SetProperty(m => m.DateChanged, new DateTime(2015, 10, 10), oldestDateHistory);

            var otherDateHistory = new MovementDateHistory(AnyGuid, new DateTime(2015, 1, 3));

            ObjectInstantiator <MovementDateHistory> .SetProperty(m => m.DateChanged, new DateTime(2015, 10, 11), otherDateHistory);

            A.CallTo(() => historyRepository.GetByMovementId(A <Guid> .Ignored))
            .Returns(new[]
            {
                oldestDateHistory,
                otherDateHistory
            });

            var dateService = new OriginalMovementDate(historyRepository);

            Assert.Equal(oldestDateHistory.PreviousDate, await dateService.Get(movement));
        }