public void TestImplementsInterface() { VendingDisplayController displayController = new VendingDisplayController(new TextBox(), new MockCoinPurse()); Assert.IsInstanceOf(typeof (IDisplayController), displayController); Assert.IsInstanceOf(typeof (ICoinPurseObserver), displayController); }
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 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 MainFormController(Form form) { MainForm = form; CoinAccepter = new CoinAccepter(CoinFactory, CoinPurse, CoinReturn); DisplayController = new VendingDisplayController(GetTextBoxFromForm(DisplayTextBoxName), CoinPurse); ReturnChangeButtonController = new ReturnChangeButtonController(GetButtonFromForm(ChangeReturnButtonName), CoinPurse, CoinReturn); InsertCoinButtonPanel = new InsertCoinButtonPanel(GetButtonFromForm(InsertPennyButtonName), GetButtonFromForm(InsertNickelButtonName), GetButtonFromForm(InsertDimeButtonName), GetButtonFromForm(InsertQuarterButtonName)); InsertCoinButtonPanelController = new InsertCoinButtonPanelController(InsertCoinButtonPanel, CoinAccepter); CoinReturnDisplayController = new CoinReturnDisplayController(GetTextBoxFromForm(CoinReturnDisplayTextBoxName), CoinReturn); ClearCoinReturnButtonController = new ClearCoinReturnButtonController(GetButtonFromForm(ClearCoinReturnButtonName), CoinReturn, new DialogService()); }