private void ButtonEventListener(object sender, EventArgs eventArgs)
        {
            decimal amountReturnedFromClear = CoinReturn.Clear();

            if (amountReturnedFromClear > 0)
            {
                DialogService.ShowMessage("You receive: " + $"{amountReturnedFromClear:C}");
            }
        }
示例#2
0
        public void TestClearCallsCoinReturnUpdatedOnObservers()
        {
            CoinReturn             coinReturn = new CoinReturn();
            MockCoinReturnObserver mockCoinReturnObserverOne = new MockCoinReturnObserver();
            MockCoinReturnObserver mockCoinReturnObserverTwo = new MockCoinReturnObserver();

            coinReturn.RegisterObserver(mockCoinReturnObserverOne);
            coinReturn.RegisterObserver(mockCoinReturnObserverTwo);

            coinReturn.Clear();

            Assert.AreEqual(1, mockCoinReturnObserverOne.NumberOfTimesCoinPurseUpdatedCalled);
            Assert.AreEqual(1, mockCoinReturnObserverTwo.NumberOfTimesCoinPurseUpdatedCalled);
        }
示例#3
0
        public void TestClearReturnsValueOfAllCoins(decimal coinOneValue, decimal coinTwoValue, decimal expectedTotalValue)
        {
            CoinReturn coinReturn = new CoinReturn();

            coinReturn.AddCoin(new MockCoin()
            {
                ValueToReturn = coinOneValue
            });
            coinReturn.AddCoin(new MockCoin()
            {
                ValueToReturn = coinTwoValue
            });

            Assert.AreEqual(expectedTotalValue, coinReturn.Clear());
        }
示例#4
0
        public void TestClearEmptiesCoinList()
        {
            CoinReturn coinReturn = new CoinReturn();

            MockCoin firstCoinAdded  = new MockCoin();
            MockCoin secondCoinAdded = new MockCoin();
            MockCoin thirdCoinAdded  = new MockCoin();

            coinReturn.AddCoin(firstCoinAdded);
            coinReturn.AddCoin(secondCoinAdded);
            coinReturn.AddCoin(thirdCoinAdded);

            coinReturn.Clear();

            Assert.AreEqual(new List <ICoin>(), coinReturn.Coins);
        }