public void TestProperties() { Button expectedClearCoinReturnButton = new Button(); MockCoinReturn expectedCoinReturn = new MockCoinReturn(); MockDialogService expectedDialogService = new MockDialogService(); ClearCoinReturnButtonController clearCoinReturnButtonController = new ClearCoinReturnButtonController(expectedClearCoinReturnButton, expectedCoinReturn, expectedDialogService); Assert.AreSame(expectedCoinReturn, clearCoinReturnButtonController.CoinReturn); Assert.AreSame(expectedClearCoinReturnButton, clearCoinReturnButtonController.Button); Assert.AreSame(expectedDialogService, clearCoinReturnButtonController.DialogService); }
public void TestClickingButtonCallsClearOnCoinReturn() { Button clearCoinReturnButton = new Button(); MockCoinReturn mockCoinReturn = new MockCoinReturn(); ClearCoinReturnButtonController clearCoinReturnButtonController = new ClearCoinReturnButtonController(clearCoinReturnButton, mockCoinReturn, new MockDialogService()); Assert.AreEqual(0, mockCoinReturn.NumberOfTimesClearWasCalled); clearCoinReturnButton.PerformClick(); Assert.AreEqual(1, mockCoinReturn.NumberOfTimesClearWasCalled); }
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()); }