public async Task WorkflowStub_Signal() { await SyncContext.ClearAsync; // Use an untyped workflow stub to execute a workflow and then // verify that we're able to send signals to it. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub($"{nameof(TestWorkflowStub_Execute)}::wait-for-signals", new WorkflowOptions() { TaskList = CadenceTestHelper.TaskList }); await stub.StartAsync(); await TestWorkflowStub_Execute.WaitUntilRunningAsync(); await stub.SignalAsync("signal", "my-signal-1"); await stub.SignalAsync("signal", "my-signal-2"); var received = await stub.GetResultAsync <List <string> >(); Assert.Equal(2, received.Count); Assert.Contains("my-signal-1", received); Assert.Contains("my-signal-2", received); }
public async Task WorkflowStub_Attach() { await SyncContext.ClearAsync; // Use an untyped workflow stub to execute a workflow. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub(nameof(TestWorkflowStub_Execute), new WorkflowOptions() { TaskList = CadenceTestHelper.TaskList }); var execution = await stub.StartAsync("Jeff"); Assert.NotNull(execution); Assert.Equal("Hello Jeff!", await stub.GetResultAsync <string>()); // Now connect another stub to the workflow and verify that we // can use it to obtain the result. stub = client.NewUntypedWorkflowStub(execution.WorkflowId, execution.RunId); Assert.Equal("Hello Jeff!", await stub.GetResultAsync <string>()); // There's one more method override for attaching to an existing workflow. stub = client.NewUntypedWorkflowStub(execution); Assert.Equal("Hello Jeff!", await stub.GetResultAsync <string>()); }
public async Task WorkflowStub_Execute_Untyped() { await SyncContext.Clear; // Use an untyped workflow stub to execute a workflow that // returns a result in one step. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub("TestWorkflowStub_Execute::hello", new WorkflowOptions() { TaskList = CadenceTestHelper.TaskList }); Assert.Equal("Hello Jeff!", await stub.ExecuteAsync <string>("Jeff")); // Verify that we're not allowed to reuse the stub. await Assert.ThrowsAsync <InvalidOperationException>(async() => await stub.StartAsync("Jeff")); // Try this again with a workflow method that doesn't return a result. stub = client.NewUntypedWorkflowStub("TestWorkflowStub_Execute::nop", new WorkflowOptions() { TaskList = CadenceTestHelper.TaskList }); await stub.ExecuteAsync(); // Verify that we're not allowed to reuse the stub. await Assert.ThrowsAsync <InvalidOperationException>(async() => await stub.StartAsync("Jeff")); }
public async Task WorkflowStub_Query_Untyped() { await SyncContext.Clear; // Use an untyped workflow stub to execute a workflow and then // verify that we're able to send signals to it. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub("TestWorkflowStub_Execute[wait-for-queries]", new StartWorkflowOptions() { TaskQueue = TemporalTestHelper.TaskQueue }); await stub.StartAsync(); await TestWorkflowStub_Execute.WaitUntilRunningAsync(); Assert.Equal("Received: my-query-1", await stub.QueryAsync <string>("query", "my-query-1")); Assert.Equal("Received: my-query-2", await stub.QueryAsync <string>("query", "my-query-2")); var received = await stub.GetResultAsync <List <string> >(); Assert.Equal(2, received.Count); Assert.Contains("my-query-1", received); Assert.Contains("my-query-2", received); }
public async Task WorkflowStub_Execute() { await SyncContext.ClearAsync; // Use an untyped workflow stub to execute a workflow. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub(nameof(TestWorkflowStub_Execute), new WorkflowOptions() { TaskList = CadenceTestHelper.TaskList }); var execution = await stub.StartAsync("Jeff"); Assert.NotNull(execution); Assert.Equal("Hello Jeff!", await stub.GetResultAsync <string>()); // Verify that we're not allowed to reuse the stub. await Assert.ThrowsAsync <InvalidOperationException>(async() => await stub.StartAsync("Jeff")); }
public async Task WorkflowStub_Start_Untyped() { await SyncContext.Clear; // Use an untyped workflow stub to execute a workflow. TestWorkflowStub_Execute.Reset(); var stub = client.NewUntypedWorkflowStub("TestWorkflowStub_Execute[hello]", new StartWorkflowOptions() { TaskQueue = TemporalTestHelper.TaskQueue }); var execution = await stub.StartAsync("Jeff"); Assert.NotNull(execution); Assert.Equal("Hello Jeff!", await stub.GetResultAsync <string>()); // Verify that we're not allowed to reuse the stub. await Assert.ThrowsAsync <InvalidOperationException>(async() => await stub.StartAsync("Jeff")); }