/// <summary> /// AddVehicle button will take the information entered on the form and /// create a vehicle representation in the database. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddVehicle_Click(object sender, EventArgs e) { if (carColorCB.SelectedItem == null || carTypeCB.SelectedItem == null || carMakeCB.SelectedItem == null || carModelCB.Text == "" || carLocationCB.SelectedItem == null) { SetAndDisplayResponseMessage(FORM_NOT_FILLED_MESSAGE); } else { string type = carTypeCB.SelectedItem.ToString(); string color = carColorCB.SelectedItem.ToString(); int year = (Int32)carYearCB.Value; string model = carModelCB.Text.ToString(); string carMake = carMakeCB.SelectedItem.ToString(); string carlocation = carLocationCB.SelectedItem.ToString(); bool rightHand = rightHandCheck.Checked; bool manual = manualCheck.Checked; int rate = (Int32)rateBox.Value; Vehicle v = new Vehicle(type, color, year, model, carMake, rightHand, manual, rate, carlocation); VehicleControl.AddVehicle(v); if (VehicleWasAdded(v.PrimaryKey)) { SetAndDisplayResponseMessage(VEHICLE_ADDED_MESSAGE); } else { SetAndDisplayResponseMessage(VEHICLE_NOT_ADDED_MESSAGE); } ResetForm(); } }
public void AddVehicleTest() { Vehicle v1 = new Vehicle("1", "Blue", 2018, "2", "3", false, false, 10, "Madison"); VehicleControl.AddVehicle(v1); Vehicle v2 = DBController.GetByPrimaryKey <Vehicle>(v1.PrimaryKey); Assert.IsNotNull(v2); }
public void SetVehicleListTest() { DateTime initialDateControl = new DateTime(2015, 8, 16, 0, 0, 0); DateTime finalDateControl = new DateTime(2015, 11, 15, 23, 59, 59); double hourPrice = 5; ValidityControl.AddDateControl(hourPrice, initialDateControl, finalDateControl); string board = "ABC 8801"; DateTime dateIn = new DateTime(2015, 9, 25, 15, 30, 0); VehicleEntrance vehicle = new VehicleEntrance(board, dateIn); VehicleControl.AddVehicle(vehicle); Assert.AreEqual(vehicle, VehicleControl.GetVehicleInside(vehicle.Board)); }
public void FindPurchaseTest() { Vehicle v1 = new Vehicle(); VehicleControl.AddVehicle(v1); int key = v1.PrimaryKey; Purchase p1 = PurchaseControl.FindPurchase(key); Assert.IsNull(p1); p1 = new Purchase(); p1.VehicleID = key; Customer c1 = DBController.GetAllRecords <Customer>().FirstOrDefault(); p1.CustomerID = c1.PrimaryKey; PurchaseControl.AddPurchase(p1); Purchase p2 = PurchaseControl.FindPurchase(key); Assert.IsNotNull(p2); }