public void Check_For_A_Non_Existent_Item_In_Non_Empty_Catalogue() { IItem item1 = new FakeItem(); IItem item2 = new FakeItemWithPrice(); SimpleCatalogue catalogue = new SimpleCatalogue(); catalogue.AddItem(item1); Assert.That(catalogue.ContainsItem(item2).Equals(false)); }
public void Try_To_Get_Purchasable_Items_Number_That_Are_Non_Existent_In_Non_Empty_Catalogue() { ICatalogue catalogue = new SimpleCatalogue(); IItem item = new FakeItem(); IItem item2 = new FakeItemWithPrice(); catalogue.AddItem(item); Assert.That(catalogue.ItemsThatCanBeBought(item2, 100).Equals(0)); }
public void Try_To_Get_Items_That_Can_Be_Bought_From_Catalogue_Not_Having_It() { ICatalogue catalogue = new SimpleCatalogue(); IItem item = new FakeItem(); catalogue.AddItem(item); IItem item2 = new FakeItemWithPrice(); Assert.That(catalogue.ItemsThatCanBeBought(item2, 100).Equals(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)); }
public void Add_A_New_Catalogue_Item() { IItem item = new FakeItem(); IVendingMachineInternal fakeMachine = new FakeVendingMachine(); SimpleCatalogue catalogue = new SimpleCatalogue(); catalogue.Init(fakeMachine); catalogue.AddItem(item); Console.WriteLine($"Catalogue count = {catalogue.GetCatalogueItems().Count}"); Assert.That(catalogue.ContainsItem(item).Equals(true)); }
public void Subtract_Group_Of_Items_From_Empty_Catalogue() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); var exception = Assert.Throws <EmptyContainerException>(() => { catalogue.SubtractItems(fakeItem, 200); }); Assert.That(exception.GetType() == typeof(EmptyContainerException)); }
public void Subtract_Item_From_Empty_Catalogue() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); var exception = Assert.Throws <ItemMismatchException>(() => { catalogue.SubtractItem(fakeItem); }); Assert.That(exception.GetType() == typeof(ItemMismatchException)); }
public void Get_Price_Of_Item_Quantity_From_Empty_Catalogue() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); var exception = Assert.Throws <EmptyContainerException>(() => { catalogue.GetPriceOfItem(fakeItem, 100); }); Assert.That(exception.GetType() == typeof(EmptyContainerException)); }
public void Check_For_Item_in_Blank_Catalogue() { IItem item = new FakeItem(); SimpleCatalogue catalogue = new SimpleCatalogue(); FakeItem fake = new FakeItem(); var exception = Assert.Throws <EmptyContainerException>(() => { catalogue.ContainsItem(fake); }); Assert.That(exception.GetType() == typeof(EmptyContainerException)); }
public void Subtract_Item_From_Catalogue_Containing_It() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); for (int i = 0; i < 100; i++) { catalogue.AddItem(fakeItem); } IItem fakeItem2 = catalogue.SubtractItem(fakeItem); Assert.That(fakeItem2.Equals(fakeItem)); }
public void Subtract_Group_Of_Items_By_Index_From_The_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); } List <IItem> items = catalogue.SubtractItems(0, subtractQuantity); Assert.That(items.Count.Equals(result)); }
public void Subtract_More_Items_By_Index_Than_There_Is_In_Catalogue() { ICatalogue catalogue = new SimpleCatalogue(); IItem item = new FakeItem(); catalogue.AddItem(item); var exception = Assert.Throws <SubtractionFromLesserQuantityException>(() => { catalogue.SubtractItems(0, 200); }); Assert.That(exception.GetType() == typeof(SubtractionFromLesserQuantityException)); }
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)); }
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)); }
public void Subtract_Index_Greater_Than_Catalogue_Size() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); catalogue.AddItem(fakeItem); var exception = Assert.Throws <ItemNotFoundException>(() => { catalogue.SubtractItem(10); }); Assert.That(exception.GetType() == typeof(ItemNotFoundException)); }
public void Subtract_Item_From_Catalogue_Not_Containing_It() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); catalogue.AddItem(fakeItem); IItem fakeItem2 = new FakeItemWithPrice(); var exception = Assert.Throws <ItemMismatchException>(() => { catalogue.SubtractItem(fakeItem2); }); Assert.That(exception.GetType() == typeof(ItemMismatchException)); }
public void Get_Price_Of_Index_In_Catalogue_Not_Containing_It() { ICatalogue catalogue = new SimpleCatalogue(); IItem item = new FakeItem(); catalogue.AddItem(item); var exception = Assert.Throws <ItemNotFoundException>(() => { catalogue.GetPriceOfItem(1); }); Assert.That(exception.GetType() == typeof(ItemNotFoundException)); }
public void Get_Price_Of_Index_Quantity_In_Catalogue_More_Than_Actual_Quantity() { ICatalogue catalogue = new SimpleCatalogue(); IItem item = new FakeItem(); catalogue.AddItem(item); var exception = Assert.Throws <ItemNotFoundException>(() => { catalogue.GetPriceOfItem(0, 100); }); Assert.That(exception.GetType() == typeof(ItemNotFoundException)); }
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)); }
public void Subtract_Valid_index_From_A_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); } IItem fakeItemResult = catalogue.SubtractItem(1); Assert.That(fakeItemResult.Equals(fakeItem2)); }
public void Get_Price_Of_All_Items_Of_A_Type_In_A_Catalogue_With_Multiple_Type_Of_Objects(int initialAmount, decimal finalPrice) { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem1 = new FakeItemWithPrice(); for (int i = 0; i < initialAmount; i++) { catalogue.AddItem(fakeItem1); } IItem fakeItem2 = new FakeItem(); catalogue.AddItem(fakeItem2); decimal price = catalogue.GetPriceOfAllItemsOfType(fakeItem1); Assert.That(price.Equals(finalPrice)); }
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)); }
public void Subtract_Group_Of_Items_From_Catalogue_Which_Does_Not_Have_It() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); IItem fakeItem2 = new FakeItemWithPrice(); for (int i = 0; i < 100; i++) { catalogue.AddItem(fakeItem); } var exception = Assert.Throws <ItemMismatchException>(() => { catalogue.SubtractItems(fakeItem2, 200); }); Assert.That(exception.GetType() == typeof(ItemMismatchException)); }
public void Subtract_More_Items_From_Catalogue_Than_It_Has() { ICatalogue catalogue = new SimpleCatalogue(); IItem fakeItem = new FakeItem(); IItem fakeItem2 = new FakeItemWithPrice(); for (int i = 0; i < 100; i++) { catalogue.AddItem(fakeItem2); } var exception = Assert.Throws <SubtractionFromLesserQuantityException>(() => { catalogue.SubtractItems(fakeItem2, 200); }); Assert.That(exception.GetType() == typeof(SubtractionFromLesserQuantityException)); }
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)); }