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 async Task SequentialTasksExecuteInSequence() { var task = new SequentialTask(this.tasks); await task.ExecuteAsync(this.Context); Assert.Equal(1, this.maxExecuting); }
public async Task SequentialTasksVerifyInParallel() { var task = new SequentialTask(TaskName, this.tasks); await task.VerifyAsync(this.Context); Assert.True(this.maxExecuting > 1); }
/// <summary> /// Executes the loader task sequence. /// </summary> /// <remarks> /// Note: This executes the supplied list in sequence. If parallel /// execution is needed then create ParallelTasks in this list. /// </remarks> /// <param name="tasks">A sequence of tasks to execute.</param> /// <returns>A task representing the completion of this function.</returns> private static async Task ExecuteAsync(IEnumerable <ITask> tasks) { var mainTask = new SequentialTask("Main", tasks); var context = new TaskContext(Program.CancellationTokenSource); await mainTask.VerifyAsync(context); await mainTask.ExecuteAsync(context); }
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"); }
/// <summary> /// Builds a set of tasks to perform the load. /// </summary> /// <returns>A sequence of tasks to execute.</returns> private static IEnumerable <ITask> BuildTasks() { List <ITask> tasks = new List <ITask>(); var targetFactory = Program.connectionFactories["target"]; if (Program.Options.FullLoad) { // Clean out the database. var cleanTask = new SequentialTask( "Clean Target Database", new ExecuteSqlTask("Truncate Facts", targetFactory, SqlQueries.TruncateFactsSql), new ExecuteSqlTask("Delete dimension data", targetFactory, SqlQueries.DeleteDimensionData)); tasks.Add(cleanTask); } var dimensionTasks = new List <ITask>(); if (Program.Options.FullLoad) { var currencyLoader = new CurrencyLoader(targetFactory); dimensionTasks.Add(currencyLoader.Build()); var dateLoader = new DateLoader(targetFactory); dimensionTasks.Add(dateLoader.Build()); var productLoader = new ProductLoader(targetFactory); Program.Disposables.Add(productLoader); dimensionTasks.Add(productLoader.Build()); } tasks.Add(new ParallelTask("Load Dimensions", dimensionTasks)); return(tasks); }
public void SequentialTaskNameConstructorSetsName() { var task = new SequentialTask(TaskName, this.tasks); Assert.Equal(TaskName, task.Name); }