コード例 #1
0
        public void VendingMachineWalletCashBackSuccess_5_2_2_2()
        {
            List <ICoin> coins = new List <ICoin>();

            coins.Add(new Coin(10, 10));
            coins.Add(new Coin(5, 10));
            coins.Add(new Coin(2, 10));

            IVendingMachineWallet wallet = new VendingMachineWallet(coins);

            wallet.AddCoinsFromAcceptor(9, new List <ICoin>()
            {
                new Coin(10, 1), new Coin(10, 1)
            });

            var expectedCollection = wallet.GetCashBack().ToList();

            expectedCollection = expectedCollection.OrderBy(c => c.CoinValue).ToList();

            List <ICoin> actual = new List <ICoin>();

            actual.Add(new Coin(5, 1));
            actual.Add(new Coin(2, 1));
            actual.Add(new Coin(2, 1));
            actual.Add(new Coin(2, 1));

            actual = actual.OrderBy(c => c.CoinValue).ToList();

            Assert.IsTrue(expectedCollection.SequenceEqual(actual, new CoinsComparer()));
        }
コード例 #2
0
        public MainViewModel()
        {
            var coinAceptor         = new CoinAceptor();
            var vendingMachineValet = new VendingMachineWallet();
            var beverageRepository  = new BeverageRepository();

            VendingMachine = new VendingMachineRef(coinAceptor, vendingMachineValet, beverageRepository);

            CustomerWallet = new Wallet();

            messageNotifyer = new MessageNotifyer();
        }
コード例 #3
0
        public void VendingMachineWalletCashBackError()
        {
            List <ICoin> coins = new List <ICoin>();

            coins.Add(new Coin(10, 10));
            coins.Add(new Coin(2, 10));

            IVendingMachineWallet wallet = new VendingMachineWallet(coins);

            wallet.AddCoinsFromAcceptor(9, new List <ICoin>()
            {
                new Coin(2, 1),
            });

            var expectedCollection = wallet.GetCashBack();

            Assert.IsTrue(expectedCollection == null);
        }