Ejemplo n.º 1
0
        public async ValueTask <ActionResult> Post([FromBody] AddOrderReq req)
        {
            var cmd = new CreateOrderMsg("0", this.TransformToOrderItemVM(req.Items));
            var vm  = await this.mediator.Send(cmd);

            return(this.Created(new Uri($"{this.Request.GetDisplayUrl()}/api/Order/{vm.Id}"), vm));
        }
Ejemplo n.º 2
0
        public async Task CreateOrder()
        {
            var msg = new CreateOrderMsg("0", new[]
            {
                new OrderItemRst(this.item),
            });

            await this.mockRepository.Save(Arg.Any <Order>());

            var svc    = new CreateOrderSvc(this.itemsTranslator, this.mockRepository);
            var actual = await svc.Handle(msg, new CancellationToken());

            actual.Id.Should().Be(this.result.Id);
            actual.Status.Should().Be(this.result.Status);
            actual.Items.Should().BeEquivalentTo(this.result.Items.AsEnumerable());
        }