public TechChallengeController(IOptions <WooliesX> configuration, IProductSorter productSorter, ITrolleyService trolleryService) { _configuration = configuration?.Value; _productSorter = productSorter; _trolleryService = trolleryService; }
public async Task Should_ReturnLowToHighPrice_When_SortOptionIsHigh() { //Arrange var products = new List <Product> { new Product() { Name = "A", Price = (decimal)5.0, Quantity = (decimal)1.0 }, new Product() { Name = "C", Price = (decimal)10.0, Quantity = (decimal)1.0 }, new Product() { Name = "B", Price = (decimal)2.0, Quantity = (decimal)1.0 } }; var wooliesxMock = new Mock <IWooliesX>(); wooliesxMock.Setup(m => m.GetProducts()).ReturnsAsync(products); //Act var wooliesx = new WooliesX(); var actual = await wooliesx.GetSortedProducts(SortOption.Low); var expected = new List <Product> { new Product() { Name = "C", Price = (decimal)2.0, Quantity = (decimal)1.0 }, new Product() { Name = "A", Price = (decimal)5.0, Quantity = (decimal)1.0 }, new Product() { Name = "B", Price = (decimal)10.0, Quantity = (decimal)1.0 } }; // Assert Assert.Equal(expected, actual); }
public ApiCaller(IOptions <WooliesX> configuration) { _configuration = configuration.Value; }
public async Task <decimal> GetTrolleyTotal([FromBody] JObject trolley) { var wooliesx = new WooliesX(_configDetails); return(await wooliesx.GetTrolleyTotal(trolley)); }
public async Task <IList <Product> > GetProducts([FromQuery] SortOption sortOption) { var wooliesx = new WooliesX(_configDetails); return(await wooliesx.GetSortedProducts(sortOption)); }