Exemple #1
0
        private static void RunOneTimeTest(MainForm frm)
        {
            PFSchedule             sked         = new PFSchedule(frm.txtScheduleName.Text.Trim());
            bool                   isScheduled  = false;
            enScheduleLookupResult lookupResult = enScheduleLookupResult.Unknown;

            CreateRunOneTimeSchedule(frm, sked);

            isScheduled  = sked.DateIsScheduled(sked.TestCurrDateTime);
            lookupResult = sked.ScheduleLookupResult;


            _msg.Length = 0;
            _msg.Append("Schedule type:        ");
            _msg.Append(sked.ScheduleFrequency.ToString());
            _msg.Append("\r\n");
            _msg.Append("Schedule Name:        ");
            _msg.Append(sked.Name);
            _msg.Append("\r\n");
            _msg.Append("RunAt date:           ");
            _msg.Append(sked.RunAt.ToString("MM/dd/yyyy HH:mm:ss"));
            _msg.Append("\r\n");
            _msg.Append("Test date:            ");
            _msg.Append(sked.TestCurrDateTime.ToString("MM/dd/yyyy HH:mm:ss"));
            _msg.Append("\r\n");
            _msg.Append("Actual result:        ");
            _msg.Append(lookupResult.ToString());
            _msg.Append("\r\n");
            _msg.Append("Expected test result: ");
            _msg.Append(sked.ExpectedTestResult.ToString());
            _msg.Append("\r\n");
            _msg.Append("Success/Failure:      ");
            if (sked.ExpectedTestResult == lookupResult)
            {
                _msg.Append("SUCCESS");
            }
            else
            {
                _msg.Append("FAIL");
            }
            _msg.Append("\r\n");
            Program._messageLog.WriteLine(_msg.ToString());
        }
