Ejemplo n.º 1
0
        public void TestHolidays2018Lists()
        {
            var holidayCalendar = new GermanPublicHoliday();
            var hols            = holidayCalendar.PublicHolidays(2018);
            var holNames        = holidayCalendar.PublicHolidayNames(2018);

            Assert.IsTrue(9 == hols.Count, "Should be 9 holidays in 2018");
            Assert.IsTrue(holNames.Count == hols.Count, "Names and holiday list are same");
        }
Ejemplo n.º 2
0
        public void TestHolidays2017Lists()
        {
            var holidayCalendar = new GermanPublicHoliday();
            var hols            = holidayCalendar.PublicHolidays(2017);
            var holNames        = holidayCalendar.PublicHolidayNames(2017);

            Assert.IsTrue(10 == hols.Count, "Should be 10 holidays in 2017 - 500th anniversary Reformation");
            Assert.IsTrue(holNames.Count == hols.Count, "Names and holiday list are same");
        }
Ejemplo n.º 3
0
        public void TestHolidays2017(int month, int day)
        {
            var holiday = new DateTime(2017, month, day);
            //Baden-Württemberg
            var holidayCalendar = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.BW
            };
            var actual = holidayCalendar.IsPublicHoliday(holiday);

            Assert.IsTrue(actual, $"{holiday.ToString("D")} is not a holiday");
        }
Ejemplo n.º 4
0
        public void TestHolidays2017BavariaLists()
        {
            var holidayCalendar = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.BY
            };
            var hols     = holidayCalendar.PublicHolidays(2017);
            var holNames = holidayCalendar.PublicHolidayNames(2017);

            //technically, Bavaria widely observes Assumption/Mariä Himmelfahrt on August 15
            Assert.IsTrue(13 == hols.Count, "Should be 13 holidays in 2017 - 500th anniversary Reformation");
            Assert.IsTrue(holNames.Count == hols.Count, "Names and holiday list are same");
        }
Ejemplo n.º 5
0
        public static int CalculateHolidays()
        {
            var calendar = new GermanPublicHoliday
            {
                State = ((GermanPublicHoliday.States[])Enum.GetValues(typeof(GermanPublicHoliday.States)))
                        .FirstOrDefault(x => x.ToString().Equals(Settings.Default.SelectedState))
            };
            var publicHolidays = calendar.PublicHolidays(DateTime.Now.Year).ToList();

            var days = publicHolidays.Where(p =>
                                            p >= DateTime.Now.StartOfWeek(DayOfWeek.Monday) && p <= DateTime.Now.EndOfWeek(DayOfWeek.Monday))
                       .ToList();

            return(days.Count);
        }
Ejemplo n.º 6
0
        public void TestSaxonyRepetanceDay()
        {
            var actual = GermanPublicHoliday.Repentance(2017);

            Assert.AreEqual(new DateTime(2017, 11, 22), actual);

            var calendar = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.SN
            };

            Assert.IsTrue(calendar.HasRepentance);

            var calendar2 = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.HE
            };

            Assert.IsFalse(calendar2.HasRepentance);
        }
        public void TestThüringenChildrensDay()
        {
            var calendar = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.SN
            };

            Assert.IsFalse(calendar.HasWorldChildrensDay(2019));

            var calendar2 = new GermanPublicHoliday {
                State = GermanPublicHoliday.States.TH
            };

            //did not have official holiday in 2018
            Assert.IsFalse(calendar2.HasWorldChildrensDay(2018));
            Assert.IsFalse(calendar2.PublicHolidays(2018).Contains(new DateTime(2018, 9, 20)));
            //introduced official holiday in 2019
            Assert.IsTrue(calendar2.HasWorldChildrensDay(2019));
            Assert.IsTrue(calendar2.PublicHolidays(2019).Contains(new DateTime(2019, 9, 20)));
        }
        public List <CountryPublicHolidayModel> GetPublicHolidayHandlers()
        {
            var publicHolidayHandlers = new List <CountryPublicHolidayModel>()
            {
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new AustriaPublicHoliday(), CountryCode = "AT/AUT", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new BelgiumPublicHoliday(), CountryCode = "BE/BEL", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new CzechRepublicPublicHoliday(), CountryCode = "CZ/CZE", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new DutchPublicHoliday(), CountryCode = "NL/NLD", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new EcbTargetClosingDay(), CountryCode = "", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new FrancePublicHoliday(), CountryCode = "FR/FRA", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new IrelandPublicHoliday(), CountryCode = "IE/IRL", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new ItalyPublicHoliday(), CountryCode = "IT/ITA", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new JapanPublicHoliday(), CountryCode = "JP/JPN", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new KazakhstanPublicHoliday(), CountryCode = "KZ/KAZ", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new NewZealandPublicHoliday(), CountryCode = "NZ/NZL", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new NorwayPublicHoliday(), CountryCode = "NO/NOR", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new PolandPublicHoliday(), CountryCode = "PL/POL", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new SlovakiaPublicHoliday(), CountryCode = "SK/SVK", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new SpainPublicHoliday(), CountryCode = "ES/ESP", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new SwedenPublicHoliday(), CountryCode = "SE/SWE", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new UKBankHoliday(), CountryCode = "GB/GBR", State = ""
                },
                new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = new USAPublicHoliday(), CountryCode = "US/USA", State = ""
                },
            };

            // Germany
            foreach (GermanPublicHoliday.States state in (GermanPublicHoliday.States[])Enum.GetValues(typeof(GermanPublicHoliday.States)))
            {
                if (state != GermanPublicHoliday.States.ALL)
                {
                    var handler = new GermanPublicHoliday();
                    handler.State = state;

                    var model = new CountryPublicHolidayModel()
                    {
                        CountryPublicHoliday = handler, CountryCode = "DE/DEU", State = state.ToString()
                    };
                    publicHolidayHandlers.Add(model);
                }
            }

            // Australia
            foreach (AustraliaPublicHoliday.States state in (AustraliaPublicHoliday.States[])Enum.GetValues(typeof(AustraliaPublicHoliday.States)))
            {
                var handler = new AustraliaPublicHoliday();
                handler.State = state;

                var model = new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = handler, CountryCode = "AU/AUS", State = state.ToString()
                };
                publicHolidayHandlers.Add(model);
            }

            // Canada
            foreach (var province in canadaProvinces)
            {
                var handler = new CanadaPublicHoliday(province);
                var model   = new CountryPublicHolidayModel()
                {
                    CountryPublicHoliday = handler, CountryCode = "CA/CAN", State = province
                };
                publicHolidayHandlers.Add(model);
            }

            publicHolidayHandlers.Add(new CountryPublicHolidayModel()
            {
                CountryPublicHoliday = new SwitzerlandPublicHoliday(hasSecondJanuary: true, hasLaborDay: true, hasCorpusChristi: true, hasChristmasEve: true, hasNewYearsEve: true), CountryCode = "CH/CHE", State = ""
            });

            return(publicHolidayHandlers);
        }