Esempio n. 1
0
        public void Test_CanCompare_ExpectedNotEqual_Cancelled()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo cancelledInfo1         = TaskExecutionResultInfo.Cancelled();
            TimeSpan       sampleDuration1                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt1                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount1 = faker.Random.Int(1, 5);

            TaskExecutionResultInfo cancelledInfo2         = TaskExecutionResultInfo.Cancelled();
            TimeSpan       sampleDuration2                 = faker.Date.Timespan();
            DateTimeOffset sampleRetry2                    = faker.Date.PastOffset();
            int            sampleFaultErrorThresholdCount2 = faker.Random.Int(1, 5);

            TaskExecutionResult cancelled1 = new TaskExecutionResult(cancelledInfo1,
                                                                     duration: sampleDuration1,
                                                                     retryAt: sampleRetryAt1,
                                                                     faultErrorThresholdCount: sampleFaultErrorThresholdCount1);

            TaskExecutionResult cancelled2 = new TaskExecutionResult(cancelledInfo2,
                                                                     duration: sampleDuration2,
                                                                     retryAt: sampleRetry2,
                                                                     faultErrorThresholdCount: sampleFaultErrorThresholdCount2);

            Assert.AreNotEqual(cancelled1, cancelled2);
        }
        public void Test_CanUpdateFromExecutionResult_Cancelled()
        {
            Faker          faker = new Faker();
            DateTimeOffset now   = DateTimeOffset
                                   .UtcNow;

            Faker <QueuedTask> taskFaker =
                GetQueuedTaskFaker();

            QueuedTask task = taskFaker
                              .Generate();

            QueuedTaskResult result = new QueuedTaskResult(task);

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

            QueuedTaskInfo repostWithInfo = result.UdpateFromExecutionResult(cancelled);

            Assert.Null(repostWithInfo);
            Assert.IsNull(result.LastError);
            Assert.AreEqual(QueuedTaskStatus.Cancelled, result.Status);
            Assert.AreEqual(0, result.ProcessingTimeMilliseconds);
            Assert.GreaterOrEqual(result.ProcessingFinalizedAtTs, now);
            Assert.GreaterOrEqual(result.FirstProcessingAttemptedAtTs, now);
            Assert.GreaterOrEqual(result.LastProcessingAttemptedAtTs, now);
        }
Esempio n. 3
0
        public void Test_CanConstruct_Cancelled()
        {
            TaskExecutionResultInfo cancelled = TaskExecutionResultInfo.Cancelled();

            Assert.NotNull(cancelled);
            Assert.IsFalse(cancelled.ExecutedSuccessfully);
            Assert.IsTrue(cancelled.ExecutionCancelled);
            Assert.IsFalse(cancelled.ExecutionFailed);
            Assert.IsNull(cancelled.Error);
        }
Esempio n. 4
0
        public void Test_CanCompare_Cancelled()
        {
            TaskExecutionResultInfo cancelled1 = TaskExecutionResultInfo.Cancelled();
            TaskExecutionResultInfo cancelled2 = TaskExecutionResultInfo.Cancelled();

            Assert.AreEqual(cancelled1, cancelled2);
            Assert.AreEqual(cancelled1, cancelled1);

            Assert.AreNotSame(cancelled1, cancelled2);
        }
Esempio n. 5
0
        public void Test_CanCompare_ExpectedEquals_Cancelled()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo cancelledInfo         = TaskExecutionResultInfo.Cancelled();
            TimeSpan       sampleDuration                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount = faker.Random.Int(1, 5);

            TaskExecutionResult cancelled1 = new TaskExecutionResult(cancelledInfo,
                                                                     duration: sampleDuration,
                                                                     retryAt: sampleRetryAt,
                                                                     faultErrorThresholdCount: sampleFaultErrorThresholdCount);

            TaskExecutionResult cancelled2 = new TaskExecutionResult(cancelledInfo,
                                                                     duration: sampleDuration,
                                                                     retryAt: sampleRetryAt,
                                                                     faultErrorThresholdCount: sampleFaultErrorThresholdCount);

            Assert.AreEqual(cancelled1, cancelled2);
            Assert.AreEqual(cancelled1, cancelled1);
        }
Esempio n. 6
0
        public void Test_CanCreate_Cancelled()
        {
            Faker faker = new Faker();
            TaskExecutionResultInfo cancelledInfo         = TaskExecutionResultInfo.Cancelled();
            TimeSpan       sampleDuration                 = faker.Date.Timespan();
            DateTimeOffset sampleRetryAt                  = faker.Date.RecentOffset();
            int            sampleFaultErrorThresholdCount = faker.Random.Int(1, 5);

            TaskExecutionResult cancelled = new TaskExecutionResult(cancelledInfo,
                                                                    duration: sampleDuration,
                                                                    retryAt: sampleRetryAt,
                                                                    faultErrorThresholdCount: sampleFaultErrorThresholdCount);

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

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

            Assert.AreEqual(sampleRetryAt, cancelled.RetryAt);
            Assert.AreEqual(sampleFaultErrorThresholdCount, cancelled.FaultErrorThresholdCount);
        }
Esempio n. 7
0
 public void NotifyCancellationObserved()
 {
     mResult = TaskExecutionResultInfo.Cancelled();
 }