public void Contains_WhenInstanceAdded_ReturnsTrueWhenTestedWithDifferentInstanceHavingSameValue() { var myInt = new SomeInt(42); var myIntCopy = new SomeInt(42); var otherInt = new SomeInt(4111); Assert.IsTrue(myInt == myIntCopy); Assert.IsFalse(myInt.Equals(otherInt)); var mySet = new HashSet <SomeInt>(); mySet.Add(myInt); Assert.IsTrue(mySet.Contains(myIntCopy)); }
public bool Equals(Entity other) { //Check whether the compared object is null. if (Object.ReferenceEquals(other, null)) { return(false); } //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, other)) { return(true); } //Check whether the products' SomeString and SomeInt properties are equal. return(SomeString.Equals(other.SomeString) && SomeInt.Equals(other.SomeInt)); }