Exemplo n.º 1
0
        public async Task ProcessAsync_Uses_SaveAllAsync_From_IUnitOfWork()
        {
            // Arrange
            var sut = new DeliveriesTimedHostedService(Configuration, _deliveryRepository.Object, _unitOfWork.Object);
            // Act
            await sut.ProcessAsync(null);

            // Assert
            _unitOfWork.Verify(u => u.SaveAllAsync(), Times.Once);
        }
Exemplo n.º 2
0
        public async Task ProcessAsync_Uses_GetAllAsync_From_IDeliveryRepository_To_Get_The_Ended_Deliveries()
        {
            // Arrange
            var sut = new DeliveriesTimedHostedService(Configuration, _deliveryRepository.Object, _unitOfWork.Object);
            // Act
            await sut.ProcessAsync(null);

            // Assert
            _deliveryRepository.Verify(r => r.GetAllAsync(It.IsAny <Expression <Func <Delivery, bool> > >()), Times.Once);
        }
Exemplo n.º 3
0
        public async Task ProcessAsync_Uses_Update_From_IDeliveryRepository_As_Many_Times_As_Deliveries_Retrieved_To_Update_The_Expired_Deliveries()
        {
            // Arrange
            _deliveryRepository.Setup(r => r.GetAllAsync(It.IsAny <Expression <Func <Delivery, bool> > >())).ReturnsAsync(NewDeliveries());
            var sut = new DeliveriesTimedHostedService(Configuration, _deliveryRepository.Object, _unitOfWork.Object);
            // Act
            await sut.ProcessAsync(null);

            // Assert
            _deliveryRepository.Verify(r => r.Update(It.Is <Delivery>(d => d.State == DeliveryState.Expired)), Times.Exactly(2));
        }