AssertCorrectExecution() public méthode

public AssertCorrectExecution ( ProgressControllerResult result ) : void
result ProgressControllerResult
Résultat void
Exemple #1
0
        public void SequentialProgressController_IProgressController_TryAbort_ControllerDrivenCancellation()
        {
            // Arrange
            ConfigurableProgressStepFactory   testFactory   = new ConfigurableProgressStepFactory();
            ConfigurableProgressTestOperation stepOperation = new ConfigurableProgressTestOperation(this.DoNothing)
            {
                CancellableAction = () =>
                {
                    // Using this opportunity to abort - the test assumes that Cancellable is called before the step is actually executed
                    this.testSubject.TryAbort().Should().BeTrue("Should be able to abort");
                    return(true);
                }
            };

            testFactory.CreateOpeartion = (d) => stepOperation;
            ProgressEventsVerifier verifier = new ProgressEventsVerifier(this.testSubject);

            this.testSubject.Initialize(testFactory, new[] { new StubProgressStepDefinition() });

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            verifier.AssertCorrectExecution(ProgressControllerResult.Cancelled);
            verifier.AssertStepCorrectExecution(stepOperation, StepExecutionState.NotStarted);
            verifier.AssertCancellationChanges(3);
        }
Exemple #2
0
        public void SequentialProgressController_IProgressEvents_StepCancelled()
        {
            // Arrange
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(new ProgressStepDefinition(null, StepAttributes.Hidden, this.Cancel));

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            verifier.AssertCorrectExecution(ProgressControllerResult.Cancelled);
            verifier.AssertStepCorrectExecution(this.testSubject.Steps.Single(), StepExecutionState.Cancelled);
            verifier.AssertCancellationChanges(2);
        }
Exemple #3
0
        public void SequentialProgressController_IProgressEvents_StepSucceeded()
        {
            // Setup
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing));

            // Execute
            this.testSubject.Start().Wait();

            // Verify
            verifier.AssertCorrectExecution(ProgressControllerResult.Succeeded);
            verifier.AssertStepCorrectExecution(this.testSubject.Steps.Single(), StepExecutionState.Succeeded);
            verifier.AssertCancellationChanges(1);
        }
Exemple #4
0
        public void SequentialProgressController_IProgressEvents_MultiStep_Succeeded()
        {
            // Arrange
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing),
                                                                                              new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing));

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            verifier.AssertCorrectExecution(ProgressControllerResult.Succeeded);
            IProgressStep[] step = this.testSubject.Steps.ToArray();
            verifier.AssertStepCorrectExecution(step[0], StepExecutionState.Succeeded);
            verifier.AssertStepCorrectExecution(step[1], StepExecutionState.Succeeded);
            verifier.AssertCancellationChanges(1);
        }
Exemple #5
0
        public void SequentialProgressController_IProgressController_TryAbort_NonCancellable()
        {
            // Arrange
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(
                new ProgressStepDefinition(null, StepAttributes.Hidden | StepAttributes.NonCancellable, this.RequestToCancelIgnored),
                new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing));

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            IProgressStep[] stepOperations = this.testSubject.Steps.ToArray();
            verifier.AssertCorrectExecution(ProgressControllerResult.Succeeded);
            verifier.AssertStepCorrectExecution(stepOperations[0], StepExecutionState.Succeeded);
            verifier.AssertStepCorrectExecution(stepOperations[1], StepExecutionState.Succeeded);
            verifier.AssertCancellationChanges(3);
        }
Exemple #6
0
        public void SequentialProgressController_IProgressController_TryAbort_Cancellable()
        {
            // Arrange
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(
                new ProgressStepDefinition(null, StepAttributes.Hidden, this.RequestToCancelAccepted),
                new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing));

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            this.testSubject.CanAbort.Should().BeFalse("Should not be abortable any more, since already aborted");
            IProgressStep[] stepOperations = this.testSubject.Steps.ToArray();
            verifier.AssertCorrectExecution(ProgressControllerResult.Cancelled);
            verifier.AssertStepCorrectExecution(stepOperations[0], StepExecutionState.Succeeded);
            verifier.AssertStepCorrectExecution(stepOperations[1], StepExecutionState.NotStarted);
            verifier.AssertCancellationChanges(2);
        }
Exemple #7
0
        public void SequentialProgressController_IProgressEvents_ProgessChanges()
        {
            // Arrange
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(new ProgressStepDefinition(null, StepAttributes.Hidden, this.NotifyProgress));

            this.notifyProgressSequence.Add(Tuple.Create("hello", 0.25));
            this.notifyProgressSequence.Add(Tuple.Create(string.Empty, 0.5));
            this.notifyProgressSequence.Add(Tuple.Create("world", 0.75));
            this.notifyProgressSequence.Add(Tuple.Create((string)null, 1.0));

            // Act
            this.testSubject.StartAsync().Wait();

            // Assert
            verifier.AssertCorrectExecution(ProgressControllerResult.Succeeded);
            verifier.AssertStepCorrectExecution(this.testSubject.Steps.Single(), StepExecutionState.Succeeded);
            verifier.AssertExecutionProgress(this.testSubject.Steps.Single(), this.notifyProgressSequence.ToArray());
            verifier.AssertCancellationChanges(1);
        }
Exemple #8
0
        public void SequentialProgressController_IProgressController_TryAbort_NonStarted()
        {
            // Setup
            ProgressEventsVerifier verifier = this.InitializeTestSubjectWithTestErrorHandling(
                new ProgressStepDefinition(null, StepAttributes.Hidden | StepAttributes.NonCancellable, this.DoNothing),
                new ProgressStepDefinition(null, StepAttributes.Hidden, this.DoNothing));

            Assert.IsFalse(this.testSubject.TryAbort(), "Should not be able to abort before started");

            // Execute
            this.testSubject.Start().Wait();

            // Verify
            IProgressStep[] stepOperations = this.testSubject.Steps.ToArray();
            verifier.AssertCorrectExecution(ProgressControllerResult.Succeeded);
            verifier.AssertStepCorrectExecution(stepOperations[0], StepExecutionState.Succeeded);
            verifier.AssertStepCorrectExecution(stepOperations[1], StepExecutionState.Succeeded);
            verifier.AssertCancellationChanges(3);
        }
        public void SequentialProgressController_IProgressController_TryAbort_ControllerDrivenCancellation()
        {
            // Setup
            ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory();
            ConfigurableProgressTestOperation stepOperation = new ConfigurableProgressTestOperation(this.DoNothing);
            stepOperation.CancellableAction = () =>
            {
                // Using this opportunity to abort - the test assumes that Cancellable is called before the step is actually executed
                Assert.IsTrue(this.testSubject.TryAbort(), "Should be able to abort");
                return true;
            };
            testFactory.CreateOpeartion = (d) => stepOperation;
            ProgressEventsVerifier verifier = new ProgressEventsVerifier(this.testSubject);
            this.testSubject.Initialize(testFactory, new[] { new StubProgressStepDefinition() });

            // Execute
            this.testSubject.Start().Wait();

            // Verify
            verifier.AssertCorrectExecution(ProgressControllerResult.Cancelled);
            verifier.AssertStepCorrectExecution(stepOperation, StepExecutionState.NotStarted);
            verifier.AssertCancellationChanges(3);
        }