コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }