Esempio n. 1
0
        public void TestCountMonths()
        {
            var dt1 = new DateTime(DateTime.Today.Year, 1, 14);
            var dt2 = new DateTime(DateTime.Today.Year - 1, 12, 18);

            var testResult = Rent.CountOfWholeCalendarMonthsBetween(dt1, dt2);

            Assert.AreEqual(0, testResult);
            testResult = Rent.CountOfWholeCalendarMonthsBetween(dt2, dt1);
            Assert.AreEqual(0, testResult);

            dt2        = new DateTime(DateTime.Today.Year - 1, 11, 5);
            testResult = Rent.CountOfWholeCalendarMonthsBetween(dt1, dt2);
            Assert.AreEqual(1, testResult);

            dt2        = new DateTime(DateTime.Today.Year, 1, 1);
            testResult = Rent.CountOfWholeCalendarMonthsBetween(dt1, dt2);
            Assert.AreEqual(0, testResult);

            dt1        = new DateTime(DateTime.Today.Year, 1, 1);
            dt2        = new DateTime(DateTime.Today.Year + 1, 1, 1);
            testResult = Rent.CountOfWholeCalendarMonthsBetween(dt1, dt2);
            Assert.AreEqual(12, testResult);

            dt1        = new DateTime(DateTime.Today.Year, 5, 5);
            dt2        = new DateTime(DateTime.Today.Year, 11, 1);
            testResult = Rent.CountOfWholeCalendarMonthsBetween(dt1, dt2);
            Assert.AreEqual(5, testResult);
        }