public void OnSaleTill_Should_Throw_ArgumentNullException_If_Products_Is_Null() { IQueryable <Product> products = null; DateTime tillDate = DateTime.Today; var ex = Assert.Throws <ArgumentNullException>(() => ProductExtensions.OnSaleTill(products, tillDate)); Assert.Equal(nameof(products), ex.ParamName); }
public void OnSaleTill_Should_Return_Only_Products_OnSale_And_With_OnSaleTo_Date_Previous_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(DateTime.Today.AddDays(-5), DateTime.Today.AddDays(-1)); p2.SetOnSale(DateTime.Today.AddDays(-3), DateTime.Today); IQueryable <Product> products = new Product[] { p1, p2, p3 }.AsQueryable(); DateTime tillDate = DateTime.Today; var productsOnSale = ProductExtensions.OnSaleTill(products, tillDate).ToArray(); Assert.True(productsOnSale.All(p => p.IsOnSale && p.OnSaleTo <= tillDate)); }