Example #1
0
        public void Test_CanCompare_ExpectedNotEqual_Successful()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo successfulInfo1        = TaskExecutionResultInfo.Successful();
            TimeSpan       sampleDuration1                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt1                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount1 = faker.Random.Int(1, 5);

            TaskExecutionResultInfo successfulInfo2        = TaskExecutionResultInfo.Successful();
            TimeSpan       sampleDuration2                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt2                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount2 = faker.Random.Int(1, 5);

            TaskExecutionResult successful1 = new TaskExecutionResult(successfulInfo1,
                                                                      duration: sampleDuration1,
                                                                      retryAt: sampleRetryAt1,
                                                                      faultErrorThresholdCount: sampleFaultErrorThresholdCount1);

            TaskExecutionResult successful2 = new TaskExecutionResult(successfulInfo2,
                                                                      duration: sampleDuration2,
                                                                      retryAt: sampleRetryAt2,
                                                                      faultErrorThresholdCount: sampleFaultErrorThresholdCount2);

            Assert.AreNotEqual(successful1, successful2);
        }
        public void Test_CanUpdateFromExecutionResult_Successful()
        {
            Faker          faker = new Faker();
            DateTimeOffset now   = DateTimeOffset
                                   .UtcNow;

            Faker <QueuedTask> taskFaker =
                GetQueuedTaskFaker();

            QueuedTask task = taskFaker
                              .Generate();

            QueuedTaskResult result = new QueuedTaskResult(task);

            TaskExecutionResult successful = new TaskExecutionResult(TaskExecutionResultInfo.Successful(),
                                                                     duration: faker.Date.Timespan(),
                                                                     retryAt: faker.Date.FutureOffset(),
                                                                     faultErrorThresholdCount: faker.Random.Int(1, 5));

            QueuedTaskInfo repostWithInfo = result.UdpateFromExecutionResult(successful);

            Assert.Null(repostWithInfo);
            Assert.IsNull(result.LastError);
            Assert.AreEqual(QueuedTaskStatus.Processed, result.Status);
            Assert.AreEqual(successful.ProcessingTimeMilliseconds, result.ProcessingTimeMilliseconds);
            Assert.GreaterOrEqual(result.ProcessingFinalizedAtTs, now);
            Assert.GreaterOrEqual(result.FirstProcessingAttemptedAtTs, now);
            Assert.GreaterOrEqual(result.LastProcessingAttemptedAtTs, now);
        }
        public async Task Test_CanPostResult_SuccessfulResults_SerialCalls()
        {
            Faker faker = new Faker();
            Func <TaskExecutionResult> rsFactory = () => new TaskExecutionResult(TaskExecutionResultInfo.Successful(),
                                                                                 duration: faker.Date.Timespan(),
                                                                                 retryAt: DateTimeOffset.UtcNow,
                                                                                 faultErrorThresholdCount: mDataSource.QueueFaultErrorThresholdCount);

            await Run_PostResultTests(rsFactory);
        }
Example #4
0
        public void Test_CanCompare_Successful()
        {
            TaskExecutionResultInfo successful1 = TaskExecutionResultInfo.Successful();
            TaskExecutionResultInfo successful2 = TaskExecutionResultInfo.Successful();

            Assert.AreEqual(successful1, successful2);
            Assert.AreEqual(successful1, successful1);

            Assert.AreNotSame(successful1, successful2);
        }
Example #5
0
        public void Test_CanConstruct_Successful()
        {
            TaskExecutionResultInfo successful = TaskExecutionResultInfo.Successful();

            Assert.NotNull(successful);
            Assert.IsTrue(successful.ExecutedSuccessfully);
            Assert.IsFalse(successful.ExecutionCancelled);
            Assert.IsFalse(successful.ExecutionFailed);
            Assert.IsNull(successful.Error);
        }
Example #6
0
        public void Test_CanCompare_ExpectedEquals_Successful()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo successfulInfo        = TaskExecutionResultInfo.Successful();
            TimeSpan       sampleDuration                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount = faker.Random.Int(1, 5);

            TaskExecutionResult successful1 = new TaskExecutionResult(successfulInfo,
                                                                      duration: sampleDuration,
                                                                      retryAt: sampleRetryAt,
                                                                      faultErrorThresholdCount: sampleFaultErrorThresholdCount);

            TaskExecutionResult successful2 = new TaskExecutionResult(successfulInfo,
                                                                      duration: sampleDuration,
                                                                      retryAt: sampleRetryAt,
                                                                      faultErrorThresholdCount: sampleFaultErrorThresholdCount);

            Assert.AreEqual(successful1, successful2);
            Assert.AreEqual(successful1, successful1);
        }
Example #7
0
        public void Test_CanCreate_Successful()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo successfulInfo        = TaskExecutionResultInfo.Successful();
            TimeSpan       sampleDuration                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount = faker.Random.Int(1, 5);

            TaskExecutionResult successful = new TaskExecutionResult(successfulInfo,
                                                                     duration: sampleDuration,
                                                                     retryAt: sampleRetryAt,
                                                                     faultErrorThresholdCount: sampleFaultErrorThresholdCount);

            Assert.IsTrue(successful.ExecutedSuccessfully);
            Assert.IsFalse(successful.ExecutionCancelled);
            Assert.IsFalse(successful.ExecutionFailed);
            Assert.IsNull(successful.Error);

            Assert.AreEqual(( long )(Math.Ceiling(sampleDuration.TotalMilliseconds)),
                            successful.ProcessingTimeMilliseconds);

            Assert.AreEqual(sampleRetryAt, successful.RetryAt);
            Assert.AreEqual(sampleFaultErrorThresholdCount, successful.FaultErrorThresholdCount);
        }
Example #8
0
 public void NotifyTaskCompleted()
 {
     mResult = TaskExecutionResultInfo.Successful();
 }