public void LongWeekend6() { var publicHolidays = new PublicHoliday[] { new PublicHoliday(2020, 01, 11, "Holiday Sunday", "Holiday Sunday", CountryCode.AT), }; ILongWeekendCalculator longWeekendCalculator = new LongWeekendCalculator(WeekendProvider.Universal); var longWeekends = longWeekendCalculator.Calculate(publicHolidays); Assert.AreEqual(0, longWeekends.Count()); }
public void Calculate_OneHolidayIsNotPublic_Successful() { var publicHolidays = new PublicHoliday[] { new PublicHoliday(2021, 05, 13, "Day1", "Day1", CountryCode.AT), new PublicHoliday(2021, 05, 14, "Day2", "Day2", CountryCode.AT, null, null, PublicHolidayType.Bank | PublicHolidayType.School | PublicHolidayType.Optional), }; ILongWeekendCalculator longWeekendCalculator = new LongWeekendCalculator(WeekendProvider.Universal); var longWeekends = longWeekendCalculator.Calculate(publicHolidays).ToArray(); Assert.AreEqual(4, longWeekends[0].DayCount); Assert.IsTrue(longWeekends[0].Bridge); }
public void LongWeekend4() { var publicHolidays = new PublicHoliday[] { new PublicHoliday(2020, 01, 10, "Holiday Friday", "Holiday Friday", CountryCode.AT), new PublicHoliday(2020, 01, 14, "Holiday Tuesday", "Holiday Tuesday", CountryCode.AT), }; ILongWeekendCalculator longWeekendCalculator = new LongWeekendCalculator(WeekendProvider.Universal); var longWeekends = longWeekendCalculator.Calculate(publicHolidays); Assert.AreEqual(1, longWeekends.Count()); var firstLongWeekend = longWeekends.First(); Assert.AreEqual(5, firstLongWeekend.DayCount); Assert.IsTrue(firstLongWeekend.Bridge); }
public void Calculate_FromFridayToMonday_Successful() { var publicHolidays = new PublicHoliday[] { new PublicHoliday(2020, 01, 10, "Holiday Friday", "Holiday Friday", CountryCode.AT), new PublicHoliday(2020, 01, 13, "Holiday Monday", "Holiday Monday", CountryCode.AT), }; ILongWeekendCalculator longWeekendCalculator = new LongWeekendCalculator(WeekendProvider.Universal); var longWeekends = longWeekendCalculator.Calculate(publicHolidays); Assert.AreEqual(1, longWeekends.Count()); var firstLongWeekend = longWeekends.First(); Assert.AreEqual(4, firstLongWeekend.DayCount); Assert.IsFalse(firstLongWeekend.Bridge); }
public void Calculate_TwoLongWeekendsWithBridgeDay_Successful() { var publicHolidays = new PublicHoliday[] { new PublicHoliday(2020, 01, 9, "Holiday Thursday", "Holiday Thursday", CountryCode.AT), new PublicHoliday(2020, 01, 14, "Holiday Tuesday", "Holiday Tuesday", CountryCode.AT), }; ILongWeekendCalculator longWeekendCalculator = new LongWeekendCalculator(WeekendProvider.Universal); var longWeekends = longWeekendCalculator.Calculate(publicHolidays); Assert.AreEqual(2, longWeekends.Count()); var firstLongWeekend = longWeekends.First(); Assert.AreEqual(4, firstLongWeekend.DayCount); Assert.IsTrue(firstLongWeekend.Bridge); var lastLongWeekend = longWeekends.Last(); Assert.AreEqual(4, lastLongWeekend.DayCount); Assert.IsTrue(lastLongWeekend.Bridge); }
/// <summary> /// Get long weekends of a country and a given year /// </summary> /// <param name="year">The year</param> /// <param name="countryCode">Country Code (ISO 3166-1 ALPHA-2)</param> /// <returns></returns> public static IEnumerable <LongWeekend> GetLongWeekend(int year, CountryCode countryCode) { var calculator = new LongWeekendCalculator(GetWeekendProvider(countryCode)); return(calculator.Calculate(GetPublicHoliday(year, countryCode))); }