public void WithUnitInStock_Should_Throw_ArgumentNullException_If_Products_Is_Null() { IQueryable <Product> products = null; int unitInStock = 0; var ex = Assert.Throws <ArgumentNullException>(() => ProductExtensions.WithUnitInStock(products, unitInStock)); Assert.Equal(nameof(products), ex.ParamName); }
public void WithUnitInStock_Should_Throw_ArgumentException_If_UnitInStock_Is_Less_Than_Zero() { IQueryable <Product> products = new Product[0].AsQueryable(); int unitInStock = -1; var ex = Assert.Throws <ArgumentException>(() => ProductExtensions.WithUnitInStock(products, unitInStock)); Assert.Equal(nameof(unitInStock), ex.ParamName); }
public void WithUnitInStock_Should_Return_Only_Products_With_Units_In_Stock_Greater_Than_The_Specified_Quantity() { 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.SetUnitInStock(2); p2.SetUnitInStock(3); p3.SetUnitInStock(1); IQueryable <Product> products = new Product[] { p1, p2, p3 }.AsQueryable(); int unitInStock = 1; var productsWithUnitInStock = ProductExtensions.WithUnitInStock(products, unitInStock).ToArray(); Assert.True(productsWithUnitInStock.All(p => p.UnitInStock > unitInStock)); }