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!"); } }
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!"); } }
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!"); } }
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); }
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); } }
/// <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); } }
/// <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); } }
public override int GetHashCode() { return(LicensePlate?.GetHashCode() ?? 0); }