Exemple #2
0
        //tests
        public static void OneTimeScheduleTest(MainForm frm)
        {
            try
            {
                _msg.Length = 0;
                _msg.Append("OneTimeScheduleTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                PFSchedule sked = new PFSchedule();
                sked.ScheduleFrequency = enScheduleFrequency.OneTime;
                sked.RunAt             = Convert.ToDateTime("07/23/2013 16:05:00");
                sked.RunWindow         = new TimeSpan(0, 10, 0);

                DateTime currDate = DateTime.Now;

                _msg.Length = 0;
                _msg.Append("CurrDate: ");
                _msg.Append(currDate.ToString("MMMM d, yyyy HH:mm:ss"));
                _msg.Append(" ");

                if (sked.DateIsScheduled(currDate))
                {
                    _msg.Append("is match");
                }
                else
                {
                    _msg.Append("NOT a match");
                }
                Program._messageLog.WriteLine(_msg.ToString());

                DateTime nextDate = DateTime.Now.Add(new TimeSpan(0, 0, 15));

                _msg.Length = 0;
                _msg.Append("NextDate: ");
                _msg.Append(nextDate.ToString("MMMM d, yyyy HH:mm:ss"));
                _msg.Append(" ");

                if (sked.DateIsScheduled(nextDate))
                {
                    _msg.Append("is match");
                }
                else
                {
                    _msg.Append("NOT a match");
                }
                Program._messageLog.WriteLine(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... OneTimeScheduleTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Exemple #3
0
        public static void VerifyDailyScheduleTimesTest(MainForm frm)
        {
            bool     expectedResult = false;
            bool     result         = false;
            DateTime currTime       = DateTime.Now;

            try
            {
                _msg.Length = 0;
                _msg.Append("VerifyDailyScheduleTimesTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                PFSchedule sked = new PFSchedule("TestSchedule");
                sked.ScheduleFrequency = enScheduleFrequency.Daily;
                TimeSpan skedTime = new TimeSpan(12, 25, 00);
                sked.SetDailyOneTimeSchedule(2, 10, skedTime, Convert.ToDateTime("7/13/2013 11:00:00"), Convert.ToDateTime("7/31/2013 23:22:59"));

                expectedResult = true;
                currTime       = Convert.ToDateTime("7/13/2013 12:27:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = false;
                currTime       = Convert.ToDateTime("7/13/2013 12:47:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = true;
                currTime       = Convert.ToDateTime("7/15/2013 12:27:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = false;
                currTime       = Convert.ToDateTime("7/14/2013 12:27:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                sked = null;
                sked = new PFSchedule("TestRecurringSchedule");

                sked.ScheduleFrequency = enScheduleFrequency.Daily;
                //skedTime = new TimeSpan(15, 35, 00);
                sked.SetDailyRecurringSchedule(3, 10, 3, enDailyOccursInterval.Hours, new TimeSpan(1, 0, 0), new TimeSpan(21, 59, 59), Convert.ToDateTime("7/13/2013 00:00:00"), Convert.ToDateTime("7/31/2013 23:59:59"));

                expectedResult = true;
                currTime       = Convert.ToDateTime("7/13/2013 10:05:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = false;
                currTime       = Convert.ToDateTime("7/13/2013 11:05:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = true;
                currTime       = Convert.ToDateTime("7/13/2013 13:05:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);

                expectedResult = false;
                currTime       = Convert.ToDateTime("7/13/2014 11:05:00");
                result         = sked.DateIsScheduled(currTime);
                PrintResult(sked, currTime, result, expectedResult);
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... VerifyDailyScheduleTimesTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Exemple #4
0
        private static void RunMonthlyTest(MainForm frm)
        {
            PFSchedule             sked         = new PFSchedule(frm.txtScheduleName.Text.Trim());
            bool                   isScheduled  = false;
            enScheduleLookupResult lookupResult = enScheduleLookupResult.Unknown;

            CreateMonthlySchedule(frm, sked);

            isScheduled  = sked.DateIsScheduled(sked.TestCurrDateTime);
            lookupResult = sked.ScheduleLookupResult;

            _msg.Length = 0;
            _msg.Append("Schedule type:        ");
            _msg.Append(sked.ScheduleFrequency.ToString());
            _msg.Append("\r\n");
            _msg.Append("Schedule Name:        ");
            _msg.Append(sked.Name);
            _msg.Append("\r\n");
            _msg.Append("Schedule Start Date:  ");
            _msg.Append(sked.ScheduleStartDate.ToString("MM/dd/yyyy HH:mm:ss"));
            _msg.Append("\r\n");
            _msg.Append("Schedule End Date:    ");
            _msg.Append(sked.ScheduleEndDate.ToString("MM/dd/yyyy HH:mm:ss"));
            _msg.Append("\r\n");


            if (sked.MonthlyScheduleMonthIdType == enMonthlyScheduleMonthIdType.EveryNumMonths)
            {
                _msg.Append("Schedule runs every:  ");
                _msg.Append(sked.MonthlyOccursEveryNumMonths.ToString());
                _msg.Append(" month(s)");
            }
            else
            {
                _msg.Append("Scheduled months:     ");
                _msg.Append(GetScheduledMonthDaysList(sked));
                _msg.Append("\r\n");
            }
            _msg.Append("\r\n");

            if (sked.MonthlyScheduleDayIdType == enMonthlyScheduleDayIdType.DayNumber)
            {
                _msg.Append("Schedule runs on day: ");
                _msg.Append(sked.MonthlyScheduleDay.ToString());
            }
            else
            {
                _msg.Append("Schedule runs on:     ");
                _msg.Append(sked.MonthlyScheduleOrdinal.ToString());
                _msg.Append(" ");
                _msg.Append(sked.MonthlyScheduleDay.ToString());
            }
            _msg.Append("\r\n");


            _msg.Append("Schedule runs every:  ");
            _msg.Append(sked.DailyOccursEveryTimeInterval.ToString());
            _msg.Append(" day(s)");
            _msg.Append("\r\n");
            _msg.Append("Daily Frequency:      ");
            _msg.Append(sked.DailyFrequency.ToString());
            _msg.Append("\r\n");

            if (sked.DailyFrequency == enDailyFrequency.OneTime)
            {
                _msg.Append("Daily Run At:         ");
                _msg.Append(sked.OccursOnceAtTime.ToString());
                _msg.Append("\r\n");
            }
            else
            {
                _msg.Append("Daily occurs every:   ");
                _msg.Append(sked.DailyOccursEveryTimeInterval.ToString());
                _msg.Append(" ");
                _msg.Append(sked.DailyOccursTimeInterval.ToString());
                _msg.Append("\r\n");
                _msg.Append("Daily starting at:    ");
                _msg.Append(PFScheduler.FormatTimeSpan(sked.DailyOccursStartTime));
                _msg.Append("\r\n");
                _msg.Append("Daily ends at:        ");
                _msg.Append(PFScheduler.FormatTimeSpan(sked.DailyOccursEndTime));
                _msg.Append("\r\n");
            }

            _msg.Append("Test date:            ");
            _msg.Append(sked.TestCurrDateTime.ToString("MM/dd/yyyy HH:mm:ss"));
            _msg.Append("\r\n");
            _msg.Append("Actual result:        ");
            _msg.Append(lookupResult.ToString());
            _msg.Append("\r\n");
            _msg.Append("Expected test result: ");
            _msg.Append(sked.ExpectedTestResult.ToString());
            _msg.Append("\r\n");
            _msg.Append("Success/Failure:      ");
            if (sked.ExpectedTestResult == lookupResult)
            {
                _msg.Append("SUCCESS");
            }
            else
            {
                _msg.Append("FAIL");
            }
            _msg.Append("\r\n");
            Program._messageLog.WriteLine(_msg.ToString());
        }