public void ExecuteIgnoresFailures() { // Initialise the task var subTasks = new List <SequentialTestTask>(); for (var loop = 1; loop <= 5; loop++) { subTasks.Add(new SequentialTestTask { TaskNumber = loop, Result = loop > 3 ? IntegrationStatus.Failure : IntegrationStatus.Success }); } var task = new SequentialTask { Tasks = subTasks.ToArray(), ContinueOnFailure = true }; // Setup the mocks var logger = mocks.DynamicMock <ILogger>(); var result = GenerateResultMock(5); mocks.ReplayAll(); // Run the actual task task.Run(result); // Verify the results mocks.VerifyAll(); Assert.AreEqual(IntegrationStatus.Failure, result.Status, "Status does not match"); }
public void ExecuteHandlesAnExceptionInATask() { // Initialise the task var task = new SequentialTask { Tasks = new ITask[] { new ExceptionTestTask() } }; // Setup the mocks var logger = mocks.DynamicMock <ILogger>(); var result = GenerateResultMock(0); Expect.Call(result.ExceptionResult).PropertyBehavior(); mocks.ReplayAll(); // Run the actual task task.Run(result); // Verify the results mocks.VerifyAll(); Assert.AreEqual(IntegrationStatus.Failure, result.Status, "Status does not match"); }
public void ExecuteHandlesAnExceptionInATask() { // Initialise the task var task = new SequentialTask { Tasks = new ITask[] { new ExceptionTestTask() } }; // Setup the mocks var logger = mocks.Create <ILogger>().Object; var result = GenerateResultMock(0); Mock.Get(result).SetupSet(_result => _result.ExceptionResult = It.IsAny <Exception>()).Verifiable(); Mock.Get(result).SetupProperty(_result => _result.ExceptionResult); // Run the actual task task.Run(result); // Verify the results VerifyResultMock(result, 0); mocks.Verify(); Assert.AreEqual(IntegrationStatus.Failure, result.Status, "Status does not match"); }
public void ExecuteStopsOnFirstFailure() { // Initialise the task var subTasks = new List <SequentialTestTask>(); for (var loop = 1; loop <= 5; loop++) { subTasks.Add(new SequentialTestTask { TaskNumber = loop, Result = loop > 3 ? IntegrationStatus.Failure : IntegrationStatus.Success }); } var task = new SequentialTask { Tasks = subTasks.ToArray() }; // Setup the mocks var logger = mocks.Create <ILogger>().Object; var result = GenerateResultMock(4); // Run the actual task task.Run(result); // Verify the results VerifyResultMock(result, 4); mocks.Verify(); Assert.AreEqual(IntegrationStatus.Failure, result.Status, "Status does not match"); }
public void ExecuteIgnoreFailureStillRunInnerSequentialTasks() { const int innerCount = 3; const int leafCount = 2; // Initialise the task var innerTasks = new List <SequentialTask>(); for (var innerLoop = 1; innerLoop <= innerCount; innerLoop++) { var leafTasks = new List <SequentialTestTask>(); for (var leafLoop = 1; leafLoop <= leafCount; leafLoop++) { leafTasks.Add(new SequentialTestTask { TaskNumber = innerLoop * 10 + leafLoop, Result = (innerLoop == 2) && (leafLoop == 2) ? IntegrationStatus.Failure : IntegrationStatus.Success }); } innerTasks.Add(new SequentialTask { ContinueOnFailure = false, Tasks = leafTasks.ToArray() }); } var task = new SequentialTask { Tasks = innerTasks.ToArray(), ContinueOnFailure = true }; // Setup the mocks var logger = mocks.DynamicMock <ILogger>(); // We cannot use a mock object here because having Clone return the original result means the test // will not be able to catch the error we are after. var result = new IntegrationResult(); result.ProjectName = ""; // must set to an empty string because the null default value makes Clone crash mocks.ReplayAll(); // Run the actual task task.Run(result); // Verify the results mocks.VerifyAll(); Assert.AreEqual(IntegrationStatus.Failure, result.Status, "Status does not match"); Assert.AreEqual(innerCount * leafCount, result.TaskResults.Count, "Bad task results count"); }