CheckState() public static method

Checks the current state of a IProgressStep
public static CheckState ( IProgressStep testSubject, StepExecutionState expectedState ) : void
testSubject IProgressStep The step to check
expectedState StepExecutionState The expected state of the step
return void
 private void ExecuteAndCancell(CancellationToken token, IProgressStepExecutionEvents notifier)
 {
     VerificationHelper.CheckState(this.testSubject, StepExecutionState.Executing);
     this.testController.IsCurrentStepCancellable.Should().BeTrue("Expected to be cancellable");
     this.testController.Cancel();
     token.ThrowIfCancellationRequested();
 }
 private void ExecuteAndNotify(CancellationToken token, IProgressStepExecutionEvents notifier)
 {
     VerificationHelper.CheckState(this.testSubject, StepExecutionState.Executing);
     for (int i = 0; i < DeterminateLoops; i++)
     {
         notifier.ProgressChanged(i.ToString(), (double)(i + 1) / (double)DeterminateLoops);
     }
 }
        public void ProgressControllerStep_NonCancellable()
        {
            this.InitializeAndExecuteTestSubject("non-cancellable step operation", StepAttributes.NonCancellable, this.ExecuteNonCancellable);

            // Assert
            this.testController.progressChanges.Should().BeEmpty();
            VerificationHelper.CheckState(this.testSubject, StepExecutionState.Succeeded);
        }
        public void ProgressControllerStep_ProgressUpdate()
        {
            // Arrange
            this.InitializeAndExecuteTestSubject("progress-update", StepAttributes.None, this.ExecuteAndNotify);

            // Assert
            this.testController.progressChanges.Should().Equal(GetExpectedExecutionEvents());
            VerificationHelper.CheckState(this.testSubject, StepExecutionState.Succeeded);
        }
        public void ProgressControllerStep_Cancelled()
        {
            // Arrange
            this.InitializeAndExecuteTestSubject("canceled step operation", StepAttributes.None, this.ExecuteAndCancell);

            // Assert
            this.testController.progressChanges.Should().BeEmpty();
            VerificationHelper.CheckState(this.testSubject, StepExecutionState.Cancelled);
        }
        public void ProgressControllerStep_Failed()
        {
            // Setup
            this.InitializeAndExecuteTestSubject("exception in executing a step operation", StepAttributes.None, this.ExecuteAndFail);

            // Verify
            this.testController.AssertNoProgressChangeEvents();
            VerificationHelper.CheckState(this.testSubject, StepExecutionState.Failed);
        }
        public void SequentialProgressController_IProgressStepFactory_SupportedInputs()
        {
            IProgressStepOperation stepOperation = this.testSubject.CreateStepOperation(this.controller, new ProgressStepDefinition("text", StepAttributes.None, (c, n) => { }));

            stepOperation.Should().NotBeNull("Expecting IProgressStepOperation");
            ProgressControllerStep step = stepOperation as ProgressControllerStep;

            step.Should().NotBeNull("Expecting ProgressControllerStep");

            VerificationHelper.CheckState(stepOperation.Step, StepExecutionState.NotStarted);

            IProgressStepExecutionEvents notifier = ((IProgressStepFactory)this.testSubject).GetExecutionCallback(stepOperation);

            stepOperation.Should().NotBeNull("Expecting IProgressStepExecutionEvents");
            notifier.Should().Be(step, "Expecting ProgressControllerStep");
        }
        public void ProgressControllerStep_States()
        {
            int maxFlag = ((int[])Enum.GetValues(typeof(StepAttributes))).Max();

            for (int i = 0; i <= maxFlag; i++)
            {
                StepAttributes attributes = (StepAttributes)i;
                string         text       = (attributes & StepAttributes.Hidden) != 0 ? null : Environment.TickCount.ToString();

                this.InitializeAndExecuteTestSubject(text, attributes, this.ExecuteAndVerify);

                // Assert
                VerificationHelper.CheckState(this.testSubject, StepExecutionState.Succeeded);
                this.testController.progressChanges.Should().BeEmpty();
            }
        }
Esempio n. 9
0
 Task <ProgressControllerResult> IProgressController.StartAsync()
 {
     return(Task.Factory.StartNew(() =>
     {
         stepOperations.ForEach(op =>
         {
             try
             {
                 this.canAbort = op.Step.Cancellable;
                 StepExecutionState state = op.RunAsync(this.cts.Token, this).Result;
                 VerificationHelper.CheckState(op.Step, state);
             }
             catch (Exception ex)
             {
                 FluentAssertions.Execution.Execute.Assertion.FailWith(ex.ToString());
             }
         });
         return this.ReturnResult;
     }));
 }
 private void ExecuteNonCancellable(CancellationToken token, IProgressStepExecutionEvents notifier)
 {
     VerificationHelper.CheckState(this.testSubject, StepExecutionState.Executing);
     this.testController.IsCurrentStepCancellable.Should().BeFalse("Not expected to be cancellable");
 }
 private void ExecuteAndFail(CancellationToken token, IProgressStepExecutionEvents notifier)
 {
     VerificationHelper.CheckState(this.testSubject, StepExecutionState.Executing);
     throw new Exception("Boom");
 }
 private void ExecuteAndVerify(CancellationToken token, IProgressStepExecutionEvents notifier)
 {
     VerificationHelper.CheckState(this.testSubject, StepExecutionState.Executing);
 }