示例#1
0
        public void MaxValue()
        {
            DbTime time = DbTime.MaxValue;

            Assert.AreEqual(235959999, time.Ticks);
            Assert.AreEqual(DateTimeKind.Unspecified, time.Kind);
        }
示例#2
0
        public void MinValue()
        {
            DbTime time = DbTime.MinValue;

            Assert.AreEqual(0, time.Ticks);
            Assert.AreEqual(DateTimeKind.Unspecified, time.Kind);
        }
示例#3
0
        public void ConvertibleCasts()
        {
            object self = new DbTime(15, 36, 11, DateTimeKind.Utc);

            DbTime selfCasted = (DbTime)self;

            Assert.AreEqual(self, selfCasted);

            Assert.AreEqual(self, GetDbDateByObjectT((DbTime)self));
            Assert.AreEqual(self, GetDbDateByIConvertibleT((DbTime)self));
        }
示例#4
0
        public void ExplicitCastToDbTime()
        {
            DateTime time = new DateTime(2013, 2, 20, 1, 2, 3, 99, DateTimeKind.Utc);
            // yes, we like to explicitly "loose" infos:
            DbTime target = (DbTime)time;

            Assert.AreEqual(1, target.Hour);
            Assert.AreEqual(2, target.Minute);
            Assert.AreEqual(3, target.Second);
            Assert.AreEqual(99, target.Millisecond);
            Assert.AreEqual(DateTimeKind.Utc, target.Kind);
        }
示例#5
0
        public void ImplicitCastToDateTime()
        {
            DbTime   time   = new DbTime(1, 2, 3, 99, DateTimeKind.Utc);
            DateTime target = time;

            // expected unix epoch on the unused date part of DateTime:
            Assert.AreEqual(1970, target.Year);
            Assert.AreEqual(1, target.Month);
            Assert.AreEqual(1, target.Day);

            Assert.AreEqual(1, target.Hour);
            Assert.AreEqual(2, target.Minute);
            Assert.AreEqual(3, target.Second);
            Assert.AreEqual(99, target.Millisecond);
            Assert.AreEqual(DateTimeKind.Utc, target.Kind);
        }
示例#6
0
        public void CtorAndProperties()
        {
            DbTime time = new DbTime();

            Assert.AreEqual(DbTime.MinValue, time);

            time = new DbTime(23, 59, 59, 999, DateTimeKind.Unspecified);
            Assert.AreEqual(DbTime.MaxValue, time);

            time = new DbTime(1, 2, 3, DateTimeKind.Local);
            Assert.AreEqual(1, time.Hour);
            Assert.AreEqual(2, time.Minute);
            Assert.AreEqual(3, time.Second);
            Assert.AreEqual(0, time.Millisecond);
            Assert.AreEqual(DateTimeKind.Local, time.Kind);

            time = new DbTime(4, 5, 6, 10, DateTimeKind.Utc);
            Assert.AreEqual(4, time.Hour);
            Assert.AreEqual(5, time.Minute);
            Assert.AreEqual(6, time.Second);
            Assert.AreEqual(10, time.Millisecond);
            Assert.AreEqual(DateTimeKind.Utc, time.Kind);
        }
示例#7
0
 public void CtorFailOnSecondUpperBound()
 {
     DbTime time = new DbTime(0, 0, 60, DateTimeKind.Unspecified);
 }
示例#8
0
 public void CtorFailOnMinuteUpperBound()
 {
     DbTime time = new DbTime(0, 60, 1, DateTimeKind.Unspecified);
 }
示例#9
0
 public void CtorFailOnHourUpperBound()
 {
     DbTime time = new DbTime(24, 1, 1, DateTimeKind.Unspecified);
 }
示例#10
0
 public void CtorFailOnHourLowerBoundNegative()
 {
     DbTime time = new DbTime(-1, 1, 1, DateTimeKind.Unspecified);
 }
示例#11
0
 public void CtorFailOnMilliSecondLowerBound()
 {
     DbTime time = new DbTime(0, 0, 0, -1, DateTimeKind.Unspecified);
 }