示例#1
0
        public async Task Activity_ExternalCancelById()
        {
            await SyncContext.ClearAsync;

            // Verify that we can externally cancel an activity
            // using the workflow execution and the activity ID.

            ActivityExternalCompletion.Reset();

            var stub     = client.NewWorkflowStub <IWorkflowActivityExternalCompletion>();
            var task     = stub.RunAsync();
            var activity = ActivityExternalCompletion.WaitForActivity();

            await client.ActivityCancelByIdAsync(activity.Task.WorkflowExecution, activity.Task.ActivityId);

            // $todo(jefflill): Need to work on exception mapping for this to work.

            // await Assert.ThrowsAsync<CadenceCancelledException>(async () => await task);
        }
示例#2
0
        public async Task Activity_ExternalCompleteByToken()
        {
            await SyncContext.ClearAsync;

            // Verify that we can externally heartbeat and complete an activity
            // using its task token.

            ActivityExternalCompletion.Reset();

            var stub     = client.NewWorkflowStub <IWorkflowActivityExternalCompletion>();
            var task     = stub.RunAsync();
            var activity = ActivityExternalCompletion.WaitForActivity();

            await client.ActivityHeartbeatByTokenAsync(activity.Task.TaskToken);

            await client.ActivityHeartbeatByTokenAsync(activity.Task.TaskToken, "Heartbeat");

            await client.ActivityCompleteByTokenAsync(activity.Task.TaskToken, "Hello World!");

            Assert.Equal("Hello World!", await task);
        }
示例#3
0
        public async Task Activity_ExternalCompleteById()
        {
            await SyncContext.ClearAsync;

            // Verify that we can externally heartbeat and complete an activity
            // using the workflow execution and the activity ID.

            ActivityExternalCompletion.Reset();

            var stub     = client.NewWorkflowStub <IWorkflowActivityExternalCompletion>();
            var task     = stub.RunAsync();
            var activity = ActivityExternalCompletion.WaitForActivity();

            await client.ActivityHeartbeatByIdAsync(activity.Task.WorkflowExecution, activity.Task.ActivityId);

            await client.ActivityHeartbeatByIdAsync(activity.Task.WorkflowExecution, activity.Task.ActivityId, "Heartbeat");

            await client.ActivityCompleteByIdAsync(activity.Task.WorkflowExecution, activity.Task.ActivityId, "Hello World!");

            Assert.Equal("Hello World!", await task);
        }
示例#4
0
        public async Task Activity_ExternalErrorById()
        {
            await SyncContext.ClearAsync;

            // Verify that we can externally fail an activity
            // using the workflow execution and the activity ID.

            ActivityExternalCompletion.Reset();

            var stub     = client.NewWorkflowStub <IWorkflowActivityExternalCompletion>();
            var task     = stub.RunAsync();
            var activity = ActivityExternalCompletion.WaitForActivity();

            await client.ActivityErrorByIdAsync(activity.Task.WorkflowExecution, activity.Task.ActivityId, new Exception("error"));

            try
            {
                await task;
            }
            catch (Exception e)
            {
                // $todo(jefflill): Verify the exception
            }
        }