Example #1
0
 public void CanConstructFromDateTime()
 {
   Date d1 = new Date(new DateTime(2001, 2, 3, 4, 5, 6, 7).AddTicks(8));
   Date d2 = new Date(2001, 2, 3);
   Assert.AreEqual(d1, d2);
   Assert.IsTrue(d1.Equals(d2));
 }
        public void Comparison()
        {
            var firstDate = new Date(2011, 1, 1);
            var sameAsFirstDate = new Date(2011, 1, 1);
            var laterDate = new Date(2011, 1, 2);

            Expect(firstDate < laterDate);
            Expect(laterDate < firstDate, Is.False);

            Expect(firstDate > laterDate, Is.False);
            Expect(laterDate > firstDate);

            Expect(firstDate <= laterDate);
            Expect(laterDate <= firstDate, Is.False);

            Expect(firstDate >= laterDate, Is.False);
            Expect(laterDate >= firstDate);

            Expect(firstDate <= sameAsFirstDate);
            Expect(firstDate >= sameAsFirstDate);
            Expect(firstDate < sameAsFirstDate, Is.False);
            Expect(firstDate > sameAsFirstDate, Is.False);

            Expect(firstDate, Is.EqualTo(sameAsFirstDate));
            Expect(firstDate.Equals(sameAsFirstDate));
        }
Example #3
0
        public void ObjectEquality()
        {
            Date d1 = new Date();
            d1.Value = System.DateTime.Now.ToUniversalTime().ToString();
            d1.Count = 42;

            Date d2 = new Date (d1.Value, d1.Count);

            Assert.IsTrue (d1 == d2, "(d1 == d2) should be true");
            Assert.IsFalse (d1 != d2, "(d1 != d2) should be false");
            Assert.IsTrue (d1.Equals (d2), "d1.Equals(d2) should be true");

            Assert.IsTrue (d1.ReferenceEquals (d1), "d1.ReferenceEquals(d1) should be true");
            Assert.IsFalse (d1.ReferenceEquals (d2), "d1.ReferenceEquals(d2) should be false");
        }
Example #4
0
        public void op_Equals_DateTime(bool expected,
                                       int day)
        {
            var obj = new Date(2012, 5, 30);
            var other = new DateTime(2012, 5, day, 12, 0, 0);

            Assert.Equal(expected, obj.Equals(other));
        }