Example #1
0
 public static void OutputResult(ScheduledFunctionResult <DateTime> result)
 {
     Assert.IsNotNull(result);
     Trace.WriteLine(
         string.Format(
             "Result:\t\t{1:hh:mm:ss.ffff}{0}Due:\t\t{2:hh:mm:ss.ffff}{0}Started:\t{3:ss.ffff}{0}Duration:\t{4}ms{0}",
             Environment.NewLine,
             result.Result,
             result.Due,
             result.Started,
             result.Duration.TotalMilliseconds()));
 }
Example #2
0
 public static void OutputResult(
     ScheduledFunctionResult <DateTime> result,
     DateTime startTime,
     TimeSpan expectedTimeSpan,
     bool failed = false)
 {
     Assert.IsNotNull(result);
     Trace.WriteLine(
         string.Format(
             "Result:\t\t{1:hh:mm:ss.ffff}{0}Expected:\t{2:hh:mm:ss.ffff}{0}Expected Time Span:\t{3}s{0}Due:\t\t{4:hh:mm:ss.ffff}{0}Started:\t{5:ss.ffff}{0}Duration:\t{6}ms{7}{0}",
             Environment.NewLine,
             result.Result,
             startTime + expectedTimeSpan,
             expectedTimeSpan.TotalSeconds,
             result.Due,
             result.Started,
             result.Duration.TotalMilliseconds(),
             failed ? string.Format("{0}**Failed**", Environment.NewLine) : string.Empty));
 }
Example #3
0
        public void CheckResults()
        {
            int numberOfTestsPassed = 0;
            int testNumber          = 1;

            foreach (KeyValuePair <ScheduledFunction <DateTime>, IEnumerable <TimeSpan> > test in _tests)
            {
                Trace.WriteLine(
                    string.Format(
                        "Test #{1} (Start time: {2:hh:mm:ss.ffff} ({3:hh:mm:ss.ffff})):{0}",
                        Environment.NewLine,
                        testNumber,
                        _startTime,
                        _fullStartTime));

                bool testFailed = false;
                Queue <ScheduledFunctionResult <DateTime> > results =
                    new Queue <ScheduledFunctionResult <DateTime> >(test.Key.History);

                foreach (TimeSpan expectedTimeSpan in test.Value)
                {
                    if (results.Count < 1)
                    {
                        Trace.WriteLine(
                            string.Format(
                                "**Not enough results available for test**{0}",
                                Environment.NewLine));
                        testFailed = true;
                        break;
                    }

                    ScheduledFunctionResult <DateTime> result = results.Dequeue();
                    bool resultFailed = false;

                    if (expectedTimeSpan == TimeSpan.MinValue)
                    {
                        // If TimeSpan.MinValue, expect immediate execution
                        if (Math.Abs((result.Result - _fullStartTime).TotalSeconds) > 0.10)
                        {
                            testFailed   = true;
                            resultFailed = true;
                        }

                        OutputResult(result, _fullStartTime, TimeSpan.Zero, resultFailed);
                    }
                    else
                    {
                        TimeSpan resultantTimeSpan = result.Result - _startTime;

                        if (Math.Abs((resultantTimeSpan - expectedTimeSpan).TotalSeconds) > 0.50)
                        {
                            testFailed   = true;
                            resultFailed = true;
                        }

                        OutputResult(result, _startTime, expectedTimeSpan, resultFailed);
                    }
                }

                if (results.Count > 0)
                {
                    Trace.WriteLine(string.Format("**Extra Results: ({1})**{0}", Environment.NewLine, results.Count));
                    testFailed = true;

                    foreach (ScheduledFunctionResult <DateTime> extraResult in results)
                    {
                        OutputResult(extraResult);
                    }
                }
                if (!testFailed)
                {
                    numberOfTestsPassed++;
                    Trace.WriteLine(string.Format("**Test Passed**{0}", Environment.NewLine));
                }
                else
                {
                    Trace.WriteLine(string.Format("**Test Failed**{0}", Environment.NewLine));
                }
                testNumber++;
            }

            if (numberOfTestsPassed == _tests.Count)
            {
                Trace.WriteLine(
                    string.Format(
                        "All tests passed ({1} test(s)){0}",
                        Environment.NewLine,
                        numberOfTestsPassed));
            }
            else
            {
                Assert.Fail("{0} passed, {1} failed", numberOfTestsPassed, _tests.Count - numberOfTestsPassed);
            }
        }
 public static void OutputResult(
     ScheduledFunctionResult<DateTime> result,
     DateTime startTime,
     TimeSpan expectedTimeSpan,
     bool failed = false)
 {
     Assert.IsNotNull(result);
     Trace.WriteLine(
         string.Format(
             "Result:\t\t{1:hh:mm:ss.ffff}{0}Expected:\t{2:hh:mm:ss.ffff}{0}Expected Time Span:\t{3}s{0}Due:\t\t{4:hh:mm:ss.ffff}{0}Started:\t{5:ss.ffff}{0}Duration:\t{6}ms{7}{0}",
             Environment.NewLine,
             result.Result,
             startTime + expectedTimeSpan,
             expectedTimeSpan.TotalSeconds,
             result.Due,
             result.Started,
             result.Duration.TotalMilliseconds(),
             failed ? string.Format("{0}**Failed**", Environment.NewLine) : string.Empty));
 }
 public static void OutputResult(ScheduledFunctionResult<DateTime> result)
 {
     Assert.IsNotNull(result);
     Trace.WriteLine(
         string.Format(
             "Result:\t\t{1:hh:mm:ss.ffff}{0}Due:\t\t{2:hh:mm:ss.ffff}{0}Started:\t{3:ss.ffff}{0}Duration:\t{4}ms{0}",
             Environment.NewLine,
             result.Result,
             result.Due,
             result.Started,
             result.Duration.TotalMilliseconds()));
 }