public async Task TestHostRetryTimeoutTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; var retryOptions = new RetryOptions(TimeSpan.FromSeconds(5), 10); retryOptions.BackoffCoefficient = 2; retryOptions.RetryTimeout = TimeSpan.FromSeconds(10); var retryTask = new RetryTask(3); testHost.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RETRY_NAME, RETRY_VERSION, () => new RetryOrchestration(retryOptions))) .AddTaskActivitiesFromInterface <IRetryTask>(retryTask); RetryOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(RETRY_NAME, RETRY_VERSION, false); Assert.IsTrue(result.StartsWith("DoWork Failed. RetryCount is:"), "Orchestration Result is wrong!!!. Result: " + result); Assert.IsTrue(RetryOrchestration.Result.StartsWith("DoWork Failed. RetryCount is:"), "Orchestration Result is wrong!!!. Result: " + RetryOrchestration.Result); Assert.IsTrue(retryTask.RetryCount < 4, "Retry Count is wrong. Count: " + retryTask.RetryCount); }
public async Task TestHostRetryCustomHandlerFailThroughProxyTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3); retryOptions.Handle = e => { Assert.IsInstanceOfType(e, typeof(TaskFailedException), "Exception is not TaskFailedException."); var taskFailed = (TaskFailedException)e; return(taskFailed.InnerException is ArgumentNullException); }; var retryTask = new RetryTask(2); testHost.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RETRY_NAME, RETRY_VERSION, () => new RetryOrchestration(retryOptions))) .AddTaskActivitiesFromInterface <IRetryTask>(retryTask); RetryOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(RETRY_NAME, RETRY_VERSION, true); Assert.AreEqual("DoWork Failed. RetryCount is: 1", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("DoWork Failed. RetryCount is: 1", RetryOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(1, retryTask.RetryCount, "Retry Count is wrong"); }
public async Task TestHostRetryOnReasonCustomHandlerTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3); retryOptions.Handle = e => { Assert.IsInstanceOfType(e, typeof(TaskFailedException), "Exception is not TaskFailedException."); var taskFailed = (TaskFailedException)e; Assert.IsInstanceOfType(taskFailed.InnerException, typeof(InvalidOperationException), "InnerException is not InvalidOperationException."); return(e.Message.StartsWith("DoWork Failed. RetryCount is:")); }; var retryTask = new RetryTask(2); testHost.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RETRY_NAME, RETRY_VERSION, () => new RetryOrchestration(retryOptions))) .AddTaskActivitiesFromInterface <IRetryTask>(retryTask); RetryOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(RETRY_NAME, RETRY_VERSION, false); Assert.AreEqual("DoWork Succeeded. Attempts: 2", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("DoWork Succeeded. Attempts: 2", RetryOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(2, retryTask.RetryCount, "Retry Count is wrong"); }
public async Task AverageCalculatorWrongNumberOfArgs() { OrchestrationTestHost host = new OrchestrationTestHost(); host.AddTaskOrchestrations(typeof(AverageCalculatorOrchestration)); host.AddTaskActivities(typeof(ComputeSumTask)); var result = await host.RunOrchestration<double>(typeof(AverageCalculatorOrchestration), new int[] { 1, 50 }); Assert.AreEqual<double>(25, result); }
public async Task AverageCalculatorWrongNumberOfArgs() { OrchestrationTestHost host = new OrchestrationTestHost(); host.AddTaskOrchestrations(typeof(AverageCalculatorOrchestration)); host.AddTaskActivities(typeof(ComputeSumTask)); var result = await host.RunOrchestration <double>(typeof(AverageCalculatorOrchestration), new int[] { 1, 50 }); Assert.AreEqual <double>(25, result); }
public async Task TestHostSubOrchestrationExplicitIdTest() { SimpleChildWorkflow.ChildInstanceId = null; var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(SimpleParentWorkflow), typeof(SimpleChildWorkflow)); object res = await testHost.RunOrchestration <object>(typeof(SimpleParentWorkflow), null); Assert.AreEqual("foo_instance", SimpleChildWorkflow.ChildInstanceId); }
public async Task TestHostGreetingsTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(GreetingsOrchestration)) .AddTaskActivities(new GetUserTask(), new SendGreetingTask()); string result = await testHost.RunOrchestration <string>(typeof(GreetingsOrchestration), null); Assert.AreEqual("Greeting send to Gabbar", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting send to Gabbar", GreetingsOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostErrorHandlingTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(ErrorHandlingOrchestration)) .AddTaskActivities(new GoodTask(), new BadTask(), new CleanupTask()); string result = await testHost.RunOrchestration <string>(typeof(ErrorHandlingOrchestration), null); Assert.AreEqual("CleanupResult", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("CleanupResult", ErrorHandlingOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostAverageCalculatorTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(AverageCalculatorOrchestration)) .AddTaskActivities(new ComputeSumTask()); double result = await testHost.RunOrchestration <double>(typeof(AverageCalculatorOrchestration), new[] { 1, 50, 10 }); Assert.AreEqual(25, result, "Orchestration Result is wrong!!!"); Assert.AreEqual(25, AverageCalculatorOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostGenerationBasicTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(GenerationBasicOrchestration)) .AddTaskActivities(new GenerationBasicTask()); GenerationBasicOrchestration.Result = 0; GenerationBasicTask.GenerationCount = 0; int result = await testHost.RunOrchestration <int>(typeof(GenerationBasicOrchestration), 4); Assert.AreEqual(4, result, "Orchestration Result is wrong!!!"); Assert.AreEqual(4, GenerationBasicOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostGreetings2Test() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(GreetingsOrchestration2)) .AddTaskActivities(new GetUserTask2(() => { testHost.Delay(2 * 1000).Wait(); }), new SendGreetingTask()); string result = await testHost.RunOrchestration <string>(typeof(GreetingsOrchestration2), 3); Assert.AreEqual("Greeting send to Gabbar", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting send to Gabbar", GreetingsOrchestration2.Result, "Orchestration Result is wrong!!!"); result = await testHost.RunOrchestration <string>(typeof(GreetingsOrchestration2), 1); Assert.AreEqual("Greeting send to TimedOut", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting send to TimedOut", GreetingsOrchestration2.Result, "Orchestration Result is wrong!!!"); }
public async Task CronBasic() { OrchestrationTestHost host = new OrchestrationTestHost(); host.ClockSpeedUpFactor = 5; MockCronTask cronTask = new MockCronTask(); host.AddTaskOrchestrations(typeof(CronOrchestration)) .AddTaskActivities(new MockObjectCreator <TaskActivity>(typeof(CronTask).ToString(), string.Empty, () => { return(cronTask); })); var result = await host.RunOrchestration <string>(typeof(CronOrchestration), null); Assert.AreEqual <string>("Done", result); Assert.AreEqual <double>(4, MockCronTask.Count); }
public async Task TestHostBasicRetryFailTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3); var retryTask = new RetryTask(3); testHost.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RETRY_NAME, RETRY_VERSION, () => new RetryOrchestration(retryOptions))) .AddTaskActivitiesFromInterface <IRetryTask>(retryTask); RetryOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(RETRY_NAME, RETRY_VERSION, false); Assert.AreEqual("DoWork Failed. RetryCount is: 3", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("DoWork Failed. RetryCount is: 3", RetryOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task AsyncDynamicProxyGreetingsTestHostTest() { AsyncDynamicGreetingsOrchestration.Result = null; AsyncDynamicGreetingsOrchestration.Result2 = null; var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(AsyncDynamicGreetingsOrchestration)) .AddTaskActivitiesFromInterface <IGreetings2>(new GreetingsManager2(), true) .AddTaskActivitiesFromInterface <IGreetings>(new GreetingsManager(), true); string result = await testHost.RunOrchestration <string>(typeof(AsyncDynamicGreetingsOrchestration), null); Assert.AreEqual("Greeting send to Gabbar", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting send to Gabbar", AsyncDynamicGreetingsOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting NOT sent to Samba", AsyncDynamicGreetingsOrchestration.Result2, "Orchestration Result is wrong!!!"); }
public async Task TestHostCronTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; testHost.AddTaskOrchestrations(typeof(CronOrchestration)) .AddTaskActivities(new CronTask(() => { testHost.Delay(2 * 1000).Wait(); })); CronTask.Result = 0; string result = await testHost.RunOrchestration <string>(typeof(CronOrchestration), new CronJob { Frequency = RecurrenceFrequency.Second, Count = 5, Interval = 3, }); Assert.AreEqual(5, CronTask.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Done", result, "Orchestration Result is wrong!!!"); Assert.AreEqual(5, CronOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostGenerationVersionTest() { var c1 = new NameValueObjectCreator <TaskOrchestration>("GenerationOrchestration", "V1", typeof(GenerationV1Orchestration)); var c2 = new NameValueObjectCreator <TaskOrchestration>("GenerationOrchestration", "V2", typeof(GenerationV2Orchestration)); var c3 = new NameValueObjectCreator <TaskOrchestration>("GenerationOrchestration", "V3", typeof(GenerationV3Orchestration)); var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(c1, c2, c3); object res = await testHost.RunOrchestration <object>("GenerationOrchestration", "V1", null); Assert.IsTrue(GenerationV1Orchestration.WasRun); Assert.IsTrue(GenerationV2Orchestration.WasRun); Assert.IsTrue(GenerationV3Orchestration.WasRun); }
public async Task TestHostSubOrchestrationFailedTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(ParentWorkflow2), typeof(ChildWorkflow2)); ChildWorkflow2.Count = 0; ParentWorkflow2.Result = null; string result = await testHost.RunOrchestration <string>(typeof(ParentWorkflow2), true); Assert.AreEqual("Test", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Test", ParentWorkflow2.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(1, ChildWorkflow2.Count, "Child Workflow Count invalid."); ChildWorkflow2.Count = 0; ParentWorkflow2.Result = null; result = await testHost.RunOrchestration <string>(typeof(ParentWorkflow2), false); Assert.AreEqual("Test", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Test", ParentWorkflow2.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(5, ChildWorkflow2.Count, "Child Workflow Count invalid."); }
public async Task TestHostSignalTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(SignalOrchestration)) .AddTaskActivities(new SendGreetingTask()); var instance = new OrchestrationInstance { InstanceId = "Test" }; Task.Factory.StartNew(() => { testHost.Delay(2 * 1000).Wait(); testHost.RaiseEvent(instance, "GetUser", "Gabbar"); } ); string result = await testHost.RunOrchestration <string>(instance, typeof(SignalOrchestration), null); Assert.AreEqual("Greeting send to Gabbar", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Greeting send to Gabbar", SignalOrchestration.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostSubOrchestrationTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(ParentWorkflow), typeof(ChildWorkflow)); string result = await testHost.RunOrchestration <string>(typeof(ParentWorkflow), true); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", result, "Orchestration Result is wrong!!!"); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", ParentWorkflow.Result, "Orchestration Result is wrong!!!"); result = await testHost.RunOrchestration <string>(typeof(ParentWorkflow), false); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", result, "Orchestration Result is wrong!!!"); Assert.AreEqual( "Child '0' completed.Child '1' completed.Child '2' completed.Child '3' completed.Child '4' completed.", ParentWorkflow.Result, "Orchestration Result is wrong!!!"); }
public async Task TestHostRetryMaxIntervalTest() { var testHost = new OrchestrationTestHost(); testHost.ClockSpeedUpFactor = 10; var retryOptions = new RetryOptions(TimeSpan.FromSeconds(3), 3); retryOptions.BackoffCoefficient = 10; retryOptions.MaxRetryInterval = TimeSpan.FromSeconds(5); var retryTask = new RetryTask(2); testHost.AddTaskOrchestrations(new TestObjectCreator <TaskOrchestration>(RETRY_NAME, RETRY_VERSION, () => new RetryOrchestration(retryOptions))) .AddTaskActivitiesFromInterface <IRetryTask>(retryTask); RetryOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(RETRY_NAME, RETRY_VERSION, false); Assert.AreEqual("DoWork Succeeded. Attempts: 2", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("DoWork Succeeded. Attempts: 2", RetryOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(2, retryTask.RetryCount, "Retry Count is wrong"); }
public async Task TestHostGenerationSubFailedTest() { var testHost = new OrchestrationTestHost(); testHost.AddTaskOrchestrations(typeof(GenerationSubFailedParentOrchestration), typeof(GenerationSubFailedChildOrchestration)); GenerationSubFailedChildOrchestration.Count = 0; GenerationSubFailedParentOrchestration.Result = null; string result = await testHost.RunOrchestration <string>(typeof(GenerationSubFailedParentOrchestration), true); Assert.AreEqual("Test", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Test", GenerationSubFailedParentOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(1, GenerationSubFailedChildOrchestration.Count, "Child Workflow Count invalid."); GenerationSubFailedChildOrchestration.Count = 0; GenerationSubFailedParentOrchestration.Result = null; result = await testHost.RunOrchestration <string>(typeof(GenerationSubFailedParentOrchestration), false); Assert.AreEqual("Test", result, "Orchestration Result is wrong!!!"); Assert.AreEqual("Test", GenerationSubFailedParentOrchestration.Result, "Orchestration Result is wrong!!!"); Assert.AreEqual(5, GenerationSubFailedChildOrchestration.Count, "Child Workflow Count invalid."); }