public void MachineTestObjectAdded() { Database database = new Database(); Machine machine1 = new Machine("Hartford", "Downtown", "M100"); database.Append(machine1); List<Machine> MachineList = database.SelectAllMachine(); Assert.AreEqual(machine1, MachineList[0]); }
public void MachineNeedRestockInitial() { Database database = new Database(); Machine machine1 = new Machine("Hartford", "Downtown", "M100"); database.Append(machine1); List<Machine> MachineList = database.SelectAllMachine(); Assert.AreEqual(true, MachineList[0].NeedRestock); }
private void button1_Click(object sender, EventArgs e) { try { // Prebuild Existing Machine ID list for comparison List <string> existingIDList = new List <string>(); foreach (Machine machine in database.SelectAllMachine()) { existingIDList.Add(machine.MachineID); } string productType = textBox1.Text; string maxCapacityString = textBox2.Text; string city = textBox3.Text; string location = textBox4.Text; string minimumStockString = textBox5.Text; string machineID = textBox6.Text; if (!existingIDList.Contains(machineID)) { if (productType != "" & productType != null & maxCapacityString != "" & maxCapacityString != null & city != "" & city != null & location != "" & location != null & minimumStockString != "" & minimumStockString != null & machineID != "" & machineID != null) { int maxCapacity = int.Parse(maxCapacityString); int minimumStock = int.Parse(minimumStockString); // Create Record Controller controller = new Controller(database); controller.AddMachine(machineID, city, location, maxCapacity, minimumStock, productType); this.parent.LoadMachineListAllDataGrid(); this.Close(); } else { MessageBox.Show("Please enter all employee information"); } } else { MessageBox.Show("That Employee ID already exists. Please select a new ID."); } } catch { MessageBox.Show("Invalid Entries - Please enter employee information."); } }
public void MachineCheckProductSingleQuantity() { Database database = new Database(); Machine machine1 = new Machine("Hartford", "Downtown", "M100"); Product product1 = new Product("coke", .75f); Product product2 = new Product("snickers", .75f); machine1.addProduct(product1); machine1.addProduct(product2); database.Append(machine1); List<Machine> MachineList = database.SelectAllMachine(); Assert.AreEqual(1, MachineList[0].getSingleQuantity("coke")); }
public void MachineCheckProductTypeNames() { Database database = new Database(); Machine machine1 = new Machine("Hartford", "Downtown", "M100"); Product product1 = new Product("coke", .75f); Product product2 = new Product("snickers", .75f); machine1.addProduct(product1); machine1.addProduct(product2); List<string> expected = new List<string> { "coke", "snickers" }; database.Append(machine1); List<Machine> MachineList = database.SelectAllMachine(); CollectionAssert.AreEqual(expected, MachineList[0].getProductNames()); }
public void MachineUpdateRetailPrice() { Database database = new Database(); Machine machine1 = new Machine("Hartford", "Downtown", "M100"); Product product1 = new Product("coke", .75f); Product product2 = new Product("snickers", .75f); machine1.addProduct(product1); machine1.addProduct(product2); machine1.updateRetailPrice("coke", 2.00f); float expected = 2.00f; database.Append(machine1); List<Machine> MachineList = database.SelectAllMachine(); Assert.AreEqual(expected, product1.RetailPrice); }