コード例 #1
0
        public void EqualsTest()
        {
            var a = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
            var b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));

            Assert.IsFalse(((object)a).Equals(3));

            Assert.IsTrue(a.Equals(b));
            Assert.IsTrue(((object)a).Equals(b));
            Assert.IsTrue(a == b);
            Assert.IsFalse(a != b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 22, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 33), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(11, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(11, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 22, 3, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 33, 4).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 44).Normalized, new Vector3F(4, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(44, 5, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 55, 6));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

            b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 66));
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(((object)a).Equals(b));
            Assert.IsFalse(a == b);
            Assert.IsTrue(a != b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #2
0
        public void EqualsTest()
        {
            var a = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
              var b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));

              Assert.IsFalse(((object)a).Equals(3));

              Assert.IsTrue(a.Equals(b));
              Assert.IsTrue(((object)a).Equals(b));
              Assert.IsTrue(a == b);
              Assert.IsFalse(a != b);
              Assert.AreEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 22, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 33), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(11, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(11, 2, 3, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 22, 3, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 33, 4).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 44).Normalized, new Vector3F(4, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(44, 5, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 55, 6));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());

              b = new SrtTransform(new Vector3F(1, 2, 3), new QuaternionF(1, 2, 3, 4).Normalized, new Vector3F(4, 5, 66));
              Assert.IsFalse(a.Equals(b));
              Assert.IsFalse(((object)a).Equals(b));
              Assert.IsFalse(a == b);
              Assert.IsTrue(a != b);
              Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }