public void holiday_days_span()
        {
            var dateTimeCulture = new WorkingDayCultureInfo("ko-KR");
            var holiday = KO_KRHolidayStrategy.Seolnal;
            var startDay = holiday.GetInstance(2015);

            //Seol 2015
            DateTime day = new DateTime(2015, 2, 18);
            do
            {
                Assert.IsFalse(dateTimeCulture.IsWorkingDay(day), day.ToString() + " shouldn't be a working day");
                day = day.AddDays(1);
            } while (day <= new DateTime(2015, 2, 20));

            //Seol 2016 (with substitute holiday)
            day = new DateTime(2016, 2, 7);
            do
            {
                Assert.IsFalse(dateTimeCulture.IsWorkingDay(day), day.ToString() + " shouldn't be a working day");
                day = day.AddDays(1);
            } while (day <= new DateTime(2015, 2, 10));

            //Chuseok 2015 (with substitute holiday)
            day = new DateTime(2015, 9, 26);
            do
            {
                Assert.IsFalse(dateTimeCulture.IsWorkingDay(day), day.ToString() + " shouldn't be a working day");
                day = day.AddDays(1);
            } while (day <= new DateTime(2015, 9, 29));
        }
 public void CanGetChineseHolidaysListIn2016()
 {
     var cultureInfo = new WorkingDayCultureInfo("zh-CN");
     Assert.IsNotNull(cultureInfo);
     var holidays = cultureInfo.GetHolidaysOfYear(2016);
     Assert.AreEqual(7, holidays.Count());
 }
Exemplo n.º 3
0
 public void assert_holidays_on_weekend_observed_on_monday()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("fr-CA");
     // 01-07-2012 Canada Day on a Sunday
     var mondayAfterCanadaDay = new DateTime(2012, 07, 02);
     Assert.AreEqual(DayOfWeek.Monday, mondayAfterCanadaDay.DayOfWeek);
     Assert.IsFalse(mondayAfterCanadaDay.IsWorkingDay(dateTimeCulture));
 }
 public void can_get_strateryies()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("ko-KR");
     var holidaysStrategy = dateTimeCulture.LocateHolidayStrategy(dateTimeCulture.Name);
     Assert.AreEqual(typeof(KO_KRHolidayStrategy), holidaysStrategy.GetType());
     var workingDaysStrategy = dateTimeCulture.LocateWorkingDayOfWeekStrategy(dateTimeCulture.Name);
     Assert.AreEqual(typeof(DefaultWorkingDayOfWeekStrategy), workingDaysStrategy.GetType());
 }
 public void Export(WorkingDayCultureInfo dateTimeCultureInfo, int year, TextWriter writer)
 {
     var holidays = dateTimeCultureInfo.GetHolidaysOfYear(year);
     writer.WriteLine(HeaderLineFomat, dateTimeCultureInfo.Name, holidays.Count());
     foreach (var holiday in holidays) {
         var instance = holiday.GetInstance(year);
         if (instance.HasValue) {
             writer.WriteLine(HolidayLineFormat, holiday.Name, instance);
         }
     }
 }
Exemplo n.º 6
0
        public void check_working_day()
        {
            var ptWorkingDayCultureInfo = new WorkingDayCultureInfo("pt-PT");
            var carnationRevolution = new DateTime(2011, 4, 25);
            var nextDay = carnationRevolution.AddDays(1);

            Assert.IsTrue(carnationRevolution.IsWorkingDay(ptWorkingDayCultureInfo) == false);
            Assert.IsTrue(carnationRevolution.DayOfWeek == DayOfWeek.Monday);

            Assert.IsTrue(nextDay.IsWorkingDay(ptWorkingDayCultureInfo));
            Assert.IsTrue(nextDay.DayOfWeek == DayOfWeek.Tuesday);
        }
        public void Christmas()
        {
            var workingDayCultureInfo = new WorkingDayCultureInfo("en-NZ");

            var dateOnGregorian = new DateTime(2013, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2014, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2015, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2016, 12, 26); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2017, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2018, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2019, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2020, 12, 25); TestHoliday(workingDayCultureInfo, dateOnGregorian);
        }
        public void NewYearsDay()
        {
            var workingDayCultureInfo = new WorkingDayCultureInfo("en-NZ");

            var dateOnGregorian = new DateTime(2013, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2014, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2015, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2016, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2017, 1, 3); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2018, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2019, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
            dateOnGregorian = new DateTime(2020, 1, 1); TestHoliday(workingDayCultureInfo, dateOnGregorian);
        }
