public async Task MustReturnTheBestMarketToPurchase()
        {
            _recommendsMarket.Items.Add(new RecommendsMarketItem {
                Market = "tonin", Name = "Linguica", Price = 9.05d, SearchableName = "linguica"
            });
            _recommendsMarket.Items.Add(new RecommendsMarketItem {
                Market = "savegnago", Name = "Iorgute", Price = 1.34d, SearchableName = "iorgute"
            });
            _recommendsMarket.Items.Add(new RecommendsMarketItem {
                Market = "savegnago", Name = "Agua", Price = 1.64d, SearchableName = "agua"
            });

            var result = await _recommendsMarketService.GetRecommendsMarket(_request);

            Assert.Equal(3, result.Items.Count);
            Assert.Equal("savegnago", result.Market);
            Assert.Equal(9.05d, result.Items.FirstOrDefault(x => x.SearchableName == "linguica").Price);
            Assert.Equal(1.34d, result.Items.FirstOrDefault(x => x.SearchableName == "iorgute").Price);
            Assert.Equal(1.64d, result.Items.FirstOrDefault(x => x.SearchableName == "agua").Price);
            Assert.Equal(12.03d, Math.Round(result.TotalPrice, 2, MidpointRounding.AwayFromZero));
        }
示例#2
0
        public async Task <IActionResult> GetRecommendsMarketAsync([FromBody] List <string> items)
        {
            try
            {
                var result = await _recommendsMarketService.GetRecommendsMarket(items);

                return(Ok(result));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }