示例#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();
                    }
                }
            }
        }
示例#2
0
 public void CHeckFile()
 {
     var f = new FileRepo();
     var vendinglist = f.GrabInfo();
     foreach (var v in vendinglist)
     {
         Assert.IsNotNull(v.Value.Location);
     }
 }
示例#3
0
        public void CheckInv()
        {
            var f = new FileRepo();
            var vendinglist = f.GrabInfo();

            foreach (var v in vendinglist)
            {
                Assert.LessOrEqual(0, v.Value.Inventory);
            }
        }
示例#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);
            }
        }
示例#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);
     }
 }
示例#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})");
                }
            }
        }