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 TestCorrectlyBuildsChangeReturnButtonController()
        {
            Form   mainForm = new Form();
            Button expectedChangeReturnButton = new Button()
            {
                Name = "ChangeReturnButton"
            };

            mainForm.Controls.Add(expectedChangeReturnButton);
            MainFormController mainFormController = new MainFormController(mainForm);

            ReturnChangeButtonController returnChangeButtonController = mainFormController.ReturnChangeButtonController;

            Assert.IsInstanceOf(typeof(ReturnChangeButtonController), returnChangeButtonController);
            Assert.AreSame(expectedChangeReturnButton, returnChangeButtonController.Button);
            Assert.AreSame(mainFormController.CoinPurse, returnChangeButtonController.CoinPurse);
            Assert.AreSame(mainFormController.CoinReturn, returnChangeButtonController.CoinReturn);
        }
Exemple #3
0
        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());
        }