From bcf53b607435158b7ea6e8afe3cf90b19c88bf2f Mon Sep 17 00:00:00 2001 From: stidsborg Date: Sun, 3 Nov 2024 10:48:44 +0100 Subject: [PATCH] Added FlowIdCanBeExtractedFromWorkflowInstance-test --- .../RFunctionTests/SunshineTests.cs | 4 +++ .../RFunctionTests/SunshineTests.cs | 27 +++++++++++++++++++ .../RFunctionTests/SunshineTests.cs | 4 +++ .../RFunctionTests/SunshineTests.cs | 4 +++ .../RFunctionTests/SunshineTests.cs | 4 +++ 5 files changed, 43 insertions(+) diff --git a/Core/Cleipnir.ResilientFunctions.Tests/InMemoryTests/RFunctionTests/SunshineTests.cs b/Core/Cleipnir.ResilientFunctions.Tests/InMemoryTests/RFunctionTests/SunshineTests.cs index b391e70e..529797dd 100644 --- a/Core/Cleipnir.ResilientFunctions.Tests/InMemoryTests/RFunctionTests/SunshineTests.cs +++ b/Core/Cleipnir.ResilientFunctions.Tests/InMemoryTests/RFunctionTests/SunshineTests.cs @@ -59,4 +59,8 @@ public override Task EffectsAreNotFetchedOnFirstInvocation() [TestMethod] public override Task EffectsAreFetchedOnSecondInvocation() => EffectsAreFetchedOnSecondInvocation(FunctionStoreFactory.Create()); + + [TestMethod] + public override Task FlowIdCanBeExtractedFromWorkflowInstance() + => FlowIdCanBeExtractedFromWorkflowInstance(FunctionStoreFactory.Create()); } \ No newline at end of file diff --git a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/RFunctionTests/SunshineTests.cs b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/RFunctionTests/SunshineTests.cs index 4cb87100..33413ac7 100644 --- a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/RFunctionTests/SunshineTests.cs +++ b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/RFunctionTests/SunshineTests.cs @@ -471,4 +471,31 @@ await BusyWait.Until( controlPanel.Status.ShouldBe(Status.Failed); } + + public abstract Task FlowIdCanBeExtractedFromWorkflowInstance(); + public async Task FlowIdCanBeExtractedFromWorkflowInstance(Task storeTask) + { + var store = await storeTask; + var flowType = nameof(SunshineScenarioFunc).ToFlowType(); + var flowInstance = Guid.NewGuid().ToString(); + + var unhandledExceptionHandler = new UnhandledExceptionCatcher(); + + using var functionsRegistry = new FunctionsRegistry(store, new Settings(unhandledExceptionHandler.Catch)); + + FlowId? flowId = null; + var reg = functionsRegistry + .RegisterParamless( + flowType, + workflow => + { + flowId = workflow.FlowId; + return Task.CompletedTask; + } + ); + await reg.Invoke(flowInstance); + + flowId.ShouldBe(new FlowId(flowType, flowInstance)); + unhandledExceptionHandler.ShouldNotHaveExceptions(); + } } \ No newline at end of file diff --git a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/RFunctionTests/SunshineTests.cs b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/RFunctionTests/SunshineTests.cs index cf80d380..190eecb9 100644 --- a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/RFunctionTests/SunshineTests.cs +++ b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/RFunctionTests/SunshineTests.cs @@ -56,4 +56,8 @@ public override Task EffectsAreNotFetchedOnFirstInvocation() [TestMethod] public override Task EffectsAreFetchedOnSecondInvocation() => EffectsAreFetchedOnSecondInvocation(FunctionStoreFactory.Create()); + + [TestMethod] + public override Task FlowIdCanBeExtractedFromWorkflowInstance() + => FlowIdCanBeExtractedFromWorkflowInstance(FunctionStoreFactory.Create()); } \ No newline at end of file diff --git a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/RFunctionTests/SunshineTests.cs b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/RFunctionTests/SunshineTests.cs index 87cb6e55..407e65c3 100644 --- a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/RFunctionTests/SunshineTests.cs +++ b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/RFunctionTests/SunshineTests.cs @@ -57,4 +57,8 @@ public override Task EffectsAreNotFetchedOnFirstInvocation() [TestMethod] public override Task EffectsAreFetchedOnSecondInvocation() => EffectsAreFetchedOnSecondInvocation(FunctionStoreFactory.Create()); + + [TestMethod] + public override Task FlowIdCanBeExtractedFromWorkflowInstance() + => FlowIdCanBeExtractedFromWorkflowInstance(FunctionStoreFactory.Create()); } \ No newline at end of file diff --git a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/RFunctionTests/SunshineTests.cs b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/RFunctionTests/SunshineTests.cs index 60effabe..028e23b2 100644 --- a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/RFunctionTests/SunshineTests.cs +++ b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/RFunctionTests/SunshineTests.cs @@ -57,4 +57,8 @@ public override Task EffectsAreNotFetchedOnFirstInvocation() [TestMethod] public override Task EffectsAreFetchedOnSecondInvocation() => EffectsAreFetchedOnSecondInvocation(FunctionStoreFactory.Create()); + + [TestMethod] + public override Task FlowIdCanBeExtractedFromWorkflowInstance() + => FlowIdCanBeExtractedFromWorkflowInstance(FunctionStoreFactory.Create()); } \ No newline at end of file