示例#1
0
        public async Task Pass_activity_task_prorperties_to_activity()
        {
            var activityTask = new ActivityTask
            {
                ActivityType = new ActivityType {
                    Name = "TestActivity", Version = "1.0"
                },
                WorkflowExecution = new WorkflowExecution {
                    RunId = "runid", WorkflowId = "wid"
                },
                TaskToken      = "token",
                Input          = "input",
                ActivityId     = "activityId",
                StartedEventId = 10
            };
            var workerTask = WorkerTask.CreateFor(activityTask, Mock.Of <IHeartbeatSwfApi>());

            await workerTask.ExecuteFor(_activityHost);

            Assert.That(TestActivity.ActivityArgs.Input, Is.EqualTo(activityTask.Input));
            Assert.That(TestActivity.ActivityArgs.ActivityId, Is.EqualTo(activityTask.ActivityId));
            Assert.That(TestActivity.ActivityArgs.WorkflowId, Is.EqualTo(activityTask.WorkflowExecution.WorkflowId));
            Assert.That(TestActivity.ActivityArgs.WorkflowRunId, Is.EqualTo(activityTask.WorkflowExecution.RunId));
            Assert.That(TestActivity.ActivityArgs.TaskToken, Is.EqualTo(activityTask.TaskToken));
            Assert.That(TestActivity.ActivityArgs.StartedEventId, Is.EqualTo(activityTask.StartedEventId));
        }
示例#2
0
 private static WorkerTask NewWorkerTask()
 {
     return(WorkerTask.CreateFor(new ActivityTask()
     {
         ActivityType = new ActivityType()
         {
             Name = "ErrorThrowingActivity", Version = "1.0"
         },
         TaskToken = "token",
         WorkflowExecution = new WorkflowExecution()
         {
             RunId = "rid", WorkflowId = "wid"
         },
         Input = "input"
     }, Mock.Of <IHeartbeatSwfApi>()));
 }
示例#3
0
        public void By_default_execution_exception_are_not_handled()
        {
            var workerTask = WorkerTask.CreateFor(new ActivityTask
            {
                ActivityType = new ActivityType()
                {
                    Name = "ActivityThrowsException", Version = "1.0"
                },
                WorkflowExecution = new WorkflowExecution()
                {
                    RunId = "runid", WorkflowId = "wid"
                },
                TaskToken = "token"
            }, Mock.Of <IHeartbeatSwfApi>());
            var hostedActivities = new ActivityHost(_domain, new[] { typeof(ActivityThrowsException) });

            Assert.ThrowsAsync <InvalidOperationException>(async() => await workerTask.ExecuteFor(hostedActivities));
        }
示例#4
0
        public async Task On_execution_returns_activity_response_for_activity_task()
        {
            var workerTask = WorkerTask.CreateFor(new ActivityTask
            {
                ActivityType = new ActivityType()
                {
                    Name = "TestActivity", Version = "1.0"
                },
                WorkflowExecution = new WorkflowExecution()
                {
                    RunId = "runid", WorkflowId = "wid"
                },
                TaskToken = "token"
            }, Mock.Of <IHeartbeatSwfApi>());

            var response = await workerTask.ExecuteFor(_activityHost);

            Assert.That(response, Is.EqualTo(new ActivityCompleteResponse("token", "result")));
        }
示例#5
0
        public async Task Execution_exception_can_be_handled_to_retry()
        {
            var workerTask = WorkerTask.CreateFor(new ActivityTask
            {
                ActivityType = new ActivityType()
                {
                    Name = "ActivityThrowsException", Version = "1.0"
                },
                WorkflowExecution = new WorkflowExecution()
                {
                    RunId = "runid", WorkflowId = "wid"
                },
                TaskToken = "token"
            }, Mock.Of <IHeartbeatSwfApi>());
            var hostedActivities = new ActivityHost(_domain, new [] { typeof(ActivityThrowsException) });

            workerTask.SetErrorHandler(ErrorHandler.Default(e => ErrorAction.Retry));

            var response = await workerTask.ExecuteFor(hostedActivities);

            Assert.That(response, Is.EqualTo(new ActivityCompleteResponse("token", "result")));
        }