Beispiel #1
0
        public async Task Order_Should_Be_Canceled()
        {
            // Arrange
            await Order_Should_Be_Created();

            Guid orderId = Guid.Empty;

            UsingDbContext(db =>
            {
                var order = db.Orders.First();
                order.OrderStatus.ShouldNotBe(OrderStatus.Canceled);
                order.CanceledTime.ShouldBeNull();
                orderId = order.Id;
            });

            var cancelRequestDto = new CancelOrderInput
            {
                CancellationReason = "Repeat orders."
            };

            // Act
            var response = await _orderAppService.CancelAsync(orderId, cancelRequestDto);

            // Assert
            response.ShouldNotBeNull();
            response.OrderStatus.ShouldBe(OrderStatus.Canceled);
            response.CanceledTime.ShouldNotBeNull();
            response.CancellationReason.ShouldBe("Repeat orders.");

            UsingDbContext(db =>
            {
                var order = db.Orders.FirstOrDefault(o => o.Id == orderId);
                order.ShouldNotBeNull();
                order.OrderStatus.ShouldBe(OrderStatus.Canceled);
                order.CancellationReason.ShouldBe("Repeat orders.");
            });
        }
Beispiel #2
0
 public Task <OrderDto> CancelAsync(Guid id, CancelOrderInput input)
 {
     return(_service.CancelAsync(id, input));
 }
Beispiel #3
0
        public async Task <ActionResult> CancelAsync([FromRoute] long id)
        {
            await _orderSrv.CancelAsync(id);

            return(NoContent());
        }