Example #1
0
        public void GoodExtractBeforeSaleComplex()
        {
            var vm       = new VendingMachine(new Cents[] { new Cents(5), new Cents(10), new Cents(25), new Cents(100) }, 1, 10, 10, 10);
            var hardware = vm.Hardware;

            vm.Configure(new List <ProductKind>()
            {
                new ProductKind("stuff", new Cents(140))
            });
            hardware.LoadCoins(new int[] { 0, 5, 1, 1 });
            hardware.LoadProducts(new int[] { 1 });
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.SelectionButtons[0].Press();
            var delivery = VMUtility.ExtractDelivery(hardware);

            VMUtility.CheckDelivery(delivery, 155, new string[] { "stuff" });
            var unload = VMUtility.Unload(hardware);

            VMUtility.CheckUnload(unload, 320, 0, new string[] { });
            hardware.LoadCoins(new int[] { 10, 10, 10, 10 });
            hardware.LoadProducts(new int[] { 1 });
            hardware.CoinSlot.AddCoin(new Coin(new Cents(25)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(10)));
            hardware.SelectionButtons[0].Press();
            delivery = VMUtility.ExtractDelivery(hardware);
            VMUtility.CheckDelivery(delivery, 0, new string[] { "stuff" });
            unload = VMUtility.Unload(hardware);
            VMUtility.CheckUnload(unload, 1400, 135, new string[] { });
        }
Example #2
0
        public void GoodApproximateChange()
        {
            var vm = new VendingMachine(new Cents[] { new Cents(5), new Cents(10), new Cents(25), new Cents(100) }, 1, 10, 10, 10);

            var hardware = vm.Hardware;

            vm.Configure(new List <ProductKind>()
            {
                new ProductKind("stuff", new Cents(140))
            });

            hardware.LoadCoins(new int[] { 0, 5, 1, 1, });

            hardware.LoadProducts(new int[] { 1 });
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.SelectionButtons[0].Press();

            var delivery = VMUtility.ExtractDelivery(hardware);

            VMUtility.CheckDelivery(delivery, 155, new string[] { "stuff" });

            var contents = VMUtility.Unload(hardware);

            VMUtility.CheckUnload(contents, 320, 0, new string[] { });
        }
        public void GoodExtractBeforeSale()
        {
            var vm = new VendingMachine(new Cents[] { new Cents(100), new Cents(5), new Cents(25), new Cents(10) }, 3, 10, 10, 10);

            vm.Configure(new List <ProductKind>()
            {
                new ProductKind("Coke", new Cents(250)),
                new ProductKind("water", new Cents(250)),
                new ProductKind("stuff", new Cents(205))
            });
            var hardware = vm.Hardware;

            hardware.LoadCoins(new int[] { 0, 1, 2, 1 });
            hardware.LoadProducts(new int[] { 1, 1, 1 });
            hardware.SelectionButtons[0].Press();

            var delivery = VMUtility.ExtractDelivery(hardware);

            VMUtility.CheckDelivery(delivery, 0, new string[] { });

            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));

            delivery = VMUtility.ExtractDelivery(hardware);
            VMUtility.CheckDelivery(delivery, 0, new string[] { });

            var unload = VMUtility.Unload(hardware);

            VMUtility.CheckUnload(unload, 65, 0, new string[] { "Coke", "water", "stuff" });
        }
Example #4
0
        public void GoodPressWithoutInsert()
        {
            this.hardware.SelectionButtons[0].Press();

            var delivery = VMUtility.ExtractDelivery(this.hardware);
            var contents = VMUtility.Unload(this.hardware);

            VMUtility.CheckDelivery(delivery, 0, new string[] { });
            VMUtility.CheckUnload(contents, 65, 0, new string[] { "Coke", "water", "stuff" });
        }
        public void GoodTeardownWithoutConfigureOrLoad()
        {
            var vm       = new VendingMachine(new Cents[] { new Cents(5), new Cents(10), new Cents(25), new Cents(100) }, 3, 10, 10, 10);
            var hardware = vm.Hardware;

            var delivery = VMUtility.ExtractDelivery(hardware);
            var unload   = VMUtility.Unload(hardware);

            VMUtility.CheckDelivery(delivery, 0, new string[] { });
            VMUtility.CheckUnload(unload, 0, 0, new string[] { });
        }
Example #6
0
        public void GoodInsertAndPressChangeExpected()
        {
            this.hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            this.hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            this.hardware.CoinSlot.AddCoin(new Coin(new Cents(100)));
            this.hardware.SelectionButtons[0].Press();

            var delivery = VMUtility.ExtractDelivery(this.hardware);
            var contents = VMUtility.Unload(this.hardware);

            VMUtility.CheckDelivery(delivery, 50, new string[] { "Coke" });
            VMUtility.CheckUnload(contents, 315, 0, new string[] { "water", "stuff" });
        }