public void Then_the_quantity_of_that_product_should_update_to_match() { var newQty = new NonNegativeQuantity(5); _basket.ChangeQuantityOfProduct(newQty, _product); Assert.AreEqual(newQty.Value, _basket.Items().FirstOrDefault(i => i.Product == _product).Quantity.Value); }
public void Then_the_product_should_be_removed() { var newQty = new NonNegativeQuantity(0); _basket.ChangeQuantityOfProduct(newQty, _product); Assert.IsNull(_basket.Items().FirstOrDefault(i => i.Product == _product)); }
public void ChangeQuantityOfProduct(NonNegativeQuantity quantity, Product product) { if (BasketContainsAnItemFor(product)) { if (quantity.IsZero()) { Remove(product); } else { GetItemFor(product).ChangeItemQtyTo(quantity); } } }
public void ChangeItemQtyTo(NonNegativeQuantity quantity) { Quantity = quantity; }
public void IncreaseItemQtyBy(NonNegativeQuantity quantity) { Quantity = Quantity.Add(quantity); }
public BasketItem(Product product, Basket basket, NonNegativeQuantity quantity) { _product = product; _basket = basket; Quantity = quantity; }
public Ketchup() { Extra = NonNegativeQuantity.Get(0); }
public NonNegativeQuantity Add(NonNegativeQuantity quantity) { return(new NonNegativeQuantity(_value + quantity._value)); }
public Mayo() { Extra = NonNegativeQuantity.Get(0); }
public NonNegativeQuantity Add(NonNegativeQuantity quantity) { return new NonNegativeQuantity(_value + quantity._value); }