Exemple #1
0
        public async Task Setup()
        {
            var client = Api.CreateClient();

            var model = new CalculateTrolley
            {
                Products = new List <Api.Models.Product>
                {
                    new Api.Models.Product {
                        Name = "Item1", Price = 4
                    }
                },
                Quantities = new List <Quantity>
                {
                    new Quantity {
                        Name = "Item1", QuantityValue = 2
                    }
                },
                Specials = new List <Api.Models.Special>
                {
                    new Api.Models.Special
                    {
                        Quantities = new List <Quantity>
                        {
                            new Quantity {
                                Name = "Item1", QuantityValue = 1
                            }
                        },
                        Total = 3
                    }
                }
            };

            var json = JsonConvert.SerializeObject(model);

            var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

            _response = await client.PostAsync($"api/trolleyCalculator", stringContent);

            var content = await _response.Content.ReadAsStringAsync();

            _view = JsonConvert.DeserializeObject <decimal>(content);
        }
        public async Task <ActionResult> Create([FromBody] CalculateTrolley request)
        {
            var calculateResponse = await _mediator.Send(request.Map());

            return(Ok(calculateResponse));
        }