Beispiel #1
0
        public IList <Product> Get(string sortOption)
        {
            List <Product> sortedResult = service.GetProducts();

            if (!string.IsNullOrWhiteSpace(sortOption))
            {
                if (sortOption == SortOption.Low.ToString()) // Order by Price
                {
                    return(sortedResult.OrderBy(t => t.price).ToList());
                }
                else if (sortOption == SortOption.High.ToString())
                {
                    return(sortedResult.OrderByDescending(t => t.price).ToList());
                }
                else if (sortOption == SortOption.Ascending.ToString())
                {
                    return(sortedResult.OrderBy(t => t.name).ToList());
                }
                else if (sortOption == SortOption.Descending.ToString())
                {
                    return(sortedResult.OrderByDescending(t => t.name).ToList());
                }
                else if (sortOption == SortOption.Recommended.ToString())
                {
                    return(GetPopularProducts());
                }
            }

            return(sortedResult);
        }
Beispiel #2
0
        public void GetProducts_Returns_Products()
        {
            var wxConfig = new WxConfig()
            {
                Token            = "c8e0d9d2-7d0d-4aa4-8cf1-a48c40384988",
                WolliesXEndPoint = "http://dev-wooliesx-recruitment.azurewebsites.net/api/"
            };

            var service = new WooliesXService(wxConfig);

            var result = service.GetProducts();

            Assert.NotNull(result);
        }