예제 #1
0
        public void TaskService_AllSupportHandlerTasks_CallsRepositoryQuery()
        {
            #region Arrange

            #endregion

            #region Act

            var outstandingTasks = _taskService.AllSupportHandlerTasks().ToList();

            #endregion

            #region Assert


            Assert.IsNotNull(outstandingTasks);
            _mockTaskRepository.Verify(x => x.Query(It.IsAny <Expression <Func <Task, bool> > >()), Times.Once());

            #endregion
        }
예제 #2
0
        public override void Execute()
        {
            try
            {
                // Get all outstanding support tasks
                var tasks = _taskService.AllSupportHandlerTasks().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.SupportService, LoggingEventType.Error, ex.Message);
            }
        }