/// <summary> /// Test whether two collections are equivalent /// </summary> /// <param name="actual"></param> /// <returns></returns> protected override bool doMatch(IEnumerable actual) { // This is just an optimization if (expected is ICollection && actual is ICollection) { if (((ICollection)actual).Count != ((ICollection)expected).Count) { return(false); } } CollectionTally tally = Tally(expected); return(tally.TryRemove(actual) && tally.Count == 0); }
private bool DictionariesEqual(IDictionary x, IDictionary y, ref Tolerance tolerance) { if (x.Count != y.Count) { return(false); } CollectionTally tally = new CollectionTally(this, x.Keys); if (!tally.TryRemove(y.Keys) || tally.Count > 0) { return(false); } foreach (object key in x.Keys) { if (!AreEqual(x[key], y[key], ref tolerance)) { return(false); } } return(true); }
private bool DictionariesEqual(IDictionary x, IDictionary y, ref Tolerance tolerance) { if (x.Count != y.Count) return false; CollectionTally tally = new CollectionTally(this, x.Keys); if (!tally.TryRemove(y.Keys) || tally.Count > 0) return false; foreach (object key in x.Keys) if (!AreEqual(x[key], y[key], ref tolerance)) return false; return true; }