Ejemplo n.º 1
0
 public override bool Equals(object obj)
 {
     return(obj is Transaction transaction &&
            Description == transaction.Description &&
            EqualityComparer <ICategory> .Default.Equals(Category, transaction.Category) &&
            date.Equals(transaction.date) &&
            EqualityComparer <IAccount> .Default.Equals(Account, transaction.Account) &&
            Amount == transaction.Amount);
 }
        public void ShouldNotBeEqualToNull()
        {
            var dateTime = new LocalDateTime(1947, 12, 17, 15, 12, 01, 789000000);
            var other    = (object)null;

            dateTime.Equals(other).Should().BeFalse();
        }
        public void ShouldNotBeEqualToAnotherType()
        {
            var dateTime = new LocalDateTime(1947, 12, 17, 15, 12, 01, 789000000);
            var other    = "some string";

            dateTime.Equals(other).Should().BeFalse();
        }
        public void ShouldNotBeEqual()
        {
            var dateTime1 = new LocalDateTime(1947, 12, 17, 15, 12, 01, 789000000);
            var dateTime2 = new LocalDateTime(new DateTime(1947, 12, 17, 15, 12, 01, 788));

            dateTime1.Equals(dateTime2).Should().BeFalse();
        }
        public void ShouldBeEqual()
        {
            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.Equals(dateTime2).Should().BeTrue();
        }
Ejemplo n.º 6
0
 //-----------------------------------------------------------------------
 /// <summary>
 /// Checks if this object equals another.
 /// <para>
 /// The entire state of the object is compared.
 ///
 /// </para>
 /// </summary>
 /// <param name="other">  the other object to compare to, null returns false </param>
 /// <returns> true if equal </returns>
 public override bool Equals(Object other)
 {
     if (other == this)
     {
         return(true);
     }
     if (other is ZoneOffsetTransition)
     {
         ZoneOffsetTransition d = (ZoneOffsetTransition)other;
         return(Transition.Equals(d.Transition) && OffsetBefore_Renamed.Equals(d.OffsetBefore_Renamed) && OffsetAfter_Renamed.Equals(d.OffsetAfter_Renamed));
     }
     return(false);
 }