public async Task MockTimerTest() { LocalOrchestrationService orchService = new LocalOrchestrationService(); TaskHubWorker worker = new TaskHubWorker(orchService); await worker.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration)) .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask)) .StartAsync(); TaskHubClient client = new TaskHubClient(orchService); OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(SimplestGreetingsOrchestration), "6"); Stopwatch sw = Stopwatch.StartNew(); OrchestrationState result = await client.WaitForOrchestrationAsync(id, TimeSpan.FromSeconds(40), new CancellationToken()); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.IsTrue(sw.Elapsed.Seconds > 6); Assert.AreEqual("Greeting send to Gabbar", SimplestGreetingsOrchestration.Result, "Orchestration Result is wrong!!!"); await worker.StopAsync(true); }
public async Task MockRecreateOrchestrationTest() { LocalOrchestrationService orchService = new LocalOrchestrationService(); TaskHubWorker worker = new TaskHubWorker(orchService); await worker.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration)) .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask)) .StartAsync(); TaskHubClient client = new TaskHubClient(orchService); OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(SimplestGreetingsOrchestration), null); OrchestrationState result = await client.WaitForOrchestrationAsync(id, TimeSpan.FromSeconds(30), new CancellationToken()); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); await Assert.ThrowsExceptionAsync <OrchestrationAlreadyExistsException>(() => client.CreateOrchestrationInstanceAsync(typeof(SimplestGreetingsOrchestration), id.InstanceId, null)); await Assert.ThrowsExceptionAsync <OrchestrationAlreadyExistsException>(() => client.CreateOrchestrationInstanceAsync(typeof(SimplestGreetingsOrchestration), id.InstanceId, null, new OrchestrationStatus[] { OrchestrationStatus.Completed })); SimplestGreetingsOrchestration.Result = String.Empty; OrchestrationInstance id2 = await client.CreateOrchestrationInstanceAsync(typeof(SimplestGreetingsOrchestration), id.InstanceId, null, new OrchestrationStatus[] {}); result = await client.WaitForOrchestrationAsync(id2, TimeSpan.FromSeconds(30), new CancellationToken()); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.AreEqual("Greeting send to Gabbar", SimplestGreetingsOrchestration.Result, "Orchestration Result on Re-Create is wrong!!!"); await worker.StopAsync(true); }
public async Task MockSuborchestrationTest() { LocalOrchestrationService orchService = new LocalOrchestrationService(); TaskHubWorker worker = new TaskHubWorker(orchService); TaskHubClient client = new TaskHubClient(orchService); await worker.AddTaskOrchestrations(typeof(ParentWorkflow), typeof(ChildWorkflow)) .StartAsync(); OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(ParentWorkflow), true); OrchestrationState result = await client.WaitForOrchestrationAsync(id, TimeSpan.FromSeconds(40), CancellationToken.None); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", ParentWorkflow.Result, "Orchestration Result is wrong!!!"); ParentWorkflow.Result = string.Empty; id = await client.CreateOrchestrationInstanceAsync(typeof(ParentWorkflow), false); result = await client.WaitForOrchestrationAsync(id, TimeSpan.FromSeconds(40), CancellationToken.None); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", ParentWorkflow.Result, "Orchestration Result is wrong!!!"); await worker.StopAsync(true); }
public async Task MockGenerationTest() { GenerationBasicOrchestration.Result = 0; GenerationBasicTask.GenerationCount = 0; LocalOrchestrationService orchService = new LocalOrchestrationService(); TaskHubWorker worker = new TaskHubWorker(orchService); TaskHubClient client = new TaskHubClient(orchService); await worker.AddTaskOrchestrations(typeof(GenerationBasicOrchestration)) .AddTaskActivities(new GenerationBasicTask()) .StartAsync(); OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync(typeof(GenerationBasicOrchestration), 4); // strip out the eid so we wait for the latest one always OrchestrationInstance masterid = new OrchestrationInstance { InstanceId = id.InstanceId }; OrchestrationState result1 = await client.WaitForOrchestrationAsync(id, TimeSpan.FromSeconds(10), CancellationToken.None); OrchestrationState result2 = await client.WaitForOrchestrationAsync(masterid, TimeSpan.FromSeconds(20), CancellationToken.None); Assert.AreEqual(OrchestrationStatus.ContinuedAsNew, result1.OrchestrationStatus); Assert.AreEqual(OrchestrationStatus.Completed, result2.OrchestrationStatus); Assert.AreEqual(4, GenerationBasicOrchestration.Result, "Orchestration Result is wrong!!!"); }
public ExceptionHandlingIntegrationTests() { var service = new LocalOrchestrationService(); this.worker = new TaskHubWorker(service); this.client = new TaskHubClient(service); }
public async Task MockRaiseEventTest() { LocalOrchestrationService orchService = new LocalOrchestrationService(); TaskHubWorker worker = new TaskHubWorker(orchService); TaskHubClient client = new TaskHubClient(orchService); await worker.AddTaskOrchestrations(typeof(GenerationSignalOrchestration)) .StartAsync(); OrchestrationInstance id = await client.CreateOrchestrationInstanceAsync( typeof(GenerationSignalOrchestration), 5); var signalId = new OrchestrationInstance { InstanceId = id.InstanceId }; await Task.Delay(2 * 500); await client.RaiseEventAsync(signalId, "Count", "1"); GenerationSignalOrchestration.signal.Set(); await Task.Delay(2 * 500); GenerationSignalOrchestration.signal.Reset(); await client.RaiseEventAsync(signalId, "Count", "2"); await Task.Delay(2 * 500); await client.RaiseEventAsync(signalId, "Count", "3"); // will be recieved by next generation GenerationSignalOrchestration.signal.Set(); await Task.Delay(2 * 500); GenerationSignalOrchestration.signal.Reset(); await client.RaiseEventAsync(signalId, "Count", "4"); await Task.Delay(2 * 500); await client.RaiseEventAsync(signalId, "Count", "5"); // will be recieved by next generation await client.RaiseEventAsync(signalId, "Count", "6"); // lost await client.RaiseEventAsync(signalId, "Count", "7"); // lost GenerationSignalOrchestration.signal.Set(); OrchestrationState result = await client.WaitForOrchestrationAsync(new OrchestrationInstance { InstanceId = id.InstanceId }, TimeSpan.FromSeconds(40), CancellationToken.None); Assert.AreEqual(OrchestrationStatus.Completed, result.OrchestrationStatus); Assert.AreEqual("5", GenerationSignalOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task Initialize() { var service = new LocalOrchestrationService(); this.worker = new TaskHubWorker(service); await this.worker .AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration)) .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask)) .StartAsync(); this.client = new TaskHubClient(service); }
public EmulatorDurabilityProviderFactory() { var service = new LocalOrchestrationService(); this.provider = new DurabilityProvider("emulator", service, service, "emulator"); }