private void ButtonEventListener(object sender, EventArgs eventArgs) { decimal amountReturnedFromClear = CoinReturn.Clear(); if (amountReturnedFromClear > 0) { DialogService.ShowMessage("You receive: " + $"{amountReturnedFromClear:C}"); } }
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); }
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()); }
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); }