public void CompareAdvancedTest() { EngineType engine1 = new EngineType(4, 408.5), engine2 = new EngineType(6, 456.2); List <Car> cars1 = new List <Car>(), cars2 = new List <Car>(); cars1.Add(new Car("Car1", engine1, 5)); cars1.Add(new Car("Car2", engine2, 4)); cars2.Add(new Car("Car1", engine1, 5)); cars2.Add(new Car("Car2", engine2, 4)); // same values, same order, different instances Assert.IsTrue(ObjectMD5.Compare(cars1, cars2)); Car car1 = cars2[0]; cars2[0] = cars2[1]; cars2[1] = car1; // same values, different order, different instances Assert.IsFalse(ObjectMD5.Compare(cars1, cars2)); cars2.Add(new Car("Car3", engine1, 5)); // different values Assert.IsFalse(ObjectMD5.Compare(cars1, cars2)); }
public void CompareSimpleTest() { EngineType engine1 = new EngineType(4, 408.5), engine2 = new EngineType(6, 456.2); Car car1_0 = new Car("Car1", engine1, 5), car2_0 = new Car("Car2", engine2, 4), car1_1 = new Car("Car1", engine1, 5), car3_0 = new Car("Car3", engine2, 5); // compare different instances, same values Assert.IsTrue(ObjectMD5.Compare(car1_0, car1_1)); // compare different instances, different values Assert.IsFalse(ObjectMD5.Compare(car1_0, car2_0)); // compare same instances Assert.IsTrue(ObjectMD5.Compare(car2_0.Engine, car3_0.Engine)); }