Exemplo n.º 1
0
        public void WhenInsertCoin_WithAnyCoin_ICoinFactoryCreateShouldBeInvoked(CoinEnum coin)
        {
            IVendingMachine vendingMachine = Mocker.CreateInstance <VendingMachine>();

            vendingMachine.InsertCoin(coin);

            Mocker.Verify <ICoinFactory>(c => c.Create(coin), Times.Once);
        }
        public void WhenCreate_WithCoinEnumInvalid_ThenInvalidCoinIsCreated()
        {
            const CoinEnum value       = CoinEnum.InvalidCoin;
            var            coinFactory = Mocker.CreateInstance <CoinFactory>();

            var coin = coinFactory.Create(value);

            coin.Should().BeOfType <InvalidCoin>();
            coin.Value.Should().Be(0);
        }
        public void WhenCreate_WithCoinEnumQuarter_ThenQuarterIsCreated()
        {
            const CoinEnum value       = CoinEnum.Quarter;
            var            coinFactory = Mocker.CreateInstance <CoinFactory>();

            var coin = coinFactory.Create(value);

            coin.Should().BeOfType <Quarter>();
            coin.Value.Should().Be(25);
        }
        public void WhenCreate_WithCoinEnumDime_ThenDimeIsCreated()
        {
            const CoinEnum value       = CoinEnum.Dime;
            var            coinFactory = Mocker.CreateInstance <CoinFactory>();

            var coin = coinFactory.Create(value);

            coin.Should().BeOfType <Dime>();
            coin.Value.Should().Be(10);
        }
        public void WhenCreate_WithCoinEnumNickel_ThenNickleIsCreated()
        {
            const CoinEnum value       = CoinEnum.Nickle;
            var            coinFactory = Mocker.CreateInstance <CoinFactory>();

            var coin = coinFactory.Create(value);

            coin.Should().BeOfType <Nickle>();
            coin.Value.Should().Be(5);
        }
        public ICoin Create(CoinEnum coin)
        {
            switch (coin)
            {
            case CoinEnum.Nickle: return(new Nickle());

            case CoinEnum.Dime: return(new Dime());

            case CoinEnum.Quarter: return(new Quarter());

            default: return(new InvalidCoin());
            }
        }
        public void WhenIterate_AndANickelHasBeenDetected_ThenInsertCoinIntoVendingMachine()
        {
            var            consoleLoop = Mocker.CreateInstance <ConsoleLoop>();
            const CoinEnum coin        = CoinEnum.Nickle;
            const string   nickle      = "Nickle";

            Mocker.GetMock <IParseConsoleInput>()
            .Setup(p => p.Parse(nickle))
            .Returns(coin);

            consoleLoop.Iterate(nickle);

            Mocker.Verify <IVendingMachine>(v => v.InsertCoin(coin));
        }
        public void InsertCoin(CoinEnum coinValue)
        {
            var coin = _coinFactory.Create(coinValue);

            if (coin is InvalidCoin)
            {
                _coinReturn.AddCoin(coin);
            }
            else
            {
                _coinSlot.AddCoin(coin);
                _vendingMachineDisplay.Update(_coinSlot);
            }
        }
Exemplo n.º 9
0
        private void ConsumeVariables()
        {
            FunctionII();
            FunctionV();
            FunctionVI();
            Test();

            Account account = new Account();

            Assert.IsNotNull(account);

            Example example = new Example();

            example.Method1();

            Color color = Color.Green;

            Assert.AreEqual(color, Color.Green);
            color = Color.Red;
            Assert.AreEqual(color, Color.Red);

            Dockings d = Dockings.Bottom | Dockings.None | Dockings.Top;

            Assert.AreNotEqual(d, Dockings.Bottom);

            WrongDirection w = WrongDirection.East;

            Assert.AreEqual(w, WrongDirection.East);
            w = WrongDirection.South;
            Assert.AreEqual(w, WrongDirection.South);
            w = WrongDirection.West;
            Assert.AreEqual(w, WrongDirection.West);
            w = WrongDirection.North;
            Assert.AreEqual(w, WrongDirection.North);

            Direction w2 = Direction.East;

            Assert.AreEqual(w2, Direction.East);
            w2 = Direction.South;
            Assert.AreEqual(w2, Direction.South);
            w2 = Direction.West;
            Assert.AreEqual(w2, Direction.West);
            w2 = Direction.North;
            Assert.AreEqual(w2, Direction.North);

            CoinEnum coin = CoinEnum.Nickel;

            Assert.AreEqual(coin, CoinEnum.Nickel);
            coin = CoinEnum.Penny;
            Assert.AreEqual(coin, CoinEnum.Penny);

            Coin coin2 = Coin.Nickel;

            Assert.AreEqual(coin2, Coin.Nickel);
            coin2 = Coin.Penny;
            Assert.AreEqual(coin2, CoinEnum.Penny);


            Employee e = new Employee();

            Assert.IsNotNull(e);

            BusinessLocation b = new BusinessLocation();

            Assert.IsNotNull(b);

            DocumentCollection dc = new DocumentCollection();

            Assert.IsNotNull(dc);

            Master m = new Master();

            Assert.IsNotNull(m);

            string s = ShippingType;

            Assert.AreEqual(s, ShippingType);
            s = SHIPPINGTYPE;
            Assert.AreEqual(s, SHIPPINGTYPE);

            this.ClientAppointment = DateTime.Now;
            this.TimeLeft          = TimeSpan.Zero;

            this.client_Appointment = DateTime.Now;
            this.time_Left          = TimeSpan.Zero;

            if ((counter == 0) || (iCounter == 0))
            {
                return;
            }

            if ((name == "") || (strName == ""))
            {
                return;
            }

            if (_registrationDate.CompareTo(DateTime.Now) == 0)
            {
                return;
            }

            _registrationDate = DateTime.Now;
            Assert.IsNotNull(_registrationDate);
        }
Exemplo n.º 10
0
        public void WhenInsertCoin_WithAnInvalidCoin_ICoinCollectionAddCoinShouldBeInvoked(CoinEnum coinEnum, Type coinType)
        {
            IVendingMachine vendingMachine = Mocker.CreateInstance <VendingMachine>();
            ICoin           coin           = (ICoin)Activator.CreateInstance(coinType);

            Mocker.GetMock <ICoinFactory>().Setup(c => c.Create(coinEnum)).Returns(coin);

            vendingMachine.InsertCoin(coinEnum);

            Mocker.Verify <ICoinReturn>(c => c.AddCoin(coin), Times.Once);
        }