private void FillListBoxVehiclesOrderedByEfficiency() { try { IVehicleLogic vehicleOperations = Provider.GetInstance.GetVehicleOperations(); var vehicles = vehicleOperations.GetVehiclesOrderedByEfficiencyConsideringStudentsNumber(); for (int index = 0; index < vehicles.Count; index++) { this.listBoxVehiclesOrderedByEfficiency.Items.Add(vehicles[index]); this.listBoxVehiclesOrderedByEfficiency.DisplayMember = "Item1"; } } catch (CoreException ex) { this.labelError.Text = ex.Message; this.labelError.Visible = true; } }
public void CalculateDistanceToCoverByVehicle() { IVehicleLogic vehicleOperations = DummyProvider.GetInstance.GetVehicleOperations(); IStudentLogic studentOperations = DummyProvider.GetInstance.GetStudentOperations(); Vehicle vehicle = new Vehicle("SBA0001", 10, 10); vehicleOperations.AddVehicle(vehicle); Student studentOne = new Student(); studentOne.Document = "1234567-1"; studentOne.Name = "John"; studentOne.Location = new Location(2.00000, 2.000000); studentOne.HavePickUpService = true; studentOne.StudentNumber = 1; Student studentTwo = new Student(); studentTwo.Document = "1234567-2"; studentTwo.Name = "George"; studentTwo.Location = new Location(1.00000, 1.000000); studentTwo.HavePickUpService = true; studentTwo.StudentNumber = 2; Student studentThree = new Student(); studentThree.Document = "1234567-3"; studentThree.Name = "Paul"; studentThree.Location = new Location(3.00000, 3.000000); studentThree.HavePickUpService = true; studentThree.StudentNumber = 3; Student studentFour = new Student(); studentFour.Document = "1234567-4"; studentFour.Name = "Ringo"; studentFour.Location = new Location(20.00000, 20.000000); studentFour.HavePickUpService = true; studentFour.StudentNumber = 4; studentOperations.AddStudent(studentOne); studentOperations.AddStudent(studentTwo); studentOperations.AddStudent(studentThree); studentOperations.AddStudent(studentFour); List <Tuple <Vehicle, List <Student> > > vehiclesWithStudents = vehicleOperations.GetVehiclesOrderedByEfficiencyConsideringStudentsNumber(); var expectedDistance = 0.0; expectedDistance += Utils.Distance(new Location(), studentTwo.Location); expectedDistance += Utils.Distance(studentTwo.Location, studentOne.Location); expectedDistance += Utils.Distance(studentOne.Location, studentThree.Location); expectedDistance += Utils.Distance(studentThree.Location, studentFour.Location); expectedDistance += Utils.Distance(studentFour.Location, new Location()); var distance = vehicleOperations.CalculateDistanceToCoverByVehicle(vehiclesWithStudents[0]); Assert.IsTrue(distance == expectedDistance); }