示例#1
0
        public void ReadingTextInput()
        {
            VM_Item a1 = new VM_Item("Potato Crisps", 3.25, "A1");
            VM_Item a2 = new VM_Item("Stackers", 1.75, "A2");
            Dictionary <string, VM_Item> testDictionary = new Dictionary <string, VM_Item>()
            {
                { "A1", a1 },
                { "A2", a2 }
            };


            VM_Stocker s1 = new VM_Stocker("vendingmachine.csv");

            //Assert.AreSame(s1.Inventory["A1"], a1);
            //CollectionAssert.AllItemsAreInstancesOfType(s1.Inventory, VM_Item());
            Assert.AreEqual(s1.Inventory["A1"].Price, a1.Price);
            Assert.AreEqual(s1.Inventory["A1"].Name, a1.Name);
            Assert.AreEqual(s1.Inventory["A1"].QuantityRemaining, a1.QuantityRemaining);
            Assert.AreEqual(s1.Inventory["A1"].QuantitySold, a1.QuantitySold);
            Assert.AreEqual(s1.Inventory["A1"].Slot, a1.Slot);

            Assert.AreEqual(s1.Inventory["A2"].Price, a2.Price);
            Assert.AreEqual(s1.Inventory["A2"].Name, a2.Name);
            Assert.AreEqual(s1.Inventory["A2"].QuantityRemaining, a2.QuantityRemaining);
            Assert.AreEqual(s1.Inventory["A2"].QuantitySold, a2.QuantitySold);
            Assert.AreEqual(s1.Inventory["A2"].Slot, a2.Slot);

            //Assert.AreEqual(s1.Inventory["A1"].Name, testDictionary.Inventory["A1"].Name);
            //CollectionAssert.Contains(s1.Inventory, a1);
            //CollectionAssert.Contains(s1.Inventory, a2);
        }
        public void TestingGetInventory()
        {
            //VM_Item i1 = new VM_Item("Moonpie", 1.50, "B1");
            // VM_Item i2 = new VM_Item("Heavy", 1.50, "C4");
            //VM_Item i3 = new VM_Item("Triplemint", 0.75, "D4");
            VendingMachine v1 = new VendingMachine();

            v1.FeedMoney(10);
            v1.Purchase(v1.GetInventory()["B1"]);
            //v1.Purchase(i1);
            VM_Stocker s1 = new VM_Stocker("vendingmachine.csv");

            Assert.AreEqual(s1.Inventory["A2"].Name, v1.GetInventory()["A2"].Name);
            Assert.AreEqual(s1.Inventory["A4"].Price, v1.GetInventory()["A4"].Price);
            Assert.AreEqual(s1.Inventory["B4"].Price, v1.GetInventory()["B4"].Price);
            Assert.AreNotEqual(s1.Inventory["B1"].QuantityRemaining, v1.GetInventory()["B1"].QuantityRemaining);
            Assert.AreNotEqual(s1.Inventory["B1"].QuantitySold, v1.GetInventory()["B1"].QuantitySold);
            //CollectionAssert.AreEquivalent(v1.GetInventory(), s1.Inventory);
        }