public void TestClickingTheButtonPassesTheCoinsReturnedFromClearToTheCoinReturn() { Button changeReturnButton = new Button(); MockCoinPurse mockCoinPurse = new MockCoinPurse(); MockCoinReturn mockCoinReturn = new MockCoinReturn(); List <ICoin> coinsFromCoinPurse = new List <ICoin>() { new MockCoin(), new MockCoin() }; mockCoinPurse.CoinsToReturnFromClear = coinsFromCoinPurse; new ReturnChangeButtonController(changeReturnButton, mockCoinPurse, mockCoinReturn); changeReturnButton.PerformClick(); List <ICoin> coinsPassedToCoinReturn = mockCoinReturn.CoinsPassedToAddCoin; Assert.AreEqual(coinsFromCoinPurse.Count, coinsPassedToCoinReturn.Count); foreach (ICoin coinFromCoinPurse in coinsFromCoinPurse) { Assert.Contains(coinFromCoinPurse, coinsPassedToCoinReturn); } }
public void TestRegistersItselfAsObserverWithCoinPurse() { MockCoinPurse mockCoinPurse = new MockCoinPurse(); VendingDisplayController displayController = new VendingDisplayController(new TextBox(), mockCoinPurse); Assert.AreEqual(1, mockCoinPurse.NumberOfTimesRegisterObserverWasCalled); Assert.AreEqual(displayController, mockCoinPurse.RegisteredCoinPurseObservers[0]); }
public void TestProperties() { TextBox expectedTextBox = new TextBox(); MockCoinPurse expectedCoinPurse = new MockCoinPurse(); VendingDisplayController displayController = new VendingDisplayController(expectedTextBox, expectedCoinPurse); Assert.AreSame(expectedTextBox, displayController.Display); Assert.AreSame(expectedCoinPurse, displayController.CoinPurse); }
public void TestClickingTheButtonCallsClearOnCoinPurse() { Button changeReturnButton = new Button(); MockCoinPurse mockCoinPurse = new MockCoinPurse(); new ReturnChangeButtonController(changeReturnButton, mockCoinPurse, new MockCoinReturn()); changeReturnButton.PerformClick(); Assert.AreEqual(1, mockCoinPurse.NumberOfTimesClearWasCalled); }
public void TestProperties() { Button expectedChangeReturnButton = new Button(); MockCoinPurse expectedCoinPurse = new MockCoinPurse(); MockCoinReturn expectedCoinReturn = new MockCoinReturn(); ReturnChangeButtonController returnChangeButtonController = new ReturnChangeButtonController(expectedChangeReturnButton, expectedCoinPurse, expectedCoinReturn); Assert.AreEqual(expectedChangeReturnButton, returnChangeButtonController.Button); Assert.AreEqual(expectedCoinPurse, returnChangeButtonController.CoinPurse); Assert.AreEqual(expectedCoinReturn, returnChangeButtonController.CoinReturn); }
public void TestSetsCurrentPurseValueFormatedLikeMoneyWhenCoinPurseNotifiesAmountHasChanged(decimal purseValue, string expectedDisplayText) { TextBox displayTextBox = new TextBox(); MockCoinPurse mockCoinPurse = new MockCoinPurse { AmountAvailableToReturn = purseValue }; VendingDisplayController displayController = new VendingDisplayController(displayTextBox, mockCoinPurse); displayController.CoinPurseUpdated(); Assert.AreEqual(expectedDisplayText, displayTextBox.Text); }
public void TestSetsDisplayTestBackToInitialMessageIfCoinPurseIsZero() { TextBox displayTextBox = new TextBox(); MockCoinPurse mockCoinPurse = new MockCoinPurse { AmountAvailableToReturn = 0.99m }; VendingDisplayController displayController = new VendingDisplayController(displayTextBox, mockCoinPurse); displayController.CoinPurseUpdated(); Assert.AreNotEqual("INSERT COINS", displayTextBox.Text); mockCoinPurse.AmountAvailableToReturn = 0; displayController.CoinPurseUpdated(); Assert.AreEqual("INSERT COINS", displayTextBox.Text); }
public void TestClickingTheButtonPassesTheCoinsReturnedFromClearToTheCoinReturn() { Button changeReturnButton = new Button(); MockCoinPurse mockCoinPurse = new MockCoinPurse(); MockCoinReturn mockCoinReturn = new MockCoinReturn(); List<ICoin> coinsFromCoinPurse = new List<ICoin>() {new MockCoin(), new MockCoin()}; mockCoinPurse.CoinsToReturnFromClear = coinsFromCoinPurse; new ReturnChangeButtonController(changeReturnButton, mockCoinPurse, mockCoinReturn); changeReturnButton.PerformClick(); List<ICoin> coinsPassedToCoinReturn = mockCoinReturn.CoinsPassedToAddCoin; Assert.AreEqual(coinsFromCoinPurse.Count, coinsPassedToCoinReturn.Count); foreach (ICoin coinFromCoinPurse in coinsFromCoinPurse) Assert.Contains(coinFromCoinPurse, coinsPassedToCoinReturn); }