public void CompareYearToMonthToNull()
        {
            var value1 = new SqlYearToMonth(22);
            var value2 = SqlYearToMonth.Null;

            var result = value1.CompareTo(value2);

            Assert.AreEqual(1, result);
        }
        public void YearToMonthFromInteger(int months, int expectedYears)
        {
            var value = new SqlYearToMonth(months);

            Assert.IsNotNull(value);
            Assert.IsFalse(value.IsNull);

            Assert.AreEqual(expectedYears, (int)value.TotalYears);
        }
        public SqlDateTime Subtract(SqlYearToMonth interval)
        {
            if (IsNull)
            {
                return(Null);
            }
            if (interval.IsNull)
            {
                return(this);
            }

            var result = value.Value.AddMonths(-interval.TotalMonths);

            return(new SqlDateTime(result.Ticks));
        }
Beispiel #4
0
        public void Subtract_MonthSpan()
        {
            var value = new SqlDateTime(2001, 11, 03, 10, 22, 03, 0);
            var ms    = new SqlYearToMonth(1, 3);

            var result = new SqlDateTime();

            Assert.DoesNotThrow(() => result = value.Subtract(ms));
            Assert.IsFalse(result.IsNull);
            Assert.AreEqual(2000, result.Year);
            Assert.AreEqual(08, result.Month);
            Assert.AreEqual(10, result.Hour);
            Assert.AreEqual(22, result.Minute);
            Assert.AreEqual(03, result.Second);
            Assert.AreEqual(0, result.Millisecond);
        }