public void OnSaleFrom_Should_Throw_ArgumentNullException_If_Products_Is_Null() { IQueryable <Product> products = null; DateTime fromDate = DateTime.Today; var ex = Assert.Throws <ArgumentNullException>(() => ProductExtensions.OnSaleFrom(products, fromDate)); Assert.Equal(nameof(products), ex.ParamName); }
public void OnSaleFrom_Should_Return_Only_Products_On_Sale_With_OnSaleFrom_Date_Greater_Than_The_Specified_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, null); IQueryable <Product> products = new Product[] { p1, p2, p3 }.AsQueryable(); DateTime fromDate = DateTime.Today; var productsOnSale = ProductExtensions.OnSaleFrom(products, fromDate).ToArray(); Assert.True(productsOnSale.All(p => p.IsOnSale && p.OnSaleFrom >= fromDate)); }