public async Task CanCancelPrenotifiedMovement() { A.CallTo(() => completedReceiptRepository.GetByMovementIdOrDefault(movementId)) .Returns <ImportMovementCompletedReceipt>(null); A.CallTo(() => receiptRepository.GetByMovementIdOrDefault(movementId)) .Returns <ImportMovementReceipt>(null); await cancelMovement.Cancel(movementId); Assert.True(movement.IsCancelled); }
public async Task <bool> HandleAsync(RecordCompletedReceipt message) { var completedReceipt = await completedReceiptRepository.GetByMovementIdOrDefault(message.ImportMovementId); if (completedReceipt == null) { await completeImportMovement.Complete(message.ImportMovementId, message.Date); await context.SaveChangesAsync(); } return(true); }
public async Task Cancel(Guid importMovementId) { var receipt = await receiptRepository.GetByMovementIdOrDefault(importMovementId); var completedReceipt = await completedReceiptRepository.GetByMovementIdOrDefault(importMovementId); if (receipt != null) { throw new InvalidOperationException(string.Format("Can't cancel movement {0} as it has been received", importMovementId)); } if (completedReceipt != null) { throw new InvalidOperationException(string.Format("Can't cancel movement {0} as it has been recovered / disposed of", importMovementId)); } var movement = await movementRepository.Get(importMovementId); movement.Cancel(); }