示例#1
0
        public void FathersDay()
        {
            var fathersday2018 = new Holidays.Generator().ForAustria(2018).Where(h => h.Name.Equals("Vatertag")).First().Date;
            var fathersday2019 = new Holidays.Generator().ForAustria(2019).Where(h => h.Name.Equals("Vatertag")).First().Date;
            var fathersday2020 = new Holidays.Generator().ForAustria(2020).Where(h => h.Name.Equals("Vatertag")).First().Date;
            var fathersday2021 = new Holidays.Generator().ForAustria(2021).Where(h => h.Name.Equals("Vatertag")).First().Date;

            Assert.Equal(fathersday2018, new DateTime(2018, 6, 10));
            Assert.Equal(fathersday2019, new DateTime(2019, 6, 9));
            Assert.Equal(fathersday2020, new DateTime(2020, 6, 14));
            Assert.Equal(fathersday2021, new DateTime(2021, 6, 13));
        }
示例#2
0
        public void MothersDay()
        {
            var mothersday2018 = new Holidays.Generator().ForAustria(2018).Where(h => h.Name.Equals("Muttertag")).First().Date;
            var mothersday2019 = new Holidays.Generator().ForAustria(2019).Where(h => h.Name.Equals("Muttertag")).First().Date;
            var mothersday2020 = new Holidays.Generator().ForAustria(2020).Where(h => h.Name.Equals("Muttertag")).First().Date;
            var mothersday2021 = new Holidays.Generator().ForAustria(2021).Where(h => h.Name.Equals("Muttertag")).First().Date;

            Assert.Equal(mothersday2018, new DateTime(2018, 5, 13));
            Assert.Equal(mothersday2019, new DateTime(2019, 5, 12));
            Assert.Equal(mothersday2020, new DateTime(2020, 5, 10));
            Assert.Equal(mothersday2021, new DateTime(2021, 5, 9));
        }
        /// <summary>
        /// Generates Austrian holidays for a given year.
        /// </summary>
        /// <param name="generator">The generated that gets extended.</param>
        /// <param name="year">The year for which the holidays should be generated.</param>
        /// <returns>An <code>IEnumerable</code> of the generated holidays.</returns>
        public static IEnumerable <Holiday> ForAustria(this Holidays.Generator generator, int year)
        {
            var holiday = generator.Create(year);

            yield return(holiday.WithDate("Neujahr", month: 1, day: 1));

            yield return(holiday.WithDate("Heilige Drei Könige", month: 1, day: 6));

            yield return(holiday.WithDate("Valentinstag", month: 2, day: 14, workingDay: true));

            yield return(holiday.BeforeEaster("Karfreitag", days: 2, workingDay: true));

            yield return(holiday.AfterEaster("Ostersonntag", days: 0));

            yield return(holiday.AfterEaster("Ostermontag", days: 1));

            yield return(holiday.WithDate("Staatsfeiertag", month: 5, day: 1));

            yield return(holiday.NthDayInMonth("Muttertag", 2, DayOfWeek.Sunday, 5, workingDay: true));

            yield return(holiday.AfterEaster("Christi Himmelfahrt", days: 39));

            yield return(holiday.AfterEaster("Pfingstsonntag", days: 49));

            yield return(holiday.AfterEaster("Pfingstmontag", days: 50));

            yield return(holiday.AfterEaster("Fronleichnam", days: 60));

            yield return(holiday.NthDayInMonth("Vatertag", 2, DayOfWeek.Sunday, 6, workingDay: true));

            yield return(holiday.WithDate("Mariä Himmelfahrt", month: 8, day: 15));

            yield return(holiday.WithDate("Nationalfeiertag", month: 10, day: 26));

            yield return(holiday.WithDate("Halloween", month: 10, day: 31, workingDay: true));

            yield return(holiday.WithDate("Allerheiligen", month: 11, day: 1));

            yield return(holiday.WithDate("Mariä Empfängnis", month: 12, day: 8));

            yield return(holiday.WithDate("Heiligabend", month: 12, day: 24, workingDay: true));

            yield return(holiday.WithDate("Christtag", month: 12, day: 25));

            yield return(holiday.WithDate("Stefanitag", month: 12, day: 26));
        }
示例#4
0
        public void Holidays2013()
        {
            var holidays = new Holidays.Generator().ForAustria(2013);

            Assert.Equal(holidays, new List <Model.Holiday>()
            {
                new Model.Holiday {
                    Name = "Neujahr", Date = new DateTime(2013, 1, 1)
                },
                new Model.Holiday {
                    Name = "Heilige Drei Könige", Date = new DateTime(2013, 1, 6)
                },
                new Model.Holiday {
                    Name = "Valentinstag", Date = new DateTime(2013, 2, 14)
                },
                new Model.Holiday {
                    Name = "Karfreitag", Date = new DateTime(2013, 3, 29)
                },
                new Model.Holiday {
                    Name = "Ostersonntag", Date = new DateTime(2013, 3, 31)
                },
                new Model.Holiday {
                    Name = "Ostermontag", Date = new DateTime(2013, 4, 1)
                },
                new Model.Holiday {
                    Name = "Staatsfeiertag", Date = new DateTime(2013, 5, 1)
                },
                new Model.Holiday {
                    Name = "Muttertag", Date = new DateTime(2013, 5, 12)
                },
                new Model.Holiday {
                    Name = "Christi Himmelfahrt", Date = new DateTime(2013, 5, 9)
                },
                new Model.Holiday {
                    Name = "Pfingstsonntag", Date = new DateTime(2013, 5, 19)
                },
                new Model.Holiday {
                    Name = "Pfingstmontag", Date = new DateTime(2013, 5, 20)
                },
                new Model.Holiday {
                    Name = "Fronleichnam", Date = new DateTime(2013, 5, 30)
                },
                new Model.Holiday {
                    Name = "Vatertag", Date = new DateTime(2013, 6, 9)
                },
                new Model.Holiday {
                    Name = "Mariä Himmelfahrt", Date = new DateTime(2013, 8, 15)
                },
                new Model.Holiday {
                    Name = "Nationalfeiertag", Date = new DateTime(2013, 10, 26)
                },
                new Model.Holiday {
                    Name = "Halloween", Date = new DateTime(2013, 10, 31)
                },
                new Model.Holiday {
                    Name = "Allerheiligen", Date = new DateTime(2013, 11, 1)
                },
                new Model.Holiday {
                    Name = "Mariä Empfängnis", Date = new DateTime(2013, 12, 8)
                },
                new Model.Holiday {
                    Name = "Heiligabend", Date = new DateTime(2013, 12, 24)
                },
                new Model.Holiday {
                    Name = "Christtag", Date = new DateTime(2013, 12, 25)
                },
                new Model.Holiday {
                    Name = "Stefanitag", Date = new DateTime(2013, 12, 26)
                },
            });
        }