コード例 #1
0
        public void ShouldHaveNoDispensedProductWhenButtonIsPressedWithoutEnoughCoinsInserted()
        {
            var dispenser = new StubbedDispenser();
            var sut       = new VendingMachine(dispenser);

            sut.SelectProduct(ProductCodes.Cola);

            Assert.False(dispenser.WasProductDispensed);
        }
コード例 #2
0
        public void ShouldNotDispenseProductWhenInvalidButtonIsEntered()
        {
            var dispenser = new StubbedDispenser();
            var sut       = new VendingMachine(dispenser);

            sut.SelectProduct("Invalid");

            Assert.False(dispenser.WasProductDispensed);
        }
コード例 #3
0
        public void ShouldDispenseProductWhenButtonIsPressedWithEnoughCoinsInserted(string productCode, int numberOfQuartersInserted)
        {
            var dispenser = new StubbedDispenser();
            var sut       = new VendingMachine(dispenser);

            StockMachineWithCoinsNeededToMakeChange(sut);

            for (var i = 0; i < numberOfQuartersInserted; i++)
            {
                sut.InsertCoin(_testBuilder.CreateQuarter());
            }
            sut.StockProduct(new Dictionary <string, int> {
                { productCode, 1 }
            });
            sut.SelectProduct(productCode);

            Assert.True(dispenser.WasProductDispensed);
        }