예제 #1
0
        public void Error_WorkflowDuplicateDuplicateEntryPoints()
        {
            // Verify that we detect duplicate entrypoint methods
            // with explicit names.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IDuplicateEntryPointsWorkflow>(client));
        }
예제 #2
0
        public void Error_WorkflowNonTaskEntryPoint()
        {
            // Workflow entry points methods need to return a Task.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNonTaskEntryPointWorkflow1>(client));
            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNonTaskEntryPointWorkflow2>(client));
        }
예제 #3
0
        /// <summary>
        /// Creates a typed workflow stub that can be used to start as well as
        /// query and signal the workflow via the type-safe interface methods.
        /// </summary>
        /// <typeparam name="TWorkflowInterface">Identifies the workflow interface.</typeparam>
        /// <param name="options">Optionally specifies the workflow options.</param>
        /// <param name="workflowTypeName">
        /// Optionally specifies the workflow type name by overriding the fully
        /// qualified <typeparamref name="TWorkflowInterface"/> type name or the name
        /// specified by a <see cref="WorkflowAttribute"/>.
        /// </param>
        /// <returns>The dynamically generated stub that implements the workflow methods defined by <typeparamref name="TWorkflowInterface"/>.</returns>
        /// <remarks>
        /// <para>
        /// Unlike activity stubs, a workflow stub may only be used to launch a single
        /// workflow.  You'll need to create a new stub for each workflow you wish to
        /// invoke and then the first method called on a workflow stub must be
        /// the one of the methods tagged by <see cref="WorkflowMethodAttribute"/>.
        /// </para>
        /// <note>
        /// <para>
        /// .NET and Java workflows can implement multiple workflow method using attributes
        /// and annotations to assign unique names to each.  Each workflow method is actually
        /// registered with Cadence as a distinct workflow type.  Workflow methods with a blank
        /// or <c>null</c> name will simply be registered using the workflow type name.
        /// </para>
        /// <para>
        /// Workflow methods with a name will be registered using a combination  of the workflow
        /// type name and the method name, using <b>"::"</b> as the separator, like:
        /// </para>
        /// <code>
        /// WORKFLOW-TYPENAME::METHOD-NAME
        /// </code>
        /// </note>
        /// </remarks>
        public TWorkflowInterface NewWorkflowStub <TWorkflowInterface>(WorkflowOptions options = null, string workflowTypeName = null)
            where TWorkflowInterface : class
        {
            CadenceHelper.ValidateWorkflowInterface(typeof(TWorkflowInterface));
            EnsureNotDisposed();

            return(StubManager.NewWorkflowStub <TWorkflowInterface>(this, options: options, workflowTypeName: workflowTypeName));
        }
예제 #4
0
        public void Generate_WorkflowResultWithOptions()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowEntryResultWithArgs>(client, options: new WorkflowOptions()
            {
                TaskList = "my-tasklist", Domain = "my-domain"
            });

            Assert.NotNull(stub);
        }
예제 #5
0
        public void Generate_WorkflowResultWithOptions()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowEntryResultWithArgs>(client, options: new StartWorkflowOptions()
            {
                TaskQueue = "my-taskqueue", Namespace = "my-namespace"
            });

            Assert.NotNull(stub);
        }
예제 #6
0
        /// <summary>
        /// Creates a typed workflow stub connected to a known workflow execution
        /// using IDs.  This can be used to signal and query the workflow via the
        /// type-safe interface methods.
        /// </summary>
        /// <typeparam name="TWorkflowInterface">Identifies the workflow interface.</typeparam>
        /// <param name="workflowId">Specifies the workflow ID.</param>
        /// <param name="runId">Optionally specifies the workflow's run ID.</param>
        /// <param name="domain">Optionally specifies a domain that </param>
        /// <returns>The dynamically generated stub that implements the workflow methods defined by <typeparamref name="TWorkflowInterface"/>.</returns>
        /// <remarks>
        /// Unlike activity stubs, a workflow stub may only be used to launch a single
        /// workflow.  You'll need to create a new stub for each workflow you wish to
        /// invoke and then the first method called on a workflow stub must be
        /// the one of the methods tagged by <see cref="WorkflowMethodAttribute"/>.
        /// </remarks>
        public TWorkflowInterface NewWorkflowStub <TWorkflowInterface>(string workflowId, string runId = null, string domain = null)
            where TWorkflowInterface : class
        {
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(workflowId), nameof(workflowId));
            CadenceHelper.ValidateWorkflowInterface(typeof(TWorkflowInterface));
            EnsureNotDisposed();

            return(StubManager.NewWorkflowStub <TWorkflowInterface>(this, workflowId, runId, domain));
        }
