Esempio n. 1
0
        public void Purchase(decimal currentFunds, string vendingChoice)
        {
            var vendinglist = f.GrabInfo();
            var list        = vendinglist.ToList();

            foreach (var v in list)
            {
                if (v.Value.Location == vendingChoice)
                {
                    if (currentFunds >= v.Value.Price)
                    {
                        Console.WriteLine($"You have purchased {v.Value.Name}");

                        Console.ReadKey();
                        v.Value.Inventory--;
                        var result = f.Update(vendinglist);
                        if (result == true)
                        {
                            Console.WriteLine("The item inventory has successfully be updated.");
                        }
                        else
                        {
                            Console.WriteLine("The file has not been updated......");
                        }
                        continue;
                    }
                    else
                    {
                        Console.WriteLine("You do not have enough funds, please enter more!");
                        Console.ReadKey();
                    }
                }
            }
        }
Esempio n. 2
0
 public void CHeckFile()
 {
     var f = new FileRepo();
     var vendinglist = f.GrabInfo();
     foreach (var v in vendinglist)
     {
         Assert.IsNotNull(v.Value.Location);
     }
 }
Esempio n. 3
0
        public void CheckInv()
        {
            var f = new FileRepo();
            var vendinglist = f.GrabInfo();

            foreach (var v in vendinglist)
            {
                Assert.LessOrEqual(0, v.Value.Inventory);
            }
        }
Esempio n. 4
0
        public void Inventory()
        {
            var f = new FileRepo();
            var vendinglist = f.GrabInfo();

            foreach (var v in vendinglist)
            {
                // this is pretty much the same thing I had in the controller, would write to the file after doing v.value.Inventory - 1;
                Assert.AreNotEqual(v.Value.Inventory, v.Value.Inventory - 1);
            }
        }
Esempio n. 5
0
 public void Funds()
 {
     int currentfunding = 30;
     var f = new FileRepo();
     var vendinglist = f.GrabInfo();
     foreach (var v in vendinglist)
     {
         // this passed till it hit a vaule that was above the amount that was inputed aka the funds in the machine
         Assert.LessOrEqual(v.Value.Price, currentfunding);
     }
 }
Esempio n. 6
0
        public void ListItems()
        {
            FileRepo f = new FileRepo();

            var vending = f.GrabInfo();

            foreach (var data in vending)
            {
                if (data.Value.Inventory > 0)
                {
                    Console.WriteLine($"{data.Value.Location} {data.Value.Name} {data.Value.Price} ({data.Value.Inventory})");
                }
            }
        }