public void TCollection_Set_Equals_Primitive_Different_Test() { var collection1 = new THashSet <int> { 1, 2, 3 }; var collection2 = new THashSet <int> { 1, 2 }; Assert.IsFalse(TCollections.Equals(collection1, collection2)); Assert.IsFalse(collection1.SequenceEqual(collection2)); collection2.Add(4); Assert.IsFalse(TCollections.Equals(collection1, collection2)); Assert.IsFalse(collection1.SequenceEqual(collection2)); }
public void TCollection_Set_Equals_Primitive_Test() { var collection1 = new THashSet <int> { 1, 2, 3 }; var collection2 = new THashSet <int> { 1, 2, 3 }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); }
public void TCollection_Set_Equals_OneAndTheSameObject_Test() { var collection1 = new THashSet <ExampleClass> { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; var collection2 = collection1; // references to one and the same collection Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); }
public void TCollection_Set_Equals_Objects_Test() { var collection1 = new THashSet <ExampleClass> { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; var collection2 = new THashSet <ExampleClass> { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsTrue(collection1.SequenceEqual(collection2)); }
public void TCollection_Set_Set_Equals_Objects_Test() { var collection1 = new THashSet <THashSet <ExampleClass> > { new THashSet <ExampleClass> { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; var collection2 = new THashSet <THashSet <ExampleClass> > { new THashSet <ExampleClass> { new ExampleClass { X = 1 }, new ExampleClass { X = 2 } } }; Assert.IsTrue(TCollections.Equals(collection1, collection2)); Assert.IsFalse(collection1.SequenceEqual(collection2)); // SequenceEqual() calls Equals() of the inner list instead of SequenceEqual() }