Ejemplo n.º 1
0
 public void DoesNotThrowWhenConstructedWithFirstDayOf1970AndOffset()
 {
     Assert.DoesNotThrow(() =>
     {
         var date = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(1970, 01, 01, 0, 0, 0, TimeSpan.Zero));
     });
 }
Ejemplo n.º 2
0
 public void DoesNotThrowWhenConstructedWithDateTimeOffsetOnEpoch()
 {
     Assert.DoesNotThrow(() =>
     {
         var date = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2038, 1, 19, 3, 14, 7, 0, TimeSpan.Zero));
     });
 }
Ejemplo n.º 3
0
 public void ThrowsWhenConstructedWithDateTimeOffsetBefore1970()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var date = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(1969, 12, 31, 23, 59, 59, TimeSpan.Zero));
     });
 }
Ejemplo n.º 4
0
 public void ThrowsWhenConstructedWithComponentsOneSecondLaterThanEpoch()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var date = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2038, 1, 19, 3, 14, 8, TimeSpan.Zero));
     });
 }
Ejemplo n.º 5
0
        public void GreaterThanOperator()
        {
            var a = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 8, 0, 0, TimeSpan.Zero));
            var b = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 9, 0, 0, TimeSpan.Zero));

            Assert.IsTrue(b > a);
        }
Ejemplo n.º 6
0
 public void ThrowsWhenConstructedWithDateTimeOffsetAfterEpoch()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var date = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2038, 2, 1, 0, 0, 0, TimeSpan.Zero));
     });
 }
Ejemplo n.º 7
0
        public void CompareIgnoresOffsetWhenOneDoNotHaveOffset()
        {
            var a = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 8, 0, 0, 0, TimeSpan.FromHours(-10)));
            var b = new DATETIMETYPE(new DateTime(2019, 1, 1, 8, 0, 0, 0, DateTimeKind.Unspecified));

            Assert.AreEqual(0, a.CompareTo(b));
        }
Ejemplo n.º 8
0
 private static DATETIMETYPE[] ToDateTimeIsUnspecifiedForNonZeroAndEmptyOffsetsInputs()
 {
     return(new[]
     {
         DATETIMETYPE.Parse("2019-02-06T17:24:00"),
         DATETIMETYPE.Parse("2019-02-07T17:24:00-08:00"),
         new DATETIMETYPE(new DateTime(2019, 1, 1, 8, 0, 0, 0, DateTimeKind.Unspecified)),
         DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 2, 9, 17, 24, 0, TimeSpan.FromHours(-8)))
     });
 }
Ejemplo n.º 9
0
 private static DATETIMETYPE[] ToDateTimeIsUtcForZeroOffsetsInput()
 {
     return(new[]
     {
         DATETIMETYPE.Parse("2019-02-06T17:24:00Z"),
         DATETIMETYPE.Parse("2019-02-06T17:24:00+00:00"),
         new DATETIMETYPE(new DateTime(2019, 1, 1, 8, 0, 0, 0, DateTimeKind.Utc)),
         DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 2, 6, 17, 24, 0, TimeSpan.Zero)),
     });
 }
Ejemplo n.º 10
0
        public void EqualsOperatorSameTimeOneMissingOffset()
        {
            // While these will compare the same, they should not be considered equal

            var a = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 8, 0, 0, 0, TimeSpan.Zero));
            var b = new DATETIMETYPE(new DateTime(2019, 1, 1, 8, 0, 0, 0, DateTimeKind.Unspecified));

            Assert.AreEqual(0, a.CompareTo(b));
            Assert.IsFalse(a == b);
        }
Ejemplo n.º 11
0
        public void EqualsOperatorSameInstantDifferentOffsets()
        {
            // Even though these are two different offsets, they represent the same moment in time and both have offsets supplied, so should be equal

            var a = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 12, 0, 0, TimeSpan.FromHours(-1)));
            var b = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)));

            Assert.AreEqual(0, a.CompareTo(b));
            Assert.IsTrue(a == b);
        }
Ejemplo n.º 12
0
        public void CompareAccountsForOffset()
        {
            // A's instant (moment in time globally) is later, but its DateTime is earlier
            var a = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 6, 0, 0, 0, TimeSpan.FromHours(-3)));

            // B's instant is earlier, but its DateTime is later
            var b = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 1, 1, 8, 0, 0, 0, TimeSpan.Zero));

            Assert.AreEqual(1, a.CompareTo(b));
        }
Ejemplo n.º 13
0
        public void UsesOffsetAsSuppliedWhenConstructedFromDateTimeOffset()
        {
            var dt = DATETIMETYPE.FromUncorrectedDate(new DateTimeOffset(2019, 2, 6, 17, 24, 0, TimeSpan.FromHours(-8)));

            Assert.AreEqual("2019-02-06T17:24:00-08:00", dt.ToString(true));
        }