public void ExecuteAction()
        {
            var task = new TestWorkerTask();

            var request = new TaskRequest(new QueueMessage("{\"task\": \"Test\", \"action\": \"TestAction\", \"id\": \"testId\" }"));

            var result = task.Execute(request);

            Assert.That(result, Is.Not.Null);
        }
        public override void Run()
        {
            var workerTaskFactory = new WorkerTaskFactory();

            while (!IsStopped)
            {
                try
                {
                    var taskContext = new TaskContext(Storage);

                    var message = Queue.GetMessage();
                    if (message != null)
                    {
                        try
                        {
                            var taskRequest = new TaskRequest(message);
                            try
                            {
                                var workerTaskType = workerTaskFactory.GetWorkerTaskType(taskRequest.TaskName);
                                var workerTask = workerTaskFactory.GetWorkerTaskInstance(workerTaskType);

                                var result = workerTask.Execute(taskRequest);

                                result.Execute(taskRequest, taskContext);
                            }
                            catch (Exception ex)
                            {
                                new ErrorResult(ex).Execute(taskRequest, taskContext);
                            }
                        }
                        finally
                        {
                            Queue.Acknowledge(message);
                        }
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }

                }
                catch (Exception ex)
                {
                    Trace.TraceError("Unhandled exception: {0}", ex);
                }
            }
        }