Exemplo n.º 1
0
        public IEnumerable <Product> GetProducts(string sortOption)
        {
            SortOption sortBy;

            if (string.IsNullOrWhiteSpace(sortOption))
            {
                throw new ArgumentNullException(nameof(sortOption));
            }

            if (!Enum.TryParse(sortOption, true, out sortBy))
            {
                throw new ArgumentException(nameof(sortOption));
            }

            var products = _productServiceAgent.GetProducts();
            var store    = new WooliesStore();

            store.Load(products);
            return(store.SortBy(SimpleSortFactory.Create(sortBy)));
        }
Exemplo n.º 2
0
 public void GivenSortOptionIsNullThrowsException()
 {
     // act & assert
     Assert.Throws <ArgumentNullException>(() => _sut.SortBy(null));
 }