Example #1
0
        public async void DeliveryService_AssignCourierToDeliveryAsync_throws_exception_when_delivery_with_specified_id_is_not_exists()
        {
            // Arrange
            var dto = A.New <AssignCourierToDeliveryDtoSave>();

            _deliveryRepository.Setup(x => x.GetDeliveryByIdAsync(dto.DeliveryId)).ReturnsAsync(() => null);

            // Act
            Func <Task> action = async() => { await _service.AssignCourierToDeliveryAsync(dto); };

            // Assert
            await action.Should().ThrowAsync <KeyNotFoundException>().WithMessage($"Delivery not found with specified Id: {dto.DeliveryId}");

            _deliveryRepository.Verify(x => x.GetDeliveryByIdAsync(dto.DeliveryId), Times.Once());
        }