public void Should_correctly_enumerate_german_federal_public_holidays_required_by_law(int year) { //expected DateOnly[] expected = { Holidays.NewYear(year), Holidays.GoodFriday(year), Holidays.EasterSunday(year), Holidays.EasterMonday(year), Holidays.LabourDay(year), Holidays.AscensionOfJayZ(year), Holidays.WhitMonday(year), Holidays.GermanReunificationDay(year), Holidays.JayZ1(year), Holidays.JayZ2(year) }; //actual var actual = Holidays.GermanPublicHolidays(year, GermanState.Bund); //compare var isOkay = expected.Except(actual).None() && actual.Except(expected).None(); Assert.True(isOkay); }
internal static bool isHoliday(this DateOnly thisDate, NonWorkingDays?nonWorkingDays = null) { HashSet <DateOnly> holidays = new(); NonWorkingDays considerAsHoliday = nonWorkingDays ?? new(); if (considerAsHoliday.EuropeanTARGET) { holidays.UnionWith(Holidays.TargetBankHolidays(thisDate.Year)); } var selectedState = considerAsHoliday.GermanPublicHolidays; if (selectedState != GermanState.NONE) { holidays.UnionWith(Holidays.GermanPublicHolidays(thisDate.Year, selectedState)); } if (considerAsHoliday.CustomNonWorkingsDays.Any()) { holidays.UnionWith(considerAsHoliday.CustomNonWorkingsDays); } return(holidays.Contains(thisDate)); }