예제 #1
0
        public override void Execute(Task task, Guid?serviceInstanceId)
        {
            if (!Enum.IsDefined(typeof(OperationTaskType), task.Name))
            {
                var message = string.Format(TaskResources.OperationsTaskRequest_InvalidRequestInvalidTaskName, task.Name);
                _taskService.CompleteUnrecoverableTaskException(task, message);
                throw new UnRecoverableErrorException(message);
            }

            // Acquire the lock
            _timerLockService.AcquireLock(serviceInstanceId.Value, task.Pin ?? 0, task.Id);

            if (task.Name.SafeEquals(TaskNames.MergePin))
            {
                _timerLockService.AcquireLock(serviceInstanceId.Value, task.FromPin ?? 0, task.Id);
                _timerLockService.AcquireLock(serviceInstanceId.Value, task.ToPin ?? 0, task.Id);
            }

            // Execute the operation task
            var operationsTask = _objectBuilder.Resolve <IOperationsTaskProcessor>(task.Name);

            operationsTask.Execute(task);

            // Complete the task
            _taskService.CompleteTask(task, true);
        }
예제 #2
0
        public void TimerLockService_AcquireLock_NewLockCreatesNewLock_CallsInsertAndUnitOfWorkSave()
        {
            #region Arrange

            #endregion

            #region Act

            _timerLockService.AcquireLock(new Guid(), 99999, 10);

            #endregion

            #region Assert

            _mockTimerLockRepository.Verify(x => x.Insert(It.IsAny <TimerLock>()), Times.Once());
            _mockUnitOfWork.Verify(x => x.Save(), Times.Once);

            #endregion
        }