Esempio n. 1
0
        public void Can_reduce_an_item_without_removing_it()
        {
            var box = new Box();
            var item = new Item {Name = "Test Item"};

            box.AddItem(2, item);

            Assert.Equal(2, box.Contents.First(x => x.Item == item).Quantity);

            box.ReduceItem(1, item);

            Assert.Equal(1, box.Contents.First(x => x.Item == item).Quantity);
        }
Esempio n. 2
0
        public void Reducing_an_item_by_equal_or_more_than_current_quantity_removes_item()
        {
            var box = new Box();
            var item = new Item {Name = "Test Item"};

            box.AddItem(2, item);

            Assert.Equal(2, box.Contents.First(x => x.Item == item).Quantity);

            box.ReduceItem(2, item);

            Assert.Equal(0, box.Contents.Count(x => x.Item == item));
        }
Esempio n. 3
0
 public void Passing_negative_quantity_to_reduce_item_throws_error()
 {
     var box = new Box();
     Assert.Throws<InvalidOperationException>(() => box.ReduceItem(1, new Item()));
 }