Beispiel #1
0
        public void AcceptingOnlyCorrectCoins()
        {
            var coinService = new VendingMachine.Services.CoinService();

            Assert.AreEqual(Coin.Cent, coinService.InsertCoinToMachine(0.01));
            Assert.AreEqual(Coin.Nickel, coinService.InsertCoinToMachine(0.05));
            Assert.AreEqual(Coin.Dime, coinService.InsertCoinToMachine(0.10));
            Assert.AreEqual(Coin.QuarterDollar, coinService.InsertCoinToMachine(0.25));
            Assert.AreEqual(Coin.HalfDollar, coinService.InsertCoinToMachine(0.50));
            Assert.AreEqual(Coin.Dollar, coinService.InsertCoinToMachine(1));
            Assert.AreEqual(Coin.BadCoin, coinService.InsertCoinToMachine(1.1));
            Assert.AreEqual(Coin.BadCoin, coinService.InsertCoinToMachine(-1));
        }
Beispiel #2
0
        public void AddMoneyToCorrectWallet()
        {
            var machine         = new Machine();
            var coinService     = new VendingMachine.Services.CoinService();
            var machineServices = new MachineServices(machine, coinService);


            machineServices.PutCoinToMachine(0.50);
            Assert.AreEqual(machineServices.Machine.CoinsInsert[Coin.HalfDollar], 1);
            machineServices.PutCoinToMachine(0.50);
            Assert.AreEqual(machineServices.Machine.CoinsInsert[Coin.HalfDollar], 2);
            machineServices.PutCoinToMachine(0.60);
            Assert.AreEqual(machineServices.Machine.RejectCoins[0.60], 1);
        }
Beispiel #3
0
 public MachineServices(Machine machine, CoinService coinService)
 {
     Machine     = machine;
     CoinService = coinService;
 }