示例#1
0
        public void RemoveItem_ThrowsExceptionRemovingNonExistentItem()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory(5);
            TestInventoryItem testItem = new TestInventoryItem();

            // Attempt to remove the inventory.
            Assert.ThrowsException <InsufficientInventoryException>(() => testInv.RemoveItem(testItem, 4, 3));
        }
示例#2
0
        public void RemoveItem_ThrowsExceptionMultipleCategories()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory(5);
            TestInventoryItem testItem = new TestInventoryItem();

            // Attempt to remove the inventory.
            Assert.ThrowsException <ArgumentNullException>(() => testInv.RemoveItem(testItem, 4));
        }
示例#3
0
        public void RegisterEntity_EntityRegistersSuccessfully()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory(5);
            TestInventoryItem testItem = new TestInventoryItem();

            var entityCategory = testInv.RegisterEntity();

            Assert.AreEqual(5, entityCategory);
        }
示例#4
0
        public void AddItem_OneCategorySuccessfully()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory();
            TestInventoryItem testItem = new TestInventoryItem();

            // Add the inventory, and confirm it exists in there.
            testInv.AddItem(testItem, 3);

            // Ensure the quantity was properly tracked in the system.
            var invStatus = testInv.GetItemProfile(testItem);

            Assert.AreEqual(invStatus.InventoryByCategory[0], 3);
            Assert.AreEqual(invStatus.TotalQuantity, 3);
        }
示例#5
0
        public void RemoveItem_RemovesSomeQuantitySuccessfully()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory(5);
            TestInventoryItem testItem = new TestInventoryItem();

            testInv.AddItem(testItem, 5, 3);
            testInv.AddItem(testItem, 7, 2);

            // Remove the item, and make sure it was removed.
            testInv.RemoveItem(testItem, 2, 3);
            var invStatus = testInv.GetItemProfile(testItem);

            Assert.AreEqual(3, invStatus.InventoryByCategory[3]);
        }
示例#6
0
        public void RemoveItem_RemovesItemEntirelySuccessfully()
        {
            // Create the test inventory, and test item.
            Inventory         testInv  = new Inventory(5);
            TestInventoryItem testItem = new TestInventoryItem();

            testInv.AddItem(testItem, 5, 3);
            testInv.AddItem(testItem, 7, 2);

            // Remove the item, and make sure it was removed.
            testInv.RemoveItem(testItem, 5, 3);
            var invStatus = testInv.GetItemProfile(testItem);

            // Ensure the category doesn't see it at all.
            Assert.IsFalse(invStatus.InventoryByCategory.ContainsKey(3));
        }