Esempio n. 1
0
        public async Task <int> Generate(Guid notificationId)
        {
            var maxAllowedMovements = (await shipmentRepository.GetByNotificationId(notificationId)).NumberOfShipments;
            var currentMovements    = (await movementRepository.GetAllMovements(notificationId)).ToArray();

            if (currentMovements.Length == maxAllowedMovements)
            {
                throw new InvalidOperationException(
                          string.Format("Cannot create a new movement number for notification {0} because there are no more available.",
                                        notificationId));
            }

            return(await nextAvailableMovementNumberGenerator.GetNext(notificationId));
        }
        public async Task NoMovements_ReturnsOne()
        {
            var result = await nextAvailableMovementNumberGenerator.GetNext(NotificationId);

            Assert.Equal(1, result);
        }