public async Task RunNormalStepsAllStepPass() { using (TestHostContext hc = CreateTestContext()) { // Arrange. var variableSets = new[] { new[] { CreateStep(TaskResult.Succeeded, ExpressionManager.Succeeded), CreateStep(TaskResult.Succeeded, ExpressionManager.Succeeded) }, new[] { CreateStep(TaskResult.Succeeded, ExpressionManager.Succeeded), CreateStep(TaskResult.Succeeded, ExpressionManager.SucceededOrFailed) }, new[] { CreateStep(TaskResult.Succeeded, ExpressionManager.Succeeded), CreateStep(TaskResult.Succeeded, ExpressionManager.Always) } }; foreach (var variableSet in variableSets) { _ec.Object.Result = null; // Act. await _stepsRunner.RunAsync( jobContext : _ec.Object, steps : variableSet.Select(x => x.Object).ToList()); // Assert. Assert.Equal(TaskResult.Succeeded, _ec.Object.Result ?? TaskResult.Succeeded); Assert.Equal(2, variableSet.Length); variableSet[0].Verify(x => x.RunAsync()); variableSet[1].Verify(x => x.RunAsync()); } } }
public async Task RunNormalStepsAllStepPass() { using (TestHostContext hc = CreateTestContext()) { // Arrange. var variableSets = new[] { new[] { CreateStep(TaskResult.Succeeded, "success()"), CreateStep(TaskResult.Succeeded, "success()") }, new[] { CreateStep(TaskResult.Succeeded, "success()"), CreateStep(TaskResult.Succeeded, "success() || failure()") }, new[] { CreateStep(TaskResult.Succeeded, "success()"), CreateStep(TaskResult.Succeeded, "always()") } }; foreach (var variableSet in variableSets) { _ec.Object.Result = null; _ec.Setup(x => x.JobSteps).Returns(new Queue <IStep>(variableSet.Select(x => x.Object).ToList())); // Act. await _stepsRunner.RunAsync(jobContext : _ec.Object); // Assert. Assert.Equal(TaskResult.Succeeded, _ec.Object.Result ?? TaskResult.Succeeded); Assert.Equal(2, variableSet.Length); variableSet[0].Verify(x => x.RunAsync()); variableSet[1].Verify(x => x.RunAsync()); } } }
public async Task RunsAfterContinueOnError() { using (TestHostContext hc = CreateTestContext()) { // Arrange. var variableSets = new[] { new[] { CreateStep(TaskResult.Failed, continueOnError: true), CreateStep(TaskResult.Succeeded) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true), CreateStep(TaskResult.Succeeded, condition: "succeededOrFailed()") }, new[] { CreateStep(TaskResult.Failed, continueOnError: true), CreateStep(TaskResult.Succeeded, continueOnError: true) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true), CreateStep(TaskResult.Succeeded, critical: true) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true), CreateStep(TaskResult.Succeeded, isFinally: true) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true, critical: true), CreateStep(TaskResult.Succeeded) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true, critical: true), CreateStep(TaskResult.Succeeded, condition: "succeededOrFailed()") }, new[] { CreateStep(TaskResult.Failed, continueOnError: true, critical: true), CreateStep(TaskResult.Succeeded, continueOnError: true) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true, critical: true), CreateStep(TaskResult.Succeeded, critical: true) }, new[] { CreateStep(TaskResult.Failed, continueOnError: true, critical: true), CreateStep(TaskResult.Succeeded, isFinally: true) }, }; foreach (var variableSet in variableSets) { _ec.Object.Result = null; // Act. await _stepsRunner.RunAsync( jobContext : _ec.Object, steps : variableSet.Select(x => x.Object).ToList()); // Assert. Assert.Equal(TaskResult.SucceededWithIssues, _ec.Object.Result); Assert.Equal(2, variableSet.Length); variableSet[0].Verify(x => x.RunAsync()); variableSet[1].Verify(x => x.RunAsync()); } } }