//-------------------------------------------------------------------------
        public virtual void test_combinedWith()
        {
            HolidayCalendar base1 = new MockHolCal();
            HolidayCalendar base2 = HolidayCalendars.FRI_SAT;
            HolidayCalendar test  = base1.combinedWith(base2);

            assertEquals(test.ToString(), "HolidayCalendar[Fri/Sat+Mock]");
            assertEquals(test.Name, "Fri/Sat+Mock");
            assertEquals(test.Equals(base1.combinedWith(base2)), true);
            assertEquals(test.Equals(ANOTHER_TYPE), false);
            assertEquals(test.Equals(null), false);
            assertEquals(test.GetHashCode(), base1.combinedWith(base2).GetHashCode());

            assertEquals(test.isHoliday(THU_2014_07_10), false);
            assertEquals(test.isHoliday(FRI_2014_07_11), true);
            assertEquals(test.isHoliday(SAT_2014_07_12), true);
            assertEquals(test.isHoliday(SUN_2014_07_13), true);
            assertEquals(test.isHoliday(MON_2014_07_14), false);
            assertEquals(test.isHoliday(TUE_2014_07_15), false);
            assertEquals(test.isHoliday(WED_2014_07_16), true);
            assertEquals(test.isHoliday(THU_2014_07_17), false);
            assertEquals(test.isHoliday(FRI_2014_07_18), true);
            assertEquals(test.isHoliday(SAT_2014_07_19), true);
            assertEquals(test.isHoliday(SUN_2014_07_20), true);
            assertEquals(test.isHoliday(MON_2014_07_21), false);
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_combined()
        {
            HolidayCalendar test = HolidayCalendars.of("Thu/Fri+Fri/Sat");

            assertEquals(test.Name, "Fri/Sat+Thu/Fri");
            assertEquals(test.ToString(), "HolidayCalendar[Fri/Sat+Thu/Fri]");

            HolidayCalendar test2 = HolidayCalendars.of("Thu/Fri+Fri/Sat");

            assertEquals(test, test2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_NO_HOLIDAYS()
        {
            HolidayCalendar test = HolidayCalendars.NO_HOLIDAYS;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                assertEquals(test.isBusinessDay(date), true);
                assertEquals(test.isHoliday(date), false);
            });
            assertEquals(test.Name, "NoHolidays");
            assertEquals(test.ToString(), "HolidayCalendar[NoHolidays]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_THU_FRI()
        {
            HolidayCalendar test = HolidayCalendars.THU_FRI;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != THURSDAY && date.DayOfWeek != FRIDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Thu/Fri");
            assertEquals(test.ToString(), "HolidayCalendar[Thu/Fri]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_FRI_SAT()
        {
            HolidayCalendar test = HolidayCalendars.FRI_SAT;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != FRIDAY && date.DayOfWeek != SATURDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Fri/Sat");
            assertEquals(test.ToString(), "HolidayCalendar[Fri/Sat]");
        }
        //-------------------------------------------------------------------------
        public virtual void test_SAT_SUN()
        {
            HolidayCalendar test = HolidayCalendars.SAT_SUN;

            LocalDateUtils.stream(LocalDate.of(2011, 1, 1), LocalDate.of(2015, 1, 31)).forEach(date =>
            {
                bool isBusinessDay = date.DayOfWeek != SATURDAY && date.DayOfWeek != SUNDAY;
                assertEquals(test.isBusinessDay(date), isBusinessDay);
                assertEquals(test.isHoliday(date), !isBusinessDay);
            });
            assertEquals(test.Name, "Sat/Sun");
            assertEquals(test.ToString(), "HolidayCalendar[Sat/Sun]");
        }
Beispiel #7
0
        public virtual void test_valid2()
        {
            ImmutableMap <string, HolidayCalendar> lookup = HolidayCalendarIniLookup.loadFromIni("HolidayCalendarDataValid2.ini");

            assertEquals(lookup.size(), 1);

            HolidayCalendar test = lookup.get("TEST-VALID");

            assertTrue(test.isHoliday(date(2015, 1, 1)));
            assertTrue(test.isHoliday(date(2015, 1, 6)));
            assertTrue(test.isHoliday(date(2015, 4, 5)));
            assertTrue(test.isHoliday(date(2015, 12, 25)));
            assertTrue(test.isHoliday(date(2016, 1, 1)));
            assertEquals(test.Name, "TEST-VALID");
            assertEquals(test.ToString(), "HolidayCalendar[TEST-VALID]");
        }