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)); }
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>())); }
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)); }
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"))); }
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"))); }