public void TestField_Compare_ThroughRelationship_TwoLevels() { //---------------Set up test pack------------------- new Engine(); //TO Load ClassDefs new Car(); //TO Load ClassDefs ContactPerson contactPerson1 = ContactPerson.CreateSavedContactPerson("ZZZZ"); ContactPerson contactPerson2 = ContactPerson.CreateSavedContactPerson("AAAA"); Car car1 = Car.CreateSavedCar("2", contactPerson1); Car car2 = Car.CreateSavedCar("5", contactPerson2); Engine car1engine1 = Engine.CreateSavedEngine(car1, "20"); Engine car2engine1 = Engine.CreateSavedEngine(car2, "50"); OrderCriteriaField orderCriteriaField = OrderCriteriaField.FromString("Engine.Car.Owner.Surname"); //---------------Execute Test ---------------------- int comparisonResult = orderCriteriaField.Compare(car1engine1, car2engine1); //---------------Test Result ----------------------- Assert.Greater(comparisonResult, 0, "engine1 should be greater as its car's regno is greater"); //---------------Tear Down ------------------------- }
public void TestField_Compare_ThroughRelationship() { //---------------Set up test pack------------------- Car car1 = new Car(); car1.CarRegNo = "5"; Car car2 = new Car(); car2.CarRegNo = "2"; Engine engine1 = new Engine(); engine1.CarID = car1.CarID; engine1.EngineNo = "20"; Engine engine2 = new Engine(); engine2.CarID = car2.CarID; engine2.EngineNo = "50"; ITransactionCommitter committer = BORegistry.DataAccessor.CreateTransactionCommitter(); committer.AddBusinessObject(car1); committer.AddBusinessObject(car2); committer.AddBusinessObject(engine1); committer.AddBusinessObject(engine2); committer.CommitTransaction(); OrderCriteriaField orderCriteriaField = OrderCriteriaField.FromString("Engine.Car.CarRegNo"); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- int comparisonResult = orderCriteriaField.Compare(engine1, engine2); //---------------Test Result ----------------------- Assert.Greater(comparisonResult, 0, "engine1 should be greater as its car's regno is greater"); //---------------Tear Down ------------------------- }