コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: DateSystem.cs プロジェクト: samuelp101/Nager.Date
        /// <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)));
        }