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 TestProperties()
        {
            MockCoinFactory expectedCoinFactory = new MockCoinFactory();
            MockCoinPurse   expectedCoinPurse   = new MockCoinPurse();
            MockCoinReturn  expectedCoinReturn  = new MockCoinReturn();

            CoinAccepter coinAccepter = new CoinAccepter(expectedCoinFactory, expectedCoinPurse, expectedCoinReturn);

            Assert.AreSame(expectedCoinFactory, coinAccepter.CoinFactory);
            Assert.AreSame(expectedCoinPurse, coinAccepter.CoinPurse);
            Assert.AreSame(expectedCoinReturn, coinAccepter.CoinReturn);
        }
        public void TestInitializesTextOnDisplayToValueOfCoinReturn(decimal valueToReturnFromCoinReturn,
            string expectedText)
        {
            MockCoinReturn mockCoinReturn = new MockCoinReturn();
            TextBox displayTextBox = new TextBox();

            mockCoinReturn.ValueToReturnFromAmountAvailable = valueToReturnFromCoinReturn;

            new CoinReturnDisplayController(displayTextBox, mockCoinReturn);

            Assert.AreEqual(expectedText, displayTextBox.Text);
        }
        public void TestProperties()
        {
            MockCoinFactory expectedCoinFactory = new MockCoinFactory();
            MockCoinPurse expectedCoinPurse = new MockCoinPurse();
            MockCoinReturn expectedCoinReturn = new MockCoinReturn();

            CoinAccepter coinAccepter = new CoinAccepter(expectedCoinFactory, expectedCoinPurse, expectedCoinReturn);

            Assert.AreSame(expectedCoinFactory, coinAccepter.CoinFactory);
            Assert.AreSame(expectedCoinPurse, coinAccepter.CoinPurse);
            Assert.AreSame(expectedCoinReturn, coinAccepter.CoinReturn);
        }
        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 void TestCoinWithNoValueIsPutIntoTheCoinReturnAndNotTheCoinPurse(decimal coinValue)
        {
            MockCoinFactory mockCoinFactory = new MockCoinFactory();
            MockCoinPurse mockCoinPurse = new MockCoinPurse();
            MockCoinReturn mockCoinReturn = new MockCoinReturn();

            MockCoin mockCoin = new MockCoin {ValueToReturn = coinValue};
            mockCoinFactory.CoinToReturn = mockCoin;

            CoinAccepter coinAccepter = new CoinAccepter(mockCoinFactory, mockCoinPurse, mockCoinReturn);

            coinAccepter.Accept(CoinSize.Large);

            Assert.AreSame(mockCoin, mockCoinReturn.CoinsPassedToAddCoin[0]);
            Assert.AreEqual(1, mockCoinReturn.NumberOfTimesAddCoinCalled);
            Assert.AreEqual(0, mockCoinPurse.NumberOfTimesAddCoinWasCalled);
            Assert.AreEqual(0, mockCoinPurse.Coins.Count);
        }
        public void TestCoinWithNoValueIsPutIntoTheCoinReturnAndNotTheCoinPurse(decimal coinValue)
        {
            MockCoinFactory mockCoinFactory = new MockCoinFactory();
            MockCoinPurse   mockCoinPurse   = new MockCoinPurse();
            MockCoinReturn  mockCoinReturn  = new MockCoinReturn();

            MockCoin mockCoin = new MockCoin {
                ValueToReturn = coinValue
            };

            mockCoinFactory.CoinToReturn = mockCoin;

            CoinAccepter coinAccepter = new CoinAccepter(mockCoinFactory, mockCoinPurse, mockCoinReturn);

            coinAccepter.Accept(CoinSize.Large);

            Assert.AreSame(mockCoin, mockCoinReturn.CoinsPassedToAddCoin[0]);
            Assert.AreEqual(1, mockCoinReturn.NumberOfTimesAddCoinCalled);
            Assert.AreEqual(0, mockCoinPurse.NumberOfTimesAddCoinWasCalled);
            Assert.AreEqual(0, mockCoinPurse.Coins.Count);
        }