Exemplo n.º 1
0
        public void MustSuccessfullyValidateRegexProduct()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.Equal("Coke", vendorMachine.InitialInputProducts);
        }
Exemplo n.º 2
0
        public void MustValidateWithErrorTextInputProductNew()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(string.Concat(VALID_ENTRY, " ", "ProductNew"));

            Assert.False(vendorMachine.IsValid());
        }
Exemplo n.º 3
0
        public void MustSuccessfullyValidateRegexCoin()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.Equal("0.01 0.05 0.10 0.25 0.50 1.00", vendorMachine.InitialInputCoins);
        }
Exemplo n.º 4
0
        public void MustValidateCoinEntrySuccessfullyTest()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.True(vendorMachine.IsValid());
        }
Exemplo n.º 5
0
        public void MustValidateCoinEntryErrorTest()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(INVALID_ENTRY);

            Assert.False(vendorMachine.IsValid());
        }
Exemplo n.º 6
0
        public void MustSuccessfullyValidateCurrencySum()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.True(vendorMachine.IsValid());
            Assert.Equal((decimal)1.91, (decimal)vendorMachine.EnteredValue());
        }
Exemplo n.º 7
0
        public void ShouldReturnExpectedValueOfRegexProduct()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            Assert.Equal("Coke Coke Coke", vendorMachine.RegexRemoveCoins("0.50 Coke 1.00 Coke Coke"));
            Assert.Equal("Coke Coke Coke", vendorMachine.RegexRemoveCoins("0.50 Coke 1.00 1.00 Coke Coke"));
            Assert.Equal("Coke Coke Coke", vendorMachine.RegexRemoveCoins("0.50 Coke 0.50 1.00 Coke Coke"));
            Assert.Equal("Coke Coke", vendorMachine.RegexRemoveCoins("0.50 Coke 1.00 0.05 Coke"));
        }
Exemplo n.º 8
0
        public void ShouldReturnDifferentValueThanExpected()
        {
            Product product1 = new Product("Pastelina", (decimal)1.50, 10);
            Product product2 = new Product("Pastelina", (decimal)1.50, 5);

            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            Assert.False((decimal)8.5 == vendorMachine.amountProductPriceSelected(product1, product2));
        }
Exemplo n.º 9
0
        public void MustValidadeInsufficientNoCoin()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("0.01 Coke");
            vendorMachine.CreateProductInput();

            Assert.False(vendorMachine.sufficientInputValue());
        }
Exemplo n.º 10
0
        public void MustValidadeCreateProductMultipleAmountInputValid()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("0.01 Coke Coke Coke Coke Coke");
            vendorMachine.CreateProductInput();

            Assert.Equal("Coke", vendorMachine.ProductSelected.Name);
            Assert.Equal(5, vendorMachine.ProductSelected.Amount);
        }
Exemplo n.º 11
0
        public void ShouldReturnExpectedValueOfRegexNormalize()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            Assert.Equal("Coke Coke Coke Coke", vendorMachine.RegexRemoveCoins("Coke   Coke Coke      Coke"));
            Assert.Equal("Coke Coke Coke Coke", vendorMachine.RegexRemoveCoins(" Coke     Coke Coke      Coke"));
            Assert.Equal("Coke Coke Coke Coke", vendorMachine.RegexRemoveCoins("Coke Coke Coke      Coke"));
            Assert.Equal("Coke Coke Coke Coke", vendorMachine.RegexRemoveCoins(" Coke   Coke    Coke   Coke"));
            Assert.Equal("Coke Coke Coke Coke", vendorMachine.RegexRemoveCoins("Coke Coke Coke Coke"));
        }
Exemplo n.º 12
0
        public void ShouldReturnExpectedValueWhenCalculatingQuantity()
        {
            Product product1 = new Product("Pastelina", (decimal)1.50, 10);
            Product product2 = new Product("Pastelina", (decimal)1.50, 5);

            //1.50 * 5
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            Assert.Equal((decimal)7.5, vendorMachine.amountProductPriceSelected(product1, product2));
            Assert.True((decimal)7.5 == vendorMachine.amountProductPriceSelected(product1, product2));
        }
Exemplo n.º 13
0
        public void WhenRequestingMultipleProducts()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("1.00 Pastelina Pastelina Pastelina");

            Assert.True(vendorMachine.IsValid());

            vendorMachine.CreateProductInput();

            Assert.Equal("Output: Pastelina = 0.70 Pastelina = 0.40 Pastelina = 0.10", vendorMachine.OutputSystem());
        }
Exemplo n.º 14
0
        public void InsertTooManyValueForProduct()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("1.00 Pastelina CHANGE");

            Assert.True(vendorMachine.IsValid());

            vendorMachine.CreateProductInput();

            Assert.Equal("Output: Pastelina = 0.70 0.50 0.10 0.10", vendorMachine.OutputSystem());
        }
Exemplo n.º 15
0
        public void InsertCoinsAndRequestProduct()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("0.50 1.00 Coke");

            Assert.True(vendorMachine.IsValid());

            vendorMachine.CreateProductInput();

            Assert.Equal("Output: Coke = 0.00", vendorMachine.OutputSystem());
        }
Exemplo n.º 16
0
        public void WhenThereIsNoChange2()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem("0.25 0.05 0.05 Pastelina CHANGE");

            Assert.True(vendorMachine.IsValid());

            vendorMachine.CreateProductInput();

            Assert.Equal("Output: Pastelina = 0.05", vendorMachine.OutputSystem());
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            while (!vendorMachine.IsValid())
            {
                Console.WriteLine("Coins are 0.01, 0.05, 0.10, 0.25, 0.50 and 1.00");
                Console.WriteLine("Products are Coke (cost 1.50), Water (cost: 1.00) and Pastelina (cost: 0.30)");
                Console.Write("Input: ");
                vendorMachine.InputSystem(Console.ReadLine());
            }

            vendorMachine.CreateProductInput();

            vendorMachine.OutputSystem();

            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }