Beispiel #1
0
        public void EqualsAndHash()
        {
            Inertial inertial = new Inertial(new Origin(), new Mass(1), new Inertia(0, 0, 0, 0, 0, 0));
            Inertial same     = new Inertial(new Origin(), new Mass(1), new Inertia(0, 0, 0, 0, 0, 0));
            Inertial diff     = new Inertial(new Origin(), new Mass(2), new Inertia(2, 2, 2, 2, 2, 2));

            Assert.IsTrue(inertial.Equals(inertial));
            Assert.IsFalse(inertial.Equals(null));
            Assert.IsTrue(inertial.Equals(same));
            Assert.IsTrue(same.Equals(inertial));
            Assert.IsFalse(inertial.Equals(diff));
            Assert.AreEqual(inertial.GetHashCode(), same.GetHashCode());
            Assert.AreNotEqual(inertial.GetHashCode(), diff.GetHashCode());
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Inertial != null ? Inertial.GetHashCode() : 0);
         foreach (var visual in Visual)
         {
             hashCode = (hashCode * 397) ^ visual.GetHashCode();
         }
         foreach (var collision in Collision)
         {
             hashCode = (hashCode * 397) ^ collision.GetHashCode();
         }
         return(hashCode);
     }
 }