public void ValidateHandlesValidationTasks() { var subTask = new MockTask(); var task = new TestTask { Tasks = new ITask[] { subTask } }; task.Validate(null, ConfigurationTrace.Start(null), null); Assert.IsTrue(subTask.IsValided); }
public void ValidateValidatesElseTasks() { var wasValidated = false; var taskMock = new MockTask() { ValidateAction = (c, t, ep) => wasValidated = true }; var task = new ConditionalTask { ElseTasks = new[] {taskMock} }; task.Validate(null, ConfigurationTrace.Start(this), null); Assert.IsTrue(wasValidated); }
public void ApplyParametersStoresTheArguments() { var parameters = new Dictionary <string, string>(); var definitions = new List <ParameterBase>(); var subTask = new MockTask(); var task = new TestTask { Tasks = new ITask[] { subTask } }; var result = mocks.Create <IIntegrationResult>().Object; task.ApplyParameters(parameters, definitions); task.Run(result); mocks.VerifyAll(); Assert.AreSame(parameters, subTask.Parameters); Assert.AreSame(definitions, subTask.Definitions); Assert.IsTrue(subTask.Executed); }
public void ApplyParametersStoresTheArguments() { var parameters = new Dictionary<string, string>(); var definitions = new List<ParameterBase>(); var subTask = new MockTask(); var task = new TestTask { Tasks = new ITask[] { subTask } }; var result = mocks.DynamicMock<IIntegrationResult>(); mocks.ReplayAll(); task.ApplyParameters(parameters, definitions); task.Run(result); mocks.VerifyAll(); Assert.AreSame(parameters, subTask.Parameters); Assert.AreSame(definitions, subTask.Definitions); Assert.IsTrue(subTask.Executed); }
public void InitialiseStatusHandlesStatusTask() { var subTask = new MockTask(); var task = new TestTask { Tasks = new ITask[] { subTask } }; task.TestStatus(); Assert.IsNotNull(task.CurrentStatus); Assert.IsTrue(subTask.SnapshotGenerated); }
public void ExecuteRunsTasksWhenConditionsPass() { var passRan = false; var failRan = false; var mockCondition = new MockCondition { EvalFunction = ir => true }; var passTask = new MockTask { RunAction = ir => passRan = true }; var failTask = new MockTask { RunAction = ir => failRan = true }; var task = new ConditionalTask { Tasks = new[] {passTask}, ElseTasks = new[] {failTask}, TaskConditions = new[] {mockCondition} }; var resultMock = this.GenerateResultMock(); this.mocks.ReplayAll(); resultMock.Status = IntegrationStatus.Success; task.Run(resultMock); this.mocks.VerifyAll(); Assert.IsTrue(passRan); Assert.IsFalse(failRan); }
public void ExecuteRunsAllTasksWhenConditionsFailAndNotContinueOnFailure() { var passRan = false; var firstFailRan = false; var secondFailRan = false; var thirdFailRan = false; var mockCondition = new MockCondition { EvalFunction = ir => false }; var passTask = new MockTask { RunAction = ir => passRan = true }; var firstFailTask = new MockTask { RunAction = ir => firstFailRan = true }; var secondFailTask = new MockTask { RunAction = ir => { secondFailRan = true; ir.Status = IntegrationStatus.Failure; } }; var thirdFailTask = new MockTask { RunAction = ir => thirdFailRan = true }; var task = new ConditionalTask { Tasks = new[] { passTask }, ElseTasks = new[] { firstFailTask, secondFailTask, thirdFailTask }, TaskConditions = new[] { mockCondition }, ContinueOnFailure = false }; var resultMock = this.GenerateResultMock(); AddResultMockExpectedClone(resultMock); AddResultMockExpectedMerge(resultMock); this.mocks.ReplayAll(); resultMock.Status = IntegrationStatus.Success; task.Run(resultMock); this.mocks.VerifyAll(); Assert.IsFalse(passRan); Assert.IsTrue(firstFailRan); Assert.IsTrue(secondFailRan); Assert.IsFalse(thirdFailRan); }
public void ExecuteRunsAllInnerTasksWhenConditionsFailAndContinueOnFailure() { const int innerCount = 3; const int leafCount = 2; var passRan = false; int taskRunCount = 0; var mockCondition = new MockCondition { EvalFunction = ir => false }; var passTask = new MockTask { RunAction = ir => passRan = true }; var innerTasks = new List <ConditionalTask>(); for (var innerLoop = 1; innerLoop <= innerCount; innerLoop++) { var leafTasks = new List <MockTask>(); for (var leafLoop = 1; leafLoop <= leafCount; leafLoop++) { leafTasks.Add(((innerLoop == 2) && (leafLoop == 2)) ? new MockTask { RunAction = ir => { taskRunCount++; ir.Status = IntegrationStatus.Failure; } } : new MockTask { RunAction = ir => { taskRunCount++; ir.Status = IntegrationStatus.Success; } } ); } innerTasks.Add(new ConditionalTask { ContinueOnFailure = false, ElseTasks = leafTasks.ToArray(), TaskConditions = new[] { mockCondition } }); } var task = new ConditionalTask { Tasks = new[] { passTask }, ElseTasks = innerTasks.ToArray(), TaskConditions = new[] { mockCondition }, ContinueOnFailure = true }; var resultMock = this.GenerateResultMock(leafCount, leafCount); AddResultMockExpectedClone(resultMock, leafCount, leafCount); AddResultMockExpectedClone(resultMock, leafCount, leafCount); AddResultMockExpectedMerge(resultMock); AddResultMockExpectedMerge(resultMock); this.mocks.ReplayAll(); resultMock.Status = IntegrationStatus.Success; task.Run(resultMock); this.mocks.VerifyAll(); Assert.IsFalse(passRan); Assert.AreEqual(innerCount * leafCount, taskRunCount, "Bad task run count"); }
public void ExecuteRunsAllInnerTasksWhenConditionsFailAndContinueOnFailure() { const int innerCount = 3; const int leafCount = 2; var passRan = false; int taskRunCount = 0; var mockCondition = new MockCondition { EvalFunction = ir => false }; var passTask = new MockTask { RunAction = ir => passRan = true }; var innerTasks = new List<ConditionalTask>(); for (var innerLoop = 1; innerLoop <= innerCount; innerLoop++) { var leafTasks = new List<MockTask>(); for (var leafLoop = 1; leafLoop <= leafCount; leafLoop++) leafTasks.Add(((innerLoop == 2) && (leafLoop == 2)) ? new MockTask { RunAction = ir => { taskRunCount++; ir.Status = IntegrationStatus.Failure; } } : new MockTask { RunAction = ir => { taskRunCount++; ir.Status = IntegrationStatus.Success; } } ); innerTasks.Add(new ConditionalTask { ContinueOnFailure = false, ElseTasks = leafTasks.ToArray(), TaskConditions = new[] { mockCondition } }); } var task = new ConditionalTask { Tasks = new[] { passTask }, ElseTasks = innerTasks.ToArray(), TaskConditions = new[] { mockCondition }, ContinueOnFailure = true }; var resultMock = this.GenerateResultMock(leafCount, leafCount); AddResultMockExpectedClone(resultMock, leafCount, leafCount); AddResultMockExpectedClone(resultMock, leafCount, leafCount); AddResultMockExpectedMerge(resultMock); AddResultMockExpectedMerge(resultMock); this.mocks.ReplayAll(); resultMock.Status = IntegrationStatus.Success; task.Run(resultMock); this.mocks.VerifyAll(); Assert.IsFalse(passRan); Assert.AreEqual(innerCount * leafCount, taskRunCount, "Bad task run count"); }