示例#1
0
        public async Task RecurringOrchestrationTest()
        {
            var instanceId = nameof(RecurringOrchestration);
            var input      = new RecurringOrchestrationInput
            {
                TargetOrchestrationInput      = "1",
                TargetOrchestrationType       = typeof(RecurringTargetOrchestration).ToString(),
                TargetOrchestrationInstanceId = nameof(RecurringTargetOrchestration)
            };
            var instance = await this.taskHubClient.CreateOrchestrationInstanceAsync(typeof(RecurringOrchestration), instanceId, input);

            await Task.Delay(TimeSpan.FromSeconds(1));

            var result = await this.taskHubClient.GetOrchestrationStateAsync(input.TargetOrchestrationInstanceId, false);

            Assert.AreNotEqual("4", result[0].Output, "Orchestration Result is wrong!!!");

            OrchestrationState state;

            do
            {
                state = await this.taskHubClient.GetOrchestrationStateAsync(instanceId);

                await Task.Delay(TimeSpan.FromSeconds(1));
            } while (state.OrchestrationStatus != OrchestrationStatus.Completed);

            Assert.AreEqual(OrchestrationStatus.Completed, state.OrchestrationStatus);
            Assert.AreEqual("4", state.Output, "Orchestration Result is wrong!!!");
        }
示例#2
0
        public async Task RecurringOrchestrationTest()
        {
            var instanceId = nameof(RecurringOrchestration);
            var input      = new RecurringOrchestrationInput
            {
                TargetOrchestrationInput      = 0,
                TargetOrchestrationType       = typeof(RecurringTargetOrchestration).ToString(),
                TargetOrchestrationInstanceId = nameof(RecurringTargetOrchestration)
            };
            var firstInstance = await this.taskHubClient.CreateOrchestrationInstanceAsync(typeof(RecurringOrchestration), instanceId, input);

            // Parent orchestration runs for 4 times with ContinueAsNew and executes the
            // RecurringTargetOrchestration each time by incrementing the counter

            // 1. Check if the first iteration of parent orchestration ends with ContinuedAsNew
            // firstInstance : Includes instanceId and first iteration executionId
            OrchestrationState state = await this.taskHubClient.WaitForOrchestrationAsync(firstInstance, TimeSpan.FromSeconds(30));

            Assert.AreEqual(OrchestrationStatus.ContinuedAsNew, state.OrchestrationStatus);

            // 2. Check if the last instance of the parent orchestration completes with Completed
            var lastInstance = new OrchestrationInstance()
            {
                InstanceId  = instanceId,
                ExecutionId = null
            };

            state = await this.taskHubClient.WaitForOrchestrationAsync(lastInstance, TimeSpan.FromMinutes(1));

            if (state.OrchestrationStatus == OrchestrationStatus.Running)
            {
                await this.taskHubClient.TerminateInstanceAsync(lastInstance);
            }

            Assert.AreEqual(OrchestrationStatus.Completed, state.OrchestrationStatus);
            Assert.AreEqual("4", state.Output, "Parent Orchestration Result is wrong!!!");
        }