public void TaskService_AllProvisioningHandlerTasks_CallsRepositoryQuery() { #region Arrange #endregion #region Act var outstandingTasks = _taskService.AllProvisioningHandlerTasks().ToList(); #endregion #region Assert Assert.IsNotNull(outstandingTasks); _mockTaskRepository.Verify(x => x.Query(It.IsAny <Expression <Func <Task, bool> > >()), Times.Once()); #endregion }
public override void Execute() { try { // Get all outstanding provisioning tasks var tasks = _taskService.AllProvisioningHandlerTasks().ToList(); if (tasks.Any()) { foreach (var task in tasks) { try { // Create a new DI container to keep all work with the handler discrete _objectBuilder.AddChildContainer(); // Instantiate the task handler using (var taskHandler = _objectBuilder.Resolve <ITaskHandler>(task.Handler)) { // Check that the task is scheduled to be executed if (!taskHandler.CanExecute(task, null)) { return; } taskHandler.Execute(task, null); } } finally { _objectBuilder.RemoveAllChildContainers(); } } } } catch (Exception ex) { _loggingManager.Write(LoggingEventSource.ProvisioningService, LoggingEventType.Error, ex.Message); } }