public void TestIntersectWithEdgeCase() { var equalityComparer = EqualityComparer <int> .Default; Func <int, int> getHashCode = value => Math.Abs(value) < 5 ? 0 : 1; var set = new TreeSet <int>(branchingFactor: 4, comparer: new SubsetHashCodeEqualityComparer <int>(equalityComparer, getHashCode)); var other = new TreeSet <int>(branchingFactor: 4, comparer: set.Comparer); set.UnionWith(Enumerable.Range(0, 10)); other.UnionWith(new[] { 4, 3, 5 }); set.IntersectWith(other); Assert.Equal(new[] { 3, 4, 5 }, set); }