public void Equals_InvokeObject_ReturnsExpected(Margins margins, object obj, bool expected) { Assert.Equal(expected, margins.Equals(obj)); if (obj is Margins) { Assert.Equal(expected, margins.GetHashCode().Equals(obj.GetHashCode())); } }
public override int GetHashCode() { unchecked { var hashCode = Name != null?Name.GetHashCode() : 0; hashCode = (hashCode * 397) ^ Width; hashCode = (hashCode * 397) ^ Height; hashCode = (hashCode * 397) ^ CornerArea.GetHashCode(); hashCode = (hashCode * 397) ^ Margins.GetHashCode(); return(hashCode); } }
public void Ctor4Int() { Margins m1 = new Margins(Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue); Assert.AreEqual(Int32.MaxValue, m1.Left, "Left"); Assert.AreEqual(Int32.MaxValue, m1.Top, "Top"); Assert.AreEqual(Int32.MaxValue, m1.Right, "Right"); Assert.AreEqual(Int32.MaxValue, m1.Bottom, "Bottom"); // right smaller than left Margins m2 = new Margins(Int32.MaxValue, 0, 10, 20); // bottom smaller than top Margins m3 = new Margins(10, 20, Int32.MaxValue, 0); Assert.IsFalse(m2.GetHashCode() == m3.GetHashCode(), "GetHashCode"); Assert.IsTrue(m1 != m2, "m1 != m2"); Assert.IsFalse(m1 == m2, "m1 == m2"); }