public async Task WhenOrderDoesNotExist_ThenShouldReturnNotFound() { _repositoryMoq.Setup(x => x.GetAsync(It.IsAny <Guid>())) .ReturnsAsync((Order)null !); var handler = new ShipOrderHandler(_repositoryMoq.Object); var result = await handler.Handle(new ShipOrder(Guid.Empty), default); Assert.NotNull(result); Assert.Equal(CommandOutcome.NotFound, result.Outcome); }
public async Task WhenConcurrencyExceptionOccurs_ThenShouldReturnConflict() { var order = _mapper.Map <Order>(Orders.Order1); _repositoryMoq.Setup(x => x.GetAsync(It.IsAny <Guid>())) .ReturnsAsync(order); _repositoryMoq.Setup(x => x.UpdateOrderStateAsync(It.IsAny <Order>(), It.IsAny <OrderState>())) .ThrowsAsync(new ConcurrencyException()); var handler = new ShipOrderHandler(_repositoryMoq.Object); var result = await handler.Handle(new ShipOrder(Guid.Empty), default); Assert.NotNull(result); Assert.Equal(CommandOutcome.Conflict, result.Outcome); }
public async Task WhenOrderFailsToUpdate_ThenShouldReturnNotFound() { var order = _mapper.Map <Order>(Orders.Order1); _repositoryMoq.Setup(x => x.GetAsync(It.IsAny <Guid>())) .ReturnsAsync(order); _repositoryMoq.Setup(x => x.UpdateOrderStateAsync(It.IsAny <Order>(), It.IsAny <OrderState>())) .ReturnsAsync((Order)null !); var handler = new ShipOrderHandler(_repositoryMoq.Object); var result = await handler.Handle(new ShipOrder(Guid.Empty), default); Assert.NotNull(result); Assert.Equal(CommandOutcome.NotFound, result.Outcome); }