Esempio n. 1
0
        public void EventsOnDateYearlyReverse()
        {
            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.AddYearlyDayOfWeekReverseEvent(offKey[0], true, 5, 2, DayOfWeek.Monday);
            CalendarDateTime.AddYearlyDayOfWeekReverseEvent(workKey[0], false, 5, 2, DayOfWeek.Monday);

            var testDate = new DateTime(2018, 5, 21);
            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(testDate.AddDays(1).EventsOnDate(true, true));
        }
Esempio n. 2
0
        public void AddYearlyDayOfWeekReverseEventWeekDuplicate()
        {
            const string duplicate = "duplicate";

            CalendarDateTime.ClearCalendar();
            CalendarDateTime.AddYearlyDayOfWeekReverseEvent(duplicate, true, 1, 1, DayOfWeek.Monday);
            Assert.Throws <ArgumentException>(() => CalendarDateTime.AddYearlyDayOfWeekReverseEvent(duplicate, false, 1, 1, DayOfWeek.Monday));
        }
Esempio n. 3
0
 public void AddYearlyDayOfWeekReverseEventWeekCount0()
 {
     CalendarDateTime.ClearCalendar();
     CalendarDateTime.AddYearlyDayOfWeekReverseEvent("the", true, 1, 1, DayOfWeek.Monday);
     Assert.Throws <ArgumentOutOfRangeException>(() => CalendarDateTime.AddYearlyDayOfWeekReverseEvent("jf", false, 1, 0, DayOfWeek.Monday));
 }
Esempio n. 4
0
 public void AddYearlyDayOfWeekReverseEventNameNull()
 {
     Assert.Throws <ArgumentNullException>(() => CalendarDateTime.AddYearlyDayOfWeekReverseEvent(string.Empty, false, 1, 1, DayOfWeek.Monday));
 }
Esempio n. 5
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>	Add Memorial Day. </summary>
        ///
        /// <param name="dayOff">	Day off (not a workday). </param>
        ///
        /// <example>
        ///     <code>
        ///     // using ThisDate.DefinedCalendars.USA;
        ///     CalendarDateTime.MemorialDay(true);
        ///     </code>
        /// </example>
        ///-------------------------------------------------------------------------------------------------
        public static void MemorialDay(bool dayOff)
        {
            var startDate = new DateTime(1868, 1, 1);

            CalendarDateTime.AddYearlyDayOfWeekReverseEvent(HolidayNames.MemorialDayText, dayOff, 5, 1, DayOfWeek.Monday, startDate);
        }