private bool CompareNonNull(IEnumerable <T> actual, IEnumerable <T> expected) { Debug.Assert(actual != null); Debug.Assert(expected != null); var actualCount = new CountedSet(actual, comparer); var expectedCount = new CountedSet(expected, comparer); if (actualCount.Count != expectedCount.Count) { return(false); } if (actualCount.NullCount != expectedCount.NullCount) { return(false); } foreach (T item in actualCount) { if (actualCount.HowMany(item) != expectedCount.HowMany(item)) { return(false); } } return(true); }