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 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);
        }        
示例#4
0
 public void ChangeQuantityOfProduct(NonNegativeQuantity quantity, Product product)
 {
     if (BasketContainsAnItemFor(product))
     {
         if (quantity.IsZero())
         {
             Remove(product);
         }
         else
         {
             GetItemFor(product).ChangeItemQtyTo(quantity);
         }
     }
 }
示例#5
0
 public void ChangeItemQtyTo(NonNegativeQuantity quantity)
 {
     Quantity = quantity;
 }
示例#6
0
 public void IncreaseItemQtyBy(NonNegativeQuantity quantity)
 {
     Quantity = Quantity.Add(quantity);
 }
示例#7
0
 public BasketItem(Product product, Basket basket, NonNegativeQuantity quantity)
 {
     _product = product;
     _basket  = basket;
     Quantity = quantity;
 }
 public Ketchup()
 {
     Extra = NonNegativeQuantity.Get(0);
 }
示例#9
0
 public NonNegativeQuantity Add(NonNegativeQuantity quantity)
 {
     return(new NonNegativeQuantity(_value + quantity._value));
 }
示例#10
0
 public Mayo()
 {
     Extra = NonNegativeQuantity.Get(0);
 }
示例#11
0
 public NonNegativeQuantity Add(NonNegativeQuantity quantity)
 {
     return new NonNegativeQuantity(_value + quantity._value);
 }