Easy way to compare the values of the two complex objects

less than 1 minute read

public static bool ValueEqual<T1, T2>(T1 expected, T2 actual)
{
    var expectedValues = JsonConvert.SerializeObject(expected);
    var actualValues = JsonConvert.SerializeObject(actual);

    return expectedValues == actualValues;
}

Categories:

Updated:

Comments