Ejemplo n.º 1
0
        /// <summary>
        /// Verifies that the <see cref="ProgressControllerStep"/> was initialized correctly
        /// </summary>
        /// <param name="testSubject">The step to verify</param>
        /// <param name="attributes">Step attributes</param>
        /// <param name="displayText">Step display text</param>
        public static void VerifyInitialized(ProgressControllerStep testSubject, StepAttributes attributes, string displayText = null)
        {
            StepExecution expectedExecution         = (attributes & StepAttributes.BackgroundThread) != 0 ? StepExecution.BackgroundThread : StepExecution.ForegroundThread;
            bool          expectedHidden            = (attributes & StepAttributes.Hidden) != 0 ? true : false;
            bool          expectedCancellable       = (attributes & StepAttributes.NonCancellable) != 0 ? false : true;
            bool          expectedImpactingProgress = (attributes & StepAttributes.NoProgressImpact) != 0 ? false : true;
            bool          expectedIndeterminate     = (attributes & StepAttributes.Indeterminate) != 0 ? true : false;

            CheckState(testSubject, StepExecutionState.NotStarted);
            Assert.AreEqual(displayText, testSubject.DisplayText, "Unexpected display text");
            Assert.AreEqual(expectedCancellable, testSubject.Cancellable, "Cancellable: Unexpected post initialization value");
            Assert.AreEqual(expectedIndeterminate, testSubject.Indeterminate, "Indeterminate: Unexpected post initialization value");
            Assert.AreEqual(expectedExecution, testSubject.Execution, "Execution: Unexpected post initialization value");
            Assert.AreEqual(expectedHidden, testSubject.Hidden, "Hidden: Unexpected post initialization value");
            Assert.AreEqual(expectedImpactingProgress, testSubject.ImpactsProgress, "ImpactingProgress: Unexpected post initialization value");

            if (expectedIndeterminate)
            {
                Assert.IsTrue(ProgressControllerHelper.IsIndeterminate(testSubject.Progress), "Progess: Should be Indeterminate");
            }
            else
            {
                Assert.AreEqual(0, testSubject.Progress, "Progress: Unexpected post initialization value");
            }
        }
        private void InitializeAndExecuteTestSubject(string text, StepAttributes attributes, Action <CancellationToken, IProgressStepExecutionEvents> operation)
        {
            // Arrange
            this.testSubject = new ProgressControllerStep(this.testController, new ProgressStepDefinition(text, attributes, operation));

            // Assert initialized state
            VerificationHelper.VerifyInitialized(this.testSubject, attributes, text);

            // Act by the controller
            this.testController.Execute(this.testSubject);
        }
        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");
        }