public void ShouldGenerateSameHashcode()
        {
            var dateTime1 = new LocalDateTime(1947, 12, 17, 15, 12, 01, 789000000);
            var dateTime2 = new LocalDateTime(new DateTime(1947, 12, 17, 15, 12, 01, 789, DateTimeKind.Local));

            dateTime1.GetHashCode().Should().Be(dateTime2.GetHashCode());
        }
        public void ShouldGenerateDifferentHashcode()
        {
            var dateTime1 = new LocalDateTime(1947, 12, 17, 15, 12, 01, 789000000);
            var dateTime2 = new LocalDateTime(new DateTime(1947, 12, 17, 15, 12, 01, 790));

            dateTime1.GetHashCode().Should().NotBe(dateTime2.GetHashCode());
        }
Ejemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = date.GetHashCode();
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Account != null ? Account.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Amount;
         return(hashCode);
     }
 }