Beispiel #1
0
        public void Get_Item_Index_From_Empty_Catalogue()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();

            var exception = Assert.Throws <EmptyContainerException>(() =>
            {
                catalogue.GetItemIndex(item);
            });

            Assert.That(exception.GetType() == typeof(EmptyContainerException));
        }
Beispiel #2
0
        public void Get_Item_Index_From_Catalogue_Containing_It()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();

            catalogue.AddItem(item);
            IItem item2 = new FakeItemWithPrice();

            catalogue.AddItem(item2);

            int index = catalogue.GetItemIndex(item2);

            Assert.That(index.Equals(1));
        }
Beispiel #3
0
        public void Get_Item_Index_From_Catalogue_Not_Containing_It()
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      item      = new FakeItem();

            catalogue.AddItem(item);
            IItem item2 = new FakeItemWithPrice();

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

            Assert.That(exception.GetType() == typeof(ItemMismatchException));
        }
Beispiel #4
0
        public void Get_Existing_Items_By_Index_That_Can_Be_Bought(int initialAmount, decimal amount, int purchasableAmount)
        {
            ICatalogue catalogue = new SimpleCatalogue();
            IItem      fakeItem  = new FakeItemWithPrice();

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

            int index          = catalogue.GetItemIndex(fakeItem);
            int canBePurchased = catalogue.ItemsThatCanBeBought(index, amount);

            Assert.That(canBePurchased.Equals(purchasableAmount));
        }