@@ -415,5 +415,94 @@ public void WorkerRuntimeTypeFollowsSpec(string workerRuntime)
415415 runtimeType . ToString ( ) . Equals ( workerRuntime , StringComparison . OrdinalIgnoreCase ) ;
416416 }
417417 }
418+
419+ [ Theory ]
420+ [ InlineData ( false , "2.0" , null , "MySubOrchestrator\n 2.0" ) ] // Explicit version
421+ [ InlineData ( false , null , null , "MySubOrchestrator" ) ] // Null version - no delimiter
422+ [ InlineData ( false , "" , null , "MySubOrchestrator\n " ) ] // Empty version - delimiter included
423+ [ InlineData ( false , "1.0.0" , null , "MySubOrchestrator\n 1.0.0" ) ] // Semantic version
424+ [ InlineData ( false , "4.5.6-preview" , null , "MySubOrchestrator\n 4.5.6-preview" ) ] // Pre-release version
425+ [ InlineData ( false , "2.0-beta.1" , null , "MySubOrchestrator\n 2.0-beta.1" ) ] // Beta version
426+ [ InlineData ( false , "v1.2.3" , null , "MySubOrchestrator\n v1.2.3" ) ] // Version with prefix
427+ [ InlineData ( true , "3.5.1" , null , "MySubOrchestrator\n 3.5.1" ) ] // Explicit version with retry
428+ [ InlineData ( true , null , null , "MySubOrchestrator" ) ] // Null version with retry
429+ [ InlineData ( false , "5.0" , "V2" , "MySubOrchestrator\n 5.0" ) ] // Schema V2
430+ [ InlineData ( false , "5.0" , "V3" , "MySubOrchestrator\n 5.0" ) ] // Schema V3
431+ [ Trait ( "Category" , PlatformSpecificHelpers . TestCategory ) ]
432+ public async Task CallSubOrchestrator_VersionHandling_OutOfProc ( bool withRetry , string version , string schemaVersion , string expectedFunctionName )
433+ {
434+ string capturedFunctionName = null ;
435+ RetryOptions capturedRetryOptions = null ;
436+
437+ // Mock the CallSubOrchestratorAsync or CallSubOrchestratorWithRetryAsync API
438+ var contextMock = new Mock < IDurableOrchestrationContext > ( ) ;
439+
440+ if ( withRetry )
441+ {
442+ contextMock
443+ . Setup ( ctx => ctx . CallSubOrchestratorWithRetryAsync (
444+ It . IsAny < string > ( ) ,
445+ It . IsAny < RetryOptions > ( ) ,
446+ It . IsAny < string > ( ) ,
447+ It . IsAny < object > ( ) ) )
448+ . Callback < string , RetryOptions , string , object > ( ( name , retry , instanceId , input ) =>
449+ {
450+ capturedFunctionName = name ;
451+ capturedRetryOptions = retry ;
452+ } )
453+ . Returns ( Task . CompletedTask ) ;
454+ }
455+ else
456+ {
457+ contextMock
458+ . Setup ( ctx => ctx . CallSubOrchestratorAsync (
459+ It . IsAny < string > ( ) ,
460+ It . IsAny < string > ( ) ,
461+ It . IsAny < object > ( ) ) )
462+ . Callback < string , string , object > ( ( name , instanceId , input ) =>
463+ capturedFunctionName = name )
464+ . Returns ( Task . CompletedTask ) ;
465+ }
466+
467+ var shim = new OutOfProcOrchestrationShim ( contextMock . Object ) ;
468+
469+ var actionType = withRetry ? "CallSubOrchestratorWithRetry" : "CallSubOrchestrator" ;
470+ var versionField = version == null ? string . Empty : $@ """version"": ""{ version } "",";
471+ var schemaVersionField = schemaVersion == null ? string . Empty : $@ """schemaVersion"": ""{ schemaVersion } "",";
472+ var retryField = withRetry ? @"""retryOptions"": {
473+ ""firstRetryIntervalInMilliseconds"": 1000,
474+ ""maxNumberOfAttempts"": 3
475+ }," : string . Empty ;
476+
477+ var executionJson = $@ "
478+ {{
479+ ""isDone"": false,
480+ { schemaVersionField }
481+ ""actions"": [
482+ [{{
483+ ""actionType"": ""{ actionType } "",
484+ ""functionName"": ""MySubOrchestrator"",
485+ { versionField }
486+ ""instanceId"": ""test-instance"",
487+ { retryField }
488+ ""input"": null
489+ }}]
490+ ]
491+ }}" ;
492+
493+ var jsonObject = JObject . Parse ( executionJson ) ;
494+ OrchestrationInvocationResult result = new OrchestrationInvocationResult ( jsonObject ) ;
495+ bool moreWork = await shim . ScheduleDurableTaskEvents ( result ) ;
496+
497+ Assert . True ( moreWork ) ;
498+ Assert . NotNull ( capturedFunctionName ) ;
499+ Assert . Equal ( expectedFunctionName , capturedFunctionName ) ;
500+
501+ if ( withRetry )
502+ {
503+ Assert . NotNull ( capturedRetryOptions ) ;
504+ Assert . Equal ( 3 , capturedRetryOptions . MaxNumberOfAttempts ) ;
505+ }
506+ }
418507 }
419508}
0 commit comments