コード例 #1
0
        public void CanRackIsEmptyTest()
        {
            int maxInventory = 5;
            var cr           = new CanRack(maxInventory);

            cr.FillTheCanRack();

            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                for (int i = maxInventory; i >= -1; i--)
                {
                    // While amount is at least 1 soda, rack is not empty
                    if (i >= 1)
                    {
                        Assert.IsFalse(cr.IsEmpty(f));
                    }
                    else
                    {
                        Assert.IsTrue(cr.IsEmpty(f));
                    }

                    cr.RemoveACanOf(f);
                }
            }
        }
コード例 #2
0
 public VendingMachine(int inventory, dynamic price)
 {
     canRack       = new CanRack(inventory);
     purchasePrice = new PurchasePrice(price);
     trxBox        = new CoinBox();
     box           = new CoinBox();
 }
コード例 #3
0
 public VendingMachineViewModel(int inventory, dynamic price)
 {
     canRack         = new CanRack(inventory);
     purchasePrice   = new PurchasePrice(price);
     trxBox          = new CoinBox();
     box             = new CoinBox();
     canPriceMessage = $"Please deposit {(this.purchasePrice.Price * .01).ToString("C2")}";
     MainTitle       = "WPF Vending Machine - Assignment 6";
     canMakeChange   = true;
 }
コード例 #4
0
        public void CanRackFillCanRackTest()
        {
            var cr = new CanRack(3);

            cr.FillTheCanRack();
            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                // Check the filled canRack by flavor
                Assert.AreEqual(cr.Contents(f).Amount, 3);
            }
        }
コード例 #5
0
        public void CanRackEmptyRackOfTest()
        {
            var cr = new CanRack(3);

            cr.FillTheCanRack();

            // Empty each flavor and confirm amount is zero
            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                cr.EmptyCanRackOf(f);
                Assert.AreEqual(cr.Contents(f).Amount, 0);
            }
        }
コード例 #6
0
        public void CanRackRemoveACanOfTest()
        {
            int maxInventory = 3;
            var cr           = new CanRack(maxInventory);

            cr.FillTheCanRack();
            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                for (int i = maxInventory; i >= -1; i--)
                {
                    // Check inventory is decremented by 1 for each iteration but never less than 0
                    cr.RemoveACanOf(f);
                    Assert.AreEqual(cr.Contents(f).Amount, Math.Max(0, i - 1));
                }
            }
        }
コード例 #7
0
        public void CanRackIsFullTest()
        {
            int maxInventory = 5;
            var cr           = new CanRack(maxInventory);

            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                for (int i = 1; i <= maxInventory + 2; i++)
                {
                    cr.AddACanOf(f);
                    // While amount < maxInventory rack is not full
                    if (i < maxInventory)
                    {
                        Assert.IsFalse(cr.IsFull(f));
                    }
                    else
                    {
                        Assert.IsTrue(cr.IsFull(f));
                    }
                }
            }
        }
コード例 #8
0
        public void CanRackAddACanOfTest()
        {
            int maxInventory = 6;
            var cr           = new CanRack(maxInventory);

            // Attempt to add 3 more cans than the maximum allowed
            foreach (Flavor f in Enum.GetValues(typeof(Flavor)))
            {
                for (int i = 1; i <= maxInventory + 3; i++)
                {
                    cr.AddACanOf(f);
                    // Check the cans are incrementing up to the max inventory, but not over
                    if (i <= maxInventory)
                    {
                        Assert.AreEqual(cr.Contents(f).Amount, i);
                    }
                    else
                    {
                        Assert.AreNotEqual(cr.Contents(f).Amount, i);
                    }
                }
            }
        }
コード例 #9
0
        public void CanRackCtorTest()
        {
            var cr = new CanRack(5);

            Assert.AreEqual(cr.MaxInventory, 5);
        }