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(); } } } }
public void CHeckFile() { var f = new FileRepo(); var vendinglist = f.GrabInfo(); foreach (var v in vendinglist) { Assert.IsNotNull(v.Value.Location); } }
public void CheckInv() { var f = new FileRepo(); var vendinglist = f.GrabInfo(); foreach (var v in vendinglist) { Assert.LessOrEqual(0, v.Value.Inventory); } }
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); } }
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); } }
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})"); } } }