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); }
public void SequentialProgressController_IProgressController_Initialize_Twice() { // Arrange ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0]); // Act and verify Exceptions.Expect <InvalidOperationException>(() => this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0])); }
public void SequentialProgressController_IProgressController_Start() { // Arrange ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); ConfigurableProgressTestOperation stepOperation = new ConfigurableProgressTestOperation(this.VerifyControllerExecuting); testFactory.CreateOpeartion = (d) => stepOperation; this.testSubject.Initialize(testFactory, new[] { new StubProgressStepDefinition() }); this.testSubject.IsStarted.Should().BeFalse("Wasn't started yet"); this.testSubject.IsFinished.Should().BeFalse("Wasn't started yet"); // Act this.testSubject.StartAsync().Wait(); this.testSubject.IsStarted.Should().BeTrue("Was started"); this.testSubject.IsFinished.Should().BeTrue("Was finished"); }
public void SequentialProgressController_IProgressController_Initialize() { // Arrange ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); IProgressStepDefinition[] definitions = new IProgressStepDefinition[] { new StubProgressStepDefinition(), new StubProgressStepDefinition(), new StubProgressStepDefinition() }; // Act this.testSubject.Initialize(testFactory, definitions); // Assert IProgressStepOperation[] stepOperations = this.testSubject.Steps.OfType <IProgressStepOperation>().ToArray(); testFactory.AssertStepOperationsCreatedForDefinitions(definitions, stepOperations); }
public void SequentialProgressController_IProgressController_Start_Twice() { // Arrange ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0]); // Act in parallel and verify Exceptions.Expect <InvalidOperationException>(() => { try { Task.WaitAll( this.testSubject.StartAsync(), this.testSubject.StartAsync()); } catch (AggregateException ex) { throw ex.InnerException; } }); }
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); }
public void SequentialProgressController_IProgressController_Initialize() { // Setup ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); IProgressStepDefinition[] definitions = new IProgressStepDefinition[] { new StubProgressStepDefinition(), new StubProgressStepDefinition(), new StubProgressStepDefinition() }; // Execute this.testSubject.Initialize(testFactory, definitions); // Verify IProgressStepOperation[] stepOperations = this.testSubject.Steps.OfType<IProgressStepOperation>().ToArray(); testFactory.AssertStepOperationsCreatedForDefinitions(definitions, stepOperations); }
public void SequentialProgressController_IProgressController_Start() { // Setup ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); ConfigurableProgressTestOperation stepOperation = new ConfigurableProgressTestOperation(this.VerifyControllerExecuting); testFactory.CreateOpeartion = (d) => stepOperation; this.testSubject.Initialize(testFactory, new[] { new StubProgressStepDefinition() }); Assert.IsFalse(this.testSubject.IsStarted, "Wasn't started yet"); Assert.IsFalse(this.testSubject.IsFinished, "Wasn't started yet"); // Execute this.testSubject.Start().Wait(); Assert.IsTrue(this.testSubject.IsStarted, "Was started"); Assert.IsTrue(this.testSubject.IsFinished, "Was finished"); }
public void SequentialProgressController_IProgressController_Start_Twice() { // Setup ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0]); // Execute in parallel and verify Exceptions.Expect<InvalidOperationException>(() => { try { Task.WaitAll( this.testSubject.Start(), this.testSubject.Start()); } catch (AggregateException ex) { throw ex.InnerException; } }); }
public void SequentialProgressController_IProgressController_Initialize_Twice() { // Setup ConfigurableProgressStepFactory testFactory = new ConfigurableProgressStepFactory(); this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0]); // Execute and verify Exceptions.Expect<InvalidOperationException>(() => this.testSubject.Initialize(testFactory, new IProgressStepDefinition[0])); }