Beispiel #1
0
        public void TestGetHashCode()
        {
            BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle2 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle3 = new BoundingRectangle(2, 3, 4, 5);

            Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
            Assert.AreNotEqual(boundingRectangle1.GetHashCode(), boundingRectangle3.GetHashCode());
        }
        public void TestGetHashCode()
        {
            BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle2 = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle boundingRectangle3 = new BoundingRectangle(2, 3, 4, 5);

            Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
            Assert.AreNotEqual(boundingRectangle1.GetHashCode(), boundingRectangle3.GetHashCode());
        }
        public void AssertThat_HashCode_IsDifferentForDifferentBounds()
        {
            var a = new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10));
            var b = new BoundingRectangle(new Vector2(0, 0), new Vector2(11, 10));

            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void AssertThat_HashCode_IsIdenticalForIdenticalBounds()
        {
            var a = new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10));
            var b = new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10));

            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
Beispiel #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Layer != null ? Layer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)Type;
         hashCode = (hashCode * 397) ^ (Pixels != null ? Pixels.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ BoundingRectangle.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #6
0
        public void Equality(BoundingRectangle boundingRectangle1, BoundingRectangle boundingRectangle2, bool expectedToBeEqual)
        {
            Assert.IsTrue(Equals(boundingRectangle1, boundingRectangle2) == expectedToBeEqual);
            Assert.IsTrue(boundingRectangle1 == boundingRectangle2 == expectedToBeEqual);
            Assert.IsFalse(boundingRectangle1 == boundingRectangle2 != expectedToBeEqual);
            Assert.IsTrue(boundingRectangle1.Equals(boundingRectangle2) == expectedToBeEqual);

            if (expectedToBeEqual)
            {
                Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
            }
        }
Beispiel #7
0
        public void HashCode(BoundingRectangle boundingRectangle1, BoundingRectangle boundingRectangle2, bool expectedThatHashCodesAreEqual)
        {
            var hashCode1 = boundingRectangle1.GetHashCode();
            var hashCode2 = boundingRectangle2.GetHashCode();

            if (expectedThatHashCodesAreEqual)
            {
                Assert.AreEqual(hashCode1, hashCode2);
            }
            else
            {
                Assert.AreNotEqual(hashCode1, hashCode2);
            }
        }