-
-
Notifications
You must be signed in to change notification settings - Fork 194
Comparing Different Types
GregFinzer edited this page Dec 20, 2017
·
1 revision
By default, Compare .NET Objects will not compare classes that are different types, even if they derive from the same base class or interface. To compare classes that are different types, set Config.IgnoreObjectTypes = true
Example
RecipeDetail detail1 = new RecipeDetail(true, "Toffee");
detail1.Ingredient = "Crunchy Chocolate";
IndianRecipeDetail detail2 = new IndianRecipeDetail(true, "Toffee");
detail2.Ingredient = "Crunchy Chocolate";
CompareLogic compareLogic = new CompareLogic();
compareLogic.Config.IgnoreObjectTypes = true;
var result = compareLogic.Compare(detail1, detail2);
Assert.IsTrue(result.AreEqual, result.DifferencesString);