public void TestSetEquals() { IImmutableSet <int> set = CreateSet <int>(); Assert.Throws <ArgumentNullException>(() => set.SetEquals(null)); // Test behavior when the current set is empty Assert.True(set.SetEquals(TransformEnumerableForSetOperation(Enumerable.Empty <int>()))); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(Enumerable.Range(0, 1)))); // Test SetEquals self Assert.True(set.SetEquals(TransformEnumerableForSetOperation(set))); // Test with same set type set = set.Union(TransformEnumerableForSetOperation(Enumerable.Range(0, 10))); IImmutableSet <int> other = CreateSet <int>(); other = other.Union(TransformEnumerableForSetOperation(Enumerable.Range(0, 10))); Assert.True(set.SetEquals(TransformEnumerableForSetOperation(other))); other = other.Remove(0); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other))); other = other.Add(-1); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other))); other = other.Remove(-1); other = other.Add(0); other = other.Remove(8); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other))); other = other.Add(11); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other))); // Test with different set type set = set.Clear(); other = other.Clear(); set = set.Union(TransformEnumerableForSetOperation(Enumerable.Range(0, 10))); other = other.Union(TransformEnumerableForSetOperation(Enumerable.Range(0, 10))); Assert.True(set.SetEquals(TransformEnumerableForSetOperation(other.ToArray()))); Assert.True(set.SetEquals(TransformEnumerableForSetOperation(other.Concat(other).ToArray()))); other = other.Remove(0); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other.ToArray()))); other = other.Add(-1); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other.ToArray()))); other = other.Remove(-1); other = other.Add(0); other = other.Remove(8); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other.ToArray()))); other = other.Add(11); Assert.False(set.SetEquals(TransformEnumerableForSetOperation(other.ToArray()))); }