Esempio n. 1
0
        public void Subtract_Group_Of_Items_By_Index_Actually_Removes_Them_From_Catalogue(int quantity, int subtractQuantity, int result)
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();

            for (int i = 0; i < quantity; i++)
            {
                catalogue.AddItem(item);
            }

            int          itemCount    = catalogue.GetItemsCount(item);
            List <IItem> items        = catalogue.SubtractItems(0, subtractQuantity);
            int          itemCountNew = catalogue.GetItemsCount(item);
            int          difference   = itemCount - itemCountNew;

            Assert.That(difference.Equals(result));
        }
Esempio n. 2
0
        public void Get_Items_Count_Of_Empty_Catalogue()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();
            var        exception = Assert.Throws <EmptyContainerException>(() =>
            {
                catalogue.GetItemsCount(item);
            });

            Assert.That(exception.GetType() == typeof(EmptyContainerException));
        }
Esempio n. 3
0
        public void Check_If_Subtraction_Actually_Remove_Item_From_Catalogue()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      fakeItem  = new FakeItem();
            IItem      fakeItem2 = new FakeItemWithPrice();

            for (int i = 0; i < 100; i++)
            {
                catalogue.AddItem(fakeItem);
                catalogue.AddItem(fakeItem2);
            }

            int itemsCount = catalogue.GetItemsCount(fakeItem2);

            catalogue.SubtractItem(1);
            int newItemsCount = catalogue.GetItemsCount(fakeItem2);
            int difference    = itemsCount - newItemsCount;

            Assert.That(difference.Equals(1));
        }
Esempio n. 4
0
        public void Get_Items_Count_Of_Catalogue_Containing_It(int amount, int finalAmount)
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();

            for (int i = 0; i < amount; i++)
            {
                catalogue.AddItem(item);
            }
            int itemsCount = catalogue.GetItemsCount(item);

            Assert.That(itemsCount.Equals(finalAmount));
        }
Esempio n. 5
0
        public void Get_Items_Count_Of_Catalogue_Not_Containing_It()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();
            IItem      item2     = new FakeItemWithPrice();

            catalogue.AddItem(item);
            var exception = Assert.Throws <ItemMismatchException>(() =>
            {
                catalogue.GetItemsCount(item2);
            });

            Assert.That(exception.GetType() == typeof(ItemMismatchException));
        }