private void buttonModify_Click(object sender, EventArgs e) { try { var selectedVehicleToModify = this.comboBoxSelectVehicleToModify.SelectedItem as Vehicle; var newCapacity = (int)this.numericUpDownCapacity.Value; var newFuelConsumption = (int)this.numericUpDownFuelConsumption.Value; ModifyVehicleInput newVehicleValues = new ModifyVehicleInput { Registration = selectedVehicleToModify.Registration, NewCapacity = newCapacity, FuelConsumptionKmsPerLtr = newFuelConsumption }; IVehicleLogic vehicleOperations = Provider.GetInstance.GetVehicleOperations(); vehicleOperations.ModifyVehicle(newVehicleValues); this.labelSuccess.Visible = true; this.labelSuccess.Text = "The vehicle was succesfully modified."; this.ClearForm(); this.ReloadComboBoxSelectVehicleToModify(); } catch (CoreException ex) { this.labelError.Visible = true; this.labelSuccess.Text = ex.Message; } catch (Exception ex) { this.labelError.Visible = true; this.labelSuccess.Text = ex.Message; } }
public void ModifyVehicleCapacityInSystem() { IVehicleLogic vehicleOperations = DummyProvider.GetInstance.GetVehicleOperations(); Vehicle newVehicle = new Vehicle("SBA1234", 10, 10); vehicleOperations.AddVehicle(newVehicle); ModifyVehicleInput input = new ModifyVehicleInput(); input.Registration = "SBA1234"; input.NewCapacity = 20; input.FuelConsumptionKmsPerLtr = 10; vehicleOperations.ModifyVehicle(input); Vehicle modifiedVehicle = vehicleOperations.GetVehicleByRegistration("SBA1234"); Assert.AreEqual(modifiedVehicle.GetCapacity(), input.NewCapacity); }