コード例 #1
0
 public TechChallengeController(IOptions <WooliesX> configuration, IProductSorter productSorter,
                                ITrolleyService trolleryService)
 {
     _configuration   = configuration?.Value;
     _productSorter   = productSorter;
     _trolleryService = trolleryService;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public ApiCaller(IOptions <WooliesX> configuration)
 {
     _configuration = configuration.Value;
 }
コード例 #4
0
        public async Task <decimal> GetTrolleyTotal([FromBody] JObject trolley)
        {
            var wooliesx = new WooliesX(_configDetails);

            return(await wooliesx.GetTrolleyTotal(trolley));
        }
コード例 #5
0
        public async Task <IList <Product> > GetProducts([FromQuery] SortOption sortOption)
        {
            var wooliesx = new WooliesX(_configDetails);

            return(await wooliesx.GetSortedProducts(sortOption));
        }