示例#1
0
        public void EventsOnDateYearlyForward()
        {
            var offKey = new List <string> {
                "rev1"
            };
            var workKey = new List <string> {
                "rev2"
            };
            var bothOffWork = new List <string>();

            bothOffWork.AddRange(offKey);
            bothOffWork.AddRange(workKey);
            CalendarDateTime.ClearCalendar();
            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(offKey[0], true, 5, 2, DayOfWeek.Monday);
            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(workKey[0], false, 5, 2, DayOfWeek.Monday);

            var testDate = new DateTime(2018, 5, 14);
            var dayOff   = testDate.EventsOnDate(false, true).ToList();
            var workday  = testDate.EventsOnDate(true, false).ToList();
            var both     = testDate.EventsOnDate(true, true).ToList();
            var neither  = testDate.EventsOnDate(false, false).ToList();

            Assert.NotStrictEqual(dayOff, offKey);
            Assert.NotStrictEqual(workday, workKey);
            Assert.Empty(neither);
            Assert.NotStrictEqual(bothOffWork, both);
            Assert.Empty(DateTime.Now.AddDays(1).EventsOnDate(true, true));
        }
示例#2
0
        public void AddYearlyDayOfWeekReverseEventDuplicate()
        {
            const string dup = "dup";

            CalendarDateTime.ClearCalendar();
            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(dup, true, 10, 1, DayOfWeek.Friday);
            Assert.Throws <ArgumentException>(() => CalendarDateTime.AddYearlyDayOfWeekForwardEvent(dup, true, 11, 1, DayOfWeek.Friday));
        }
示例#3
0
 public void AddYearlyDayOfWeekReverseEventEventWeekCount0()
 {
     CalendarDateTime.ClearCalendar();
     CalendarDateTime.AddYearlyDayOfWeekForwardEvent("Jane", true, 10, 1, DayOfWeek.Friday);
     Assert.Throws <ArgumentOutOfRangeException>(() => CalendarDateTime.AddYearlyDayOfWeekForwardEvent("Tarzan", true, 11, 0, DayOfWeek.Friday));
 }
示例#4
0
 public void AddYearlyDayOfWeekReverseEventEventNameNull()
 {
     Assert.Throws <ArgumentNullException>(() => CalendarDateTime.AddYearlyDayOfWeekForwardEvent(null, true, 1, 1, DayOfWeek.Friday));
 }
示例#5
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Father's Day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.FathersDay(false);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void FathersDay(bool dayOff)
        {
            var start = new DateTime(1910, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.FathersDayText, dayOff, 6, 3, DayOfWeek.Sunday, start);
        }
示例#6
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Columbus Day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.ColumbusDay(false);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void ColumbusDay(bool dayOff)
        {
            var start = new DateTime(1492, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.ColumbusDayText, dayOff, 10, 2, DayOfWeek.Monday, start);
        }
示例#7
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Thanksgiving Day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.ThanksgivingDay(false);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void ThanksgivingDay(bool dayOff)
        {
            var start = new DateTime(1619, 1, 1);               // No exact year, 1621, 1619 comes up.

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.ThanksgivingDayText, dayOff, 11, 4, DayOfWeek.Thursday, start);
        }
示例#8
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Presidents day (Washington's day). </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.PresidensDay(false);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void PresidentsDay(bool dayOff)
        {
            var start = new DateTime(1971, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.PresidentsDayText, dayOff, 2, 3, DayOfWeek.Monday, start);
        }
示例#9
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Martin Luther King day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.MartinLutherKingDay(true);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void MartinLutherKingDay(bool dayOff)
        {
            var start = new DateTime(1986, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.MartinLutherKingText, dayOff, 1, 3, DayOfWeek.Monday, start);
        }
示例#10
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Labor Day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.LaborDay(true);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void LaborDay(bool dayOff)
        {
            var start = new DateTime(1894, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekForwardEvent(HolidayNames.LaborDayText, dayOff, 9, 1, DayOfWeek.Monday, start);
        }