public VendingMachine(ICoinSlot coinSlot, ICoinReturn coinReturn, ICoinFactory coinFactory, IVendingMachineDisplay vendingMachineDisplay)
 {
     _coinSlot              = coinSlot;
     _coinReturn            = coinReturn;
     _coinFactory           = coinFactory;
     _vendingMachineDisplay = vendingMachineDisplay;
 }
        public void Setup()
        {
            _mockPurchaseHandler        = MockRepository.GenerateMock <IPurchaseHandler>();
            _mockVendingMachineDisplay  = MockRepository.GenerateMock <IVendingMachineDisplay>();
            _mockVendingMachineHardware = MockRepository.GenerateMock <IVendingMachineHardware>();

            _sut = new VendingMachineController(_mockPurchaseHandler, _mockVendingMachineDisplay, _mockVendingMachineHardware);
        }
Exemplo n.º 3
0
        public void GivenNoCoinsHaveBeenInserted_WhenUpdate_ThenInsertCoinShouldBeDisplayed()
        {
            IVendingMachineDisplay vendingMachineDisplay = Mocker.CreateInstance <VendingMachineDisplay>();
            ICoinCollection        coinCollection        = new CoinCollection();
            var expectedString = Resources.Strings.InsertCoin;

            vendingMachineDisplay.Update(coinCollection);

            vendingMachineDisplay.Display.Should().Be(expectedString);
            Mocker.Verify <IDisplayWriter>(d => d.Write(expectedString), Times.Once);
        }
Exemplo n.º 4
0
        public void GivenANickelHasBeenInserted_WhenUpdate_Then5CentsShouldBeDisplayed()
        {
            IVendingMachineDisplay vendingMachineDisplay = Mocker.CreateInstance <VendingMachineDisplay>();
            ICoinCollection        coinCollection        = new CoinCollection()
            {
                new Nickle()
            };
            var expectedString = string.Format(Resources.Strings.DisplayCoinTotal, 0.05);

            vendingMachineDisplay.Update(coinCollection);

            vendingMachineDisplay.Display.Should().Be(expectedString);
            Mocker.Verify <IDisplayWriter>(d => d.Write(expectedString), Times.Once);
        }
 public VendingMachineController(IPurchaseHandler purchaseHandler, IVendingMachineDisplay vendingMachineDisplay, IVendingMachineHardware vendingMachineHardware)
 {
     _purchaseHandler        = purchaseHandler;
     _vendingMachineDisplay  = vendingMachineDisplay;
     _vendingMachineHardware = vendingMachineHardware;
 }