Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
papafe committed Oct 18, 2023
1 parent 2fdea52 commit 9dfc21c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Realm/Realm/DatabaseTypes/RealmValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1534,12 +1534,25 @@ public bool Equals(RealmValue other)
RealmValueType.Object => AsIRealmObject().Equals(other.AsIRealmObject()),
RealmValueType.List => AsList().SequenceEqual(other.AsList()),
RealmValueType.Set => AsSet().SetEquals(other.AsSet()),
RealmValueType.Dictionary => AsDictionary().Count == other.AsDictionary().Count && !AsDictionary().Except(other.AsDictionary()).Any(),
RealmValueType.Dictionary => CompareDicts(this, other),
RealmValueType.Null => true,
_ => false,
};
}

private bool CompareDicts(RealmValue first, RealmValue second)
{
var firstDict = first.AsDictionary();
var secondDict = second.AsDictionary();

if (firstDict.Count != secondDict.Count)
{
return false;
}

return firstDict.OrderBy(kvp => kvp.Key).SequenceEqual(secondDict.OrderBy(kvp => kvp.Key));
}

/// <summary>
/// Compares two <see cref="RealmValue"/> instances for equality.
/// </summary>
Expand Down

0 comments on commit 9dfc21c

Please sign in to comment.