예제 #7
0
        /// <summary>
        /// Creates a typed workflow stub connected to a known workflow execution
        /// using a <see cref="WorkflowExecution"/>.  This can be used to signal and
        /// query the workflow via the type-safe interface methods.
        /// </summary>
        /// <typeparam name="TWorkflowInterface">Identifies the workflow interface.</typeparam>
        /// <param name="execution">Specifies the <see cref="WorkflowExecution"/>.</param>
        /// <returns>The dynamically generated stub that implements the workflow methods defined by <typeparamref name="TWorkflowInterface"/>.</returns>
        /// <remarks>
        /// Unlike activity stubs, a workflow stub may only be used to launch a single
        /// workflow.  You'll need to create a new stub for each workflow you wish to
        /// invoke and then the first method called on a workflow stub must be
        /// the one of the methods tagged by <see cref="WorkflowMethodAttribute"/>.
        /// </remarks>
        public TWorkflowInterface NewWorkflowStub <TWorkflowInterface>(WorkflowExecution execution)
            where TWorkflowInterface : class
        {
            Covenant.Requires <ArgumentNullException>(execution != null, nameof(execution));
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(execution.WorkflowId), nameof(execution.WorkflowId));
            Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(execution.RunId), nameof(execution.RunId));
            CadenceHelper.ValidateWorkflowInterface(typeof(TWorkflowInterface));
            EnsureNotDisposed();

            return(StubManager.NewWorkflowStub <TWorkflowInterface>(this, execution.WorkflowId, execution.RunId));
        }
예제 #8
0
        public void Error_WorkflowNoEntryPoint()
        {
            // Workflows need to have at least one entry point.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNoEntryPointWorkflow>(client));
        }
예제 #9
0
        public void Error_WorkflowGenericsNotAllowed()
        {
            // We don't support workflow interfaces with generic parameters.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorGenericWorkflow <int> >(client));
        }
예제 #10
0
        public void Error_WorkflowDuplicateQueries()
        {
            // Verify that we detect duplicate query names.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorDuplicateQueriesWorkflow>(client));
        }
예제 #11
0
        public void Error_WorkflowNonTaskQuery()
        {
            // Workflow query methods need to return a Task.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNonTaskQueryWorkflow>(client));
        }
예제 #12
0
        public void Generate_WorkflowResultWithArgs()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowEntryResultWithArgs>(client);

            Assert.NotNull(stub);
        }
예제 #13
0
        public void Generate_WorkflowMultiMethods()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowMultiMethods>(client);

            Assert.NotNull(stub);
        }
예제 #14
0
        public void Generate_WorkflowQueryVoidWithArgs()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowQueryVoidWithArgs>(client);

            Assert.NotNull(stub);
        }
예제 #15
0
        public void Generate_WorkflowSignalNoArgs()
        {
            var stub = StubManager.NewWorkflowStub <IWorkflowSignalNoArgs>(client);

            Assert.NotNull(stub);
        }
예제 #16
0
        public void Error_WorkflowNullClient()
        {
            // A non-NULL client is required.

            Assert.Throws <ArgumentNullException>(() => StubManager.NewWorkflowStub <IErrorNoEntryPointWorkflow>(null));
        }
예제 #17
0
        public void Error_WorkflowNotInterface()
        {
            // Only workflow interfaces are allowed.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNotInterfaceWorkflow>(client));
        }
예제 #18
0
        public void Error_WorkflowNotPublic()
        {
            // Workflow interfaces must be public.

            Assert.Throws <WorkflowTypeException>(() => StubManager.NewWorkflowStub <IErrorNotPublicWorkflow>(client));
        }