Exemplo n.º 9
0
        public void get_year_prior_2013_holidays_in_portugal()
        {
            var portugalWorkingDayCultureInfo = new WorkingDayCultureInfo("pt-PT");
            var today = new DateTime(2010, 2, 1);
            var holidays = today.AllYearHolidays(portugalWorkingDayCultureInfo);

            Assert.IsTrue(holidays.Count == 13, "expecting 13 holidays but got {0}", holidays.Count);

            foreach (DateTime holidayDate in holidays.Keys)
            {
                var holiday = holidays[holidayDate];
                Assert.IsTrue(holidayDate.IsWorkingDay(portugalWorkingDayCultureInfo) == false,
                    "holiday {0} shouln't be working day in Portugal", holiday.Name);
            }
        }
Exemplo n.º 10
0
        public void get_us_holidays_in_2015_passes()
        {
            var usWorkingDayCultureInfo = new WorkingDayCultureInfo("en-US");
            var today = new DateTime(2015, 1, 1);
            var holidays = today.AllYearHolidays(usWorkingDayCultureInfo);

            Assert.IsTrue(holidays.Count == 10, "expecting 10 holidays but got {0}", holidays.Count);

            foreach (DateTime holidayDate in holidays.Keys)
            {
                var holiday = holidays[holidayDate];
                Assert.IsTrue(holidayDate.IsWorkingDay(usWorkingDayCultureInfo) == false,
                    "holiday {0} shouln't be working day in US", holiday.Name);
            }
        }
Exemplo n.º 11
0
 public void CanWorkOn2016()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("fr-CA");
     var holidays = dateTimeCulture.GetHolidaysOfYear(2016);
     Assert.IsTrue(holidays.Any());
 }
Exemplo n.º 12
0
 public void assert_holidays_count()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("fr-CA");
     var holidays = dateTimeCulture.Holidays;
     Assert.AreEqual(8, holidays.Count());
 }
Exemplo n.º 13
0
 public void Init()
 {
     dateTimeCulture = new WorkingDayCultureInfo("vi-VN");
 }
Exemplo n.º 14
0
 public void can_get_stratery()
 {
     var dateTimeCulture = new WorkingDayCultureInfo("fr-CA");
     var strategy = dateTimeCulture.LocateHolidayStrategy(dateTimeCulture.Name);
     Assert.AreEqual(typeof (FR_CAHolidayStrategy), strategy.GetType());
 }
Exemplo n.º 15
0
        public void holidays()
        {
            var ptWorkingDayCultureInfo = new WorkingDayCultureInfo("pt-PT");
            var enWorkingDayCultureInfo = new WorkingDayCultureInfo("default");

            var thursday = new DateTime(2011, 4, 21); // A thursday
            var thursday_plus_two_working_days_pt = thursday.AddWorkingDays(2, ptWorkingDayCultureInfo);
            // friday + 2 working days on PT
            var thursday_plus_two_working_days_en = thursday.AddWorkingDays(2, enWorkingDayCultureInfo);
            // friday + 2 working days on Default

            //Default doesn't have supported holidays
            Assert.IsTrue(thursday_plus_two_working_days_en == thursday.AddDays(4));
            Assert.IsTrue(thursday_plus_two_working_days_en.DayOfWeek == DayOfWeek.Monday);

            //Portuguese Holidays are supported
            Assert.IsTrue(thursday_plus_two_working_days_pt == thursday.AddDays(6));
            // + Good Friday (22-4-2011) + Carnation Revolution (25-4-2011)
            Assert.IsTrue(thursday_plus_two_working_days_pt.DayOfWeek == DayOfWeek.Wednesday);
        }
Exemplo n.º 16
0
        public void provide_custom_strategies()
        {
            var customWorkingDayCultureInfo = new WorkingDayCultureInfo("CustomTest");

            Assert.IsTrue(DateTime.Today.IsWorkingDay(customWorkingDayCultureInfo) == false);
            Assert.IsTrue(DateTime.Today.AddDays(1).IsWorkingDay(customWorkingDayCultureInfo) == true);
        }
Exemplo n.º 17
0
        public void recomended_calculation()
        {
            var workingDayCultureInfo = new WorkingDayCultureInfo("pt-PT");
            var friday = new DateTime(2011, 5, 13); // A friday
            var friday_plus_two_working_days = friday.AddWorkingDays(2, workingDayCultureInfo);
            // friday + 2 working days

            Assert.IsTrue(friday_plus_two_working_days == friday.AddDays(4));
            Assert.IsTrue(friday_plus_two_working_days.DayOfWeek == DayOfWeek.Tuesday);
        }