예제 #1
0
        public void TestHashCodeSameObject()
        {
            using (StringWriter sw = new StringWriter())
            {
                LicensePlate li1 = new LicensePlate("FI", "ABC-123");

                // Assert
                Assert.AreEqual(li1.GetHashCode(), li1.GetHashCode(), "GetHashCode should work if compared to self!");
            }
        }
예제 #2
0
        public void TestHashCodeDifferentObjectDifferentDate()
        {
            using (StringWriter sw = new StringWriter())
            {
                LicensePlate li1 = new LicensePlate("FI", "ABC-123");
                LicensePlate li2 = new LicensePlate("FI", "UXE-465");

                // Assert
                Assert.AreNotEqual(li1.GetHashCode(), li2.GetHashCode(), "GetHashCode should not work if compared to different date!");
            }
        }
예제 #3
0
        public void TestHashCodeDifferentObjectSameDate()
        {
            using (StringWriter sw = new StringWriter())
            {
                LicensePlate li1 = new LicensePlate("FI", "ABC-123");
                LicensePlate li2 = new LicensePlate("FI", "ABC-123");

                // Assert
                Assert.AreEqual(li1.GetHashCode(), li2.GetHashCode(), "GetHashCode should work if compared to same date!");
            }
        }
예제 #4
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LicensePlate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ContainerId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ShipId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TrainId?.GetHashCode() ?? 0);
            return(hashCode);
        }
예제 #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Surname != null ? Surname.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LicensePlate != null ? LicensePlate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Phone != null ? Phone.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Apartaments != null ? Apartaments.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #6
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (LicensePlate != null)
         {
             hashCode = hashCode * 59 + LicensePlate.GetHashCode();
         }
         if (Visit != null)
         {
             hashCode = hashCode * 59 + Visit.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #7
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (LicensePlate != null)
         {
             hashCode = hashCode * 59 + LicensePlate.GetHashCode();
         }
         if (Engine != null)
         {
             hashCode = hashCode * 59 + Engine.GetHashCode();
         }
         if (Body != null)
         {
             hashCode = hashCode * 59 + Body.GetHashCode();
         }
         if (LowVoltage != null)
         {
             hashCode = hashCode * 59 + LowVoltage.GetHashCode();
         }
         if (Lighting != null)
         {
             hashCode = hashCode * 59 + Lighting.GetHashCode();
         }
         if (Brakes != null)
         {
             hashCode = hashCode * 59 + Brakes.GetHashCode();
         }
         if (Sensors != null)
         {
             hashCode = hashCode * 59 + Sensors.GetHashCode();
         }
         if (Miscellaneous != null)
         {
             hashCode = hashCode * 59 + Miscellaneous.GetHashCode();
         }
         if (Conditioning != null)
         {
             hashCode = hashCode * 59 + Conditioning.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #8
0
 public override int GetHashCode()
 {
     return(LicensePlate?.GetHashCode() ?? 0);
 }