Пример #1
0
        public void GetHashCode_Different()
        {
            var noteId1 = new NoteId(new FourBitNumber(1), new SevenBitNumber(2));
            var noteId2 = new NoteId(new FourBitNumber(2), new SevenBitNumber(1));

            Assert.AreNotEqual(noteId1.GetHashCode(), noteId2.GetHashCode(), "Hash codes for different objects are the same.");
        }
Пример #2
0
        public void GetHashCode_Same()
        {
            var noteId1 = new NoteId(new FourBitNumber(1), new SevenBitNumber(2));
            var noteId2 = new NoteId(new FourBitNumber(1), new SevenBitNumber(2));

            Assert.AreEqual(noteId1.GetHashCode(), noteId2.GetHashCode(), "Hash codes for identical objects are different.");
        }
Пример #3
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 (DutyId != null)
         {
             hashCode = hashCode * 59 + DutyId.GetHashCode();
         }
         if (NoteId != null)
         {
             hashCode = hashCode * 59 + NoteId.GetHashCode();
         }
         if (Content != null)
         {
             hashCode = hashCode * 59 + Content.GetHashCode();
         }
         return(hashCode);
     }
 }
 /// <summary>
 /// Override of <see cref="object.GetHashCode" />.
 /// </summary>
 /// <returns>Returns the result of calling <see cref="object.GetHashCode" /> on the <see cref="NoteId" /> property.</returns>
 public override int GetHashCode()
 {
     return(NoteId.GetHashCode());
 }