Example #1
0
        public async Task Handle_Uses_SaveAllAsync_From_IUnitOfWork()
        {
            // Arrange
            Arrange();

            var sut = new ApproveDeliveryCommandHandler(
                _deliveryRepository.Object,
                _existsDelivery.Object,
                _userContext.Object,
                _unitOfWork.Object);
            // Act
            await sut.Handle(NewApproveDeliveryCommand(), new CancellationToken());

            // Assert
            _unitOfWork.Verify(u => u.SaveAllAsync(), Times.Once);
        }
Example #2
0
        public async Task Handle_Uses_EnforceRule_From_IExistsDeliverySpecification()
        {
            // Arrange
            Arrange();

            var sut = new ApproveDeliveryCommandHandler(
                _deliveryRepository.Object,
                _existsDelivery.Object,
                _userContext.Object,
                _unitOfWork.Object);
            // Act
            await sut.Handle(NewApproveDeliveryCommand(), new CancellationToken());

            // Assert
            _existsDelivery.Verify(s => s.EnforceRule(It.IsAny <Delivery>(), It.IsAny <string>()), Times.Once);
        }
Example #3
0
        public async Task Handle_Uses_Update_From_IDeliveryRepository_With_Delivery_State_Is_Approved()
        {
            // Arrange
            Arrange();

            var sut = new ApproveDeliveryCommandHandler(
                _deliveryRepository.Object,
                _existsDelivery.Object,
                _userContext.Object,
                _unitOfWork.Object);
            // Act
            await sut.Handle(NewApproveDeliveryCommand(), new CancellationToken());

            // Assert
            _deliveryRepository.Verify(r => r.Update(It.Is <Delivery>(d => d.State == DeliveryState.Approved)), Times.Once);
        }
Example #4
0
        public async Task Handle_Uses_GetAsync_From_IDeliveryRepository_To_Get_The_Delivery()
        {
            // Arrange
            Arrange();

            var sut = new ApproveDeliveryCommandHandler(
                _deliveryRepository.Object,
                _existsDelivery.Object,
                _userContext.Object,
                _unitOfWork.Object);
            // Act
            await sut.Handle(NewApproveDeliveryCommand(), new CancellationToken());

            // Assert
            _deliveryRepository.Verify(r => r.GetAsync(It.IsAny <Expression <Func <Delivery, bool> > >()), Times.Once);
        }