Deep compare
27 May 2018
code deep compare dotnet testingSimple method for deep comparing objects in .net
Requires CompareNETObjects nuget package from GregFinzer
public static class ObjectExtensions
{
public static bool IsDeeplyEqualTo(this object actual, object expected)
{
CompareLogic compareLogic = new CompareLogic();
compareLogic.Config.MaxDifferences = 100;
ComparisonResult result = compareLogic.Compare(expected, actual);
if (result.AreEqual)
return true;
throw new ObjectsNotEqualException(result.DifferencesString);
}
}
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.