public void OnSale_Should_Throw_ArgumentNullException_If_Products_Is_Null()
        {
            IQueryable <Product> products = null;

            var ex = Assert.Throws <ArgumentNullException>(() => ProductExtensions.OnSale(products));

            Assert.Equal(nameof(products), ex.ParamName);
        }
        public void OnSale_Should_Return_Only_Products_OnSale_On_The_Current_Date()
        {
            var p1 = Product.Create("ean", "sku", "name", "url");
            var p2 = Product.Create("ean", "sku", "name", "url");
            var p3 = Product.Create("ean", "sku", "name", "url");

            p1.SetOnSale();
            p2.SetOnSale(DateTime.Today.AddDays(-1), DateTime.Today.AddMonths(1));

            IQueryable <Product> products = new Product[]
            {
                p1, p2, p3
            }.AsQueryable();

            var today = DateTime.Now;

            var productsOnSale = ProductExtensions.OnSale(products).ToArray();

            Assert.Equal(2, productsOnSale.Count());
            Assert.True(productsOnSale.All(p => p.IsOnSale && p.OnSaleFrom <= today && (!p.OnSaleTo.HasValue || p.OnSaleTo >= today)));
        }