Esempio n. 1
0
        public void TestCalendarAdjust()
        {
            var d1 = new Date(2014, 01, 30);
            var d2 = new Date(2014, 01, 31);
            var d3 = new Date(2014, 02, 06);
            var d4 = new Date(2014, 02, 12);

            Assert.AreEqual(new Date(2014, 02, 07), _cal.Adjust(d2, BusinessDayConvention.Following));
            Assert.AreEqual(new Date(2014, 01, 30), _cal.Adjust(d2, BusinessDayConvention.ModifiedFollowing));
            Assert.AreEqual(new Date(2014, 01, 30), _cal.Adjust(d3, BusinessDayConvention.Previous));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.Adjust(d3, BusinessDayConvention.ModifiedPrevious));

            Assert.AreEqual(new Date(2014, 01, 31), _cal.AddDays(d1, 1));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddBizDays(d1, 1));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddDays(d1, 1, BusinessDayConvention.Following));
            Assert.AreEqual(new Date(2014, 01, 30), _cal.AddDays(d1, 1, BusinessDayConvention.ModifiedFollowing));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddBizDays(d1, 1, BusinessDayConvention.Previous));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddBizDays(d1, 1, BusinessDayConvention.ModifiedFollowing));

            Assert.AreEqual(new Date(2014, 02, 01), _cal.AddDays(d2, 1));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddBizDays(d2, 1));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddDays(d2, 1, BusinessDayConvention.Following));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddDays(d2, 1, BusinessDayConvention.ModifiedFollowing));
            Assert.AreEqual(new Date(2014, 02, 10), _cal.AddBizDays(d2, 1, BusinessDayConvention.Following));
            Assert.AreEqual(new Date(2014, 02, 07), _cal.AddBizDays(d2, 1, BusinessDayConvention.Previous));

            Assert.AreEqual(false, _cal.BizDaysBetweenDates(d2, d3).Any());
            Assert.AreEqual(4, _cal.BizDaysBetweenDates(d1, d4).Count);
        }