public void TestImplementsInterface()
        {
            CoinReturnDisplayController coinReturnDisplayController = new CoinReturnDisplayController(new TextBox(),
                new MockCoinReturn());

            Assert.IsInstanceOf(typeof (IDisplayController), coinReturnDisplayController);
            Assert.IsInstanceOf(typeof (ICoinReturnObserver), coinReturnDisplayController);
        }
        public void TestRegistersSelfAsObserverWithCoinReturn()
        {
            MockCoinReturn mockCoinReturn = new MockCoinReturn();
            CoinReturnDisplayController coinReturnDisplayController = new CoinReturnDisplayController(new TextBox(),
                mockCoinReturn);

            Assert.AreEqual(1, mockCoinReturn.NumberOfTimesRegisterObserverWasCalled);
            Assert.AreSame(coinReturnDisplayController, mockCoinReturn.ObserversPassedToRegisterObserver[0]);
        }
        public void TestProperties()
        {
            MockCoinReturn expectedCoinReturn = new MockCoinReturn();
            TextBox expectedTextBox = new TextBox();

            CoinReturnDisplayController coinReturnDisplayController = new CoinReturnDisplayController(expectedTextBox,
                expectedCoinReturn);

            Assert.AreEqual(expectedCoinReturn, coinReturnDisplayController.CoinReturn);
            Assert.AreEqual(expectedTextBox, coinReturnDisplayController.Display);
        }
        public void TestUpdatesDisplayTextWithCoinReturnValueWhenCoinReturnUpdatedIsCalled(
            decimal valueToReturnFromCoinReturn, string expectedUpdatedText)
        {
            MockCoinReturn mockCoinReturn = new MockCoinReturn();
            TextBox displayTextBox = new TextBox();

            CoinReturnDisplayController coinReturnDisplayController = new CoinReturnDisplayController(displayTextBox,
                mockCoinReturn);

            const string expectedStartingAmountBecauseTheMockReturnsAnAmoutOfZeroByDefualt = "$0.00";
            Assert.AreEqual(expectedStartingAmountBecauseTheMockReturnsAnAmoutOfZeroByDefualt, displayTextBox.Text);

            mockCoinReturn.ValueToReturnFromAmountAvailable = valueToReturnFromCoinReturn;

            coinReturnDisplayController.CoinReturnUpdated();

            Assert.AreEqual(expectedUpdatedText, 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());
        }