public void GetBasicBestRoutes() { SetUp(); StudentLogic testLogic = new StudentLogic(); SchoolVanLogic schoolVanLogic = new SchoolVanLogic(); Student newStudent = TestStudent(1); newStudent.Id = testLogic.GetNextIdFree() - 1; testLogic.Add(newStudent); SchoolVanLogic logic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); logic.Add(newSchoolVan); newSchoolVan.Id = logic.GetNextIdFree() - 1; Route expectedRoute = new Route(); expectedRoute.TheSchoolVan = newSchoolVan; Coordinate schoolCoordinate = new Coordinate(); expectedRoute.Add(schoolCoordinate); expectedRoute.Add(newStudent); List <Route> expectedRoutes = new List <Route>(); expectedRoutes.Add(expectedRoute); List <Route> obtainRoutes = schoolVanLogic.GetBestRoutes(); Assert.IsTrue(obtainRoutes.SequenceEqual(expectedRoutes)); }
public void SortSchoolVanSuccess() { List <SchoolVan> toSort = new List <SchoolVan>(); SchoolVan firstTestSchoolVan = new SchoolVan(); SchoolVan secondTestSchoolVan = new SchoolVan(); SchoolVan thirdTestSchoolVan = new SchoolVan(); firstTestSchoolVan.Id = 4; secondTestSchoolVan.Id = 2; thirdTestSchoolVan.Id = 3; firstTestSchoolVan.Capacity = 4; secondTestSchoolVan.Capacity = 2; thirdTestSchoolVan.Capacity = 3; toSort.Add(firstTestSchoolVan); toSort.Add(secondTestSchoolVan); toSort.Add(thirdTestSchoolVan); List <SchoolVan> expectedList = new List <SchoolVan>(); expectedList.Add(firstTestSchoolVan); expectedList.Add(thirdTestSchoolVan); expectedList.Add(secondTestSchoolVan); SortSchoolVans sort = new SortSchoolVans(); List <SchoolVan> ObtainedList = sort.GenerateSortedList(toSort); bool result = expectedList.SequenceEqual(ObtainedList); Assert.IsTrue(result); }
public void toStringSchoolVan() { SchoolVan aSchoolVan = new SchoolVan(); aSchoolVan.Id = 123; aSchoolVan.Capacity = 10; Assert.IsTrue(aSchoolVan.ToString().Equals("[123] Capacidad 10 - Consumo 1")); }
public void ExistsSchoolVanFail() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); Assert.IsFalse(testLogic.Exists(newSchoolVan)); }
public void AddSchoolVanSuccess() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); testLogic.Add(newSchoolVan); Assert.IsTrue(testLogic.Exists(newSchoolVan)); }
public void SchoolVanLengthSuccess() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); testLogic.Add(newSchoolVan); Assert.IsTrue(testLogic.Length() == 1); }
public void Add(Object anObject) { if (CanIAdd(anObject)) { SchoolVan newSchoolVan = anObject as SchoolVan; SchoolVanAccess context = new SchoolVanAccess(); context.Add(newSchoolVan); } }
public void AddNewSchoolVan(int capacity, int fuel) { SchoolVanLogic logic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); newSchoolVan.Capacity = capacity; newSchoolVan.FuelConsumption = fuel; newSchoolVan.Id = logic.GetNextIdFree(); logic.Add(newSchoolVan); }
public void GetBestRoutesWithoutStudents() { SetUp(); NoStudentsInSystemException expectedExcetpion = new NoStudentsInSystemException("No Students in the system"); SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); testLogic.Add(newSchoolVan); testLogic.GetBestRoutes(); }
public void CompareSchoolVanDifferentObject() { SchoolVan aVan = new SchoolVan(); SchoolVan anotherVan = new SchoolVan(); int aTestId = 1; int test = 4; aVan.Id = aTestId; Assert.IsFalse(aVan.Equals(test)); }
public void AddInvalidSchoolVan() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); newSchoolVan.Capacity = -30; SchoolVanLogic testLogic = new SchoolVanLogic(); testLogic.Add(newSchoolVan); Assert.IsFalse(testLogic.Exists(newSchoolVan)); }
public void SchoolVanStudentAssignmentSuccess() { SetUp(); List <Tuple <SchoolVan, List <Student> > > expectedValue = new List <Tuple <SchoolVan, List <Student> > >(); StudentLogic testLogic = new StudentLogic(); SchoolVanLogic schoolVanLogic = new SchoolVanLogic(); Student newStudent = TestStudent(100); testLogic.Add(newStudent); newStudent.Id = testLogic.GetNextIdFree() - 1; Student lastStudent = TestStudent(200); testLogic.Add(lastStudent); lastStudent.Id = testLogic.GetNextIdFree() - 1; Student otherStudent = TestStudent(300); testLogic.Add(otherStudent); otherStudent.Id = testLogic.GetNextIdFree() - 1; Student anotherStudent = TestStudent(400); testLogic.Add(anotherStudent); anotherStudent.Id = testLogic.GetNextIdFree() - 1; SchoolVanLogic logic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); newSchoolVan.Id = 15; newSchoolVan.Capacity = 10; logic.Add(newSchoolVan); List <Student> firstStudentList = new List <Student>(); firstStudentList.Add(newStudent); firstStudentList.Add(lastStudent); SchoolVan anotherSchoolVan = new SchoolVan(); anotherSchoolVan.Id = 25; anotherSchoolVan.Capacity = 14; logic.Add(anotherSchoolVan); List <Student> nextStudentList = new List <Student>(); nextStudentList.Add(otherStudent); nextStudentList.Add(anotherStudent); Tuple <SchoolVan, List <Student> > firstTouple = new Tuple <SchoolVan, List <Student> >(anotherSchoolVan, firstStudentList); Tuple <SchoolVan, List <Student> > nextTouple = new Tuple <SchoolVan, List <Student> >(newSchoolVan, nextStudentList); expectedValue.Add(firstTouple); expectedValue.Add(nextTouple); List <Tuple <SchoolVan, List <Student> > > ObtainValue = logic.StudentAssignment(); Assert.IsTrue(CompareStudentAssignment(ObtainValue, expectedValue)); }
public void CompareSchoolVanSuccess() { SchoolVan aVan = new SchoolVan(); SchoolVan anotherVan = new SchoolVan(); int aTestId = 1; aVan.Id = aTestId; aVan.FuelConsumption = 4; anotherVan.Id = aTestId; Assert.IsTrue(aVan.Equals(anotherVan)); }
public void DeleteSchoolDifferentObjectFail() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); int testInt = 0; testLogic.Add(newSchoolVan); testLogic.Remove(testInt); Assert.IsTrue(testLogic.Exists(newSchoolVan)); }
public void CompareSchoolVanFail() { SchoolVan aVan = new SchoolVan(); SchoolVan anotherVan = new SchoolVan(); int aTestId = 1; int anotherTestId = 2; aVan.Id = aTestId; anotherVan.Id = anotherTestId; Assert.IsFalse(aVan.Equals(anotherVan)); }
public void RemoveSchoolVan(object selectedObject) { if (!(selectedObject is SchoolVan)) { throw new WrongObjectException("Se esperaba un objeto del tipo [SchoolVan]"); } SchoolVan toDelete = selectedObject as SchoolVan; SchoolVanLogic logic = new SchoolVanLogic(); logic.Remove(toDelete); }
public void DeleteSchoolVanSuccess() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); testLogic.Add(newSchoolVan); newSchoolVan.Id = testLogic.GetNextIdFree() - 1; testLogic.Remove(newSchoolVan); Assert.IsFalse(testLogic.Exists(newSchoolVan)); }
public void OutOfBandsSchoolVanCapacity() { int aId = 1; int capacity = 2000; SchoolVan aVan = new SchoolVan(); aVan.Id = aId; aVan.Capacity = capacity; SchoolVanValidator validator = new SchoolVanValidator(); Assert.IsFalse(validator.IsValid(aVan)); }
public void ValidSchoolVanCapacity() { int aId = 1; int capacity = 5; SchoolVan aVan = new SchoolVan(); aVan.Id = aId; aVan.Capacity = capacity; SchoolVanValidator validator = new SchoolVanValidator(); Assert.IsTrue(validator.IsValid(aVan)); }
public void ModifySchoolVanFailCheckOldSchoolVan() { SetUp(); SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVan anotherSchoolVan = new SchoolVan(); anotherSchoolVan.Id = -3; testLogic.Add(newSchoolVan); testLogic.Modify(newSchoolVan, anotherSchoolVan); Assert.IsTrue(testLogic.Exists(newSchoolVan)); }
public void LoadFields(object selectedObject, TextBox textId, NumericUpDown numericCapacity, NumericUpDown numericFuel) { if (!(selectedObject is SchoolVan)) { throw new WrongObjectException("Se esperaba un objeto del tipo [SchoolVan]"); } SchoolVan theSchoolVan = selectedObject as SchoolVan; textId.Text = theSchoolVan.Id + ""; numericCapacity.Value = theSchoolVan.Capacity; numericFuel.Value = theSchoolVan.FuelConsumption; }
public void ConstructorSchoolVanIdSuccess() { int aId = 1; int capacity = 5; SchoolVan aVan = new SchoolVan(); aVan.Id = aId; aVan.FuelConsumption = 4; aVan.Capacity = capacity; Assert.IsTrue(aVan.Id.Equals(aId)); Assert.IsTrue(aVan.Capacity.Equals(capacity)); Assert.IsTrue(aVan.FuelConsumption.Equals(4)); }
public void ModifySchoolVanModifyNonExistent() { SetUp(); SchoolVan schoolVan = new SchoolVan(); schoolVan.Id = 4; SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan editedSchoolVan = new SchoolVan(); editedSchoolVan.Id = 50; testLogic.Modify(schoolVan, editedSchoolVan); Assert.IsFalse(testLogic.Exists(editedSchoolVan)); }
public void ModifySchoolVanFail() { SetUp(); SchoolVan schoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan editedSchoolVan = new SchoolVan(); testLogic.Add(schoolVan); schoolVan.Id = testLogic.GetNextIdFree() - 1; editedSchoolVan.Id = testLogic.GetNextIdFree() - 1; testLogic.Modify(schoolVan, editedSchoolVan); Assert.IsTrue(testLogic.Exists(editedSchoolVan)); }
public void GetNextIdFreeSuccess() { SetUp(); SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); newSchoolVan.Id = 1; newSchoolVan.Capacity = 2; testLogic.Add(newSchoolVan); int expectedValue = 0; Assert.IsFalse(testLogic.GetNextIdFree().Equals(expectedValue)); }
public void ModifySchoolVanSuccess() { SetUp(); SchoolVan schoolVan = new SchoolVan(); schoolVan.Id = 4; SchoolVanLogic testLogic = new SchoolVanLogic(); SchoolVan editedSchoolVan = new SchoolVan(); editedSchoolVan.Id = 50; testLogic.Add(schoolVan); testLogic.Modify(schoolVan, editedSchoolVan); Assert.IsTrue(testLogic.Exists(editedSchoolVan)); }
public void AreEqualsSuccess() { SchoolVan aSchoolVan = new SchoolVan(); SchoolVan anotherSchoolVan = new SchoolVan(); aSchoolVan.Id = 1; anotherSchoolVan.Id = 1; List <Route> aListRoute = new List <Route>(); Route aNewRoute = new Route(); int expectedLength = 1; aListRoute.Add(aNewRoute); Assert.IsTrue(aSchoolVan.Equals(anotherSchoolVan) && aListRoute.Count == expectedLength); }
public void InvalidFuelConsumptionSchoolVan() { int aId = 1; int capacity = 10; int fuelConsumption = 0; SchoolVan aVan = new SchoolVan(); aVan.Id = aId; aVan.Capacity = capacity; aVan.FuelConsumption = fuelConsumption; SchoolVanValidator validator = new SchoolVanValidator(); Assert.IsFalse(validator.IsValid(aVan)); }
private List <Student> GetStudentsBySchoolVan(SchoolVan aSchoolVan) { List <Student> students = new List <Student>(); List <Tuple <SchoolVan, List <Student> > > studentsAssignment = StudentAssignment(); foreach (Tuple <SchoolVan, List <Student> > tuple in studentsAssignment) { if (tuple.Item1.Equals(aSchoolVan)) { students = tuple.Item2; } } return(students); }
public void AddSchoolVanFail() { SetUp(); SchoolVan newSchoolVan = new SchoolVan(); SchoolVanLogic testLogic = new SchoolVanLogic(); testLogic.Add(newSchoolVan); SchoolVan anotherNewSchoolVan = new SchoolVan(); testLogic.Add(anotherNewSchoolVan); int expectedSchoolVanListLength = 2; Assert.IsTrue(testLogic.Length() == expectedSchoolVanListLength); }