Example #1
0
        public void MustValidateWithErrorTextInputProductNew()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

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

            Assert.False(vendorMachine.IsValid());
        }
Example #2
0
        public void MustValidateCoinEntrySuccessfullyTest()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.True(vendorMachine.IsValid());
        }
Example #3
0
        public void MustValidateCoinEntryErrorTest()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(INVALID_ENTRY);

            Assert.False(vendorMachine.IsValid());
        }
Example #4
0
        public void MustSuccessfullyValidateCurrencySum()
        {
            SystemVendorMachine vendorMachine = new SystemVendorMachine();

            vendorMachine.InputSystem(VALID_ENTRY);

            Assert.True(vendorMachine.IsValid());
            Assert.Equal((decimal)1.91, (decimal)vendorMachine.EnteredValue());
        }
Example #5
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());
        }
Example #6
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());
        }
Example #7
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());
        }
Example #8
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());
        }
Example #9
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();
        }