sdk/dotnet/test/Datasync.Common.Test/AssertEx.cs
/// <summary>
/// Assert that the two JObjects are identical enough.
/// </summary>
/// <param name="expected"></param>
/// <param name="actual"></param>
Assert that the two JObjects are identical enough.
Assert that the two JObjects are identical enough .
public static void JsonEqual(JObject expected, JObject actual)
        {
            static bool DoCheck(JProperty prop) => prop.Value.Type switch
            {
                JTokenType.Null => false,
                JTokenType.Boolean => prop.Value.Value<bool>(),
                _ => true
            };
            foreach (JProperty expectedProp in expected.Properties().Where(prop => DoCheck(prop)))
            {
                JProperty actualProp = actual.Properties().SingleOrDefault(ap => ap.Name == expectedProp.Name);
                Assert.Equal(expectedProp.Value, actualProp.Value);
            }
        }
public static void JsonEqual ( JObject expected , JObject actual ) { static bool DoCheck ( JProperty prop ) => prop . Value . Type switch { JTokenType . Null => false , JTokenType . Boolean => prop . Value . Value < bool > ( ) , _ => true } ; foreach ( JProperty expectedProp in expected . Properties ( ) . Where ( prop => DoCheck ( prop ) ) ) { JProperty actualProp = actual . Properties ( ) . SingleOrDefault ( ap => ap . Name == expectedProp . Name ) ; Assert . Equal ( expectedProp . Value , actualProp . Value ) ; } }
Assert that the two JObjects are identical enough.
Assert that the two JObjects are identical enough .
// Each property in the expectedItem should be present in the actualItem unless the value is null.
expected
JObject
None
actual
JObject
None