@@ -347,9 +347,11 @@ public async Task RestartAsync_EndToEnd(bool restartWithNewInstanceId)
347347 . Setup ( x => x . GetOrchestrationStateAsync ( originalInstanceId , false ) )
348348 . ReturnsAsync ( new List < Core . OrchestrationState > { originalState } ) ;
349349
350- // Setup the mock for the new orchestration creation
350+ // Capture the TaskMessage for verification becasue we will create this message at RestartAsync.
351+ TaskMessage ? capturedMessage = null ;
351352 this . orchestrationClient
352353 . Setup ( x => x . CreateTaskOrchestrationAsync ( It . IsAny < TaskMessage > ( ) ) )
354+ . Callback < TaskMessage > ( msg => capturedMessage = msg )
353355 . Returns ( Task . CompletedTask ) ;
354356
355357 string restartedInstanceId = await this . client . RestartAsync ( originalInstanceId , restartWithNewInstanceId ) ;
@@ -363,16 +365,21 @@ public async Task RestartAsync_EndToEnd(bool restartWithNewInstanceId)
363365 restartedInstanceId . Should ( ) . Be ( originalInstanceId ) ;
364366 }
365367
366- // Verify that CreateTaskOrchestrationAsync was called with the correct parameters
368+ // Verify that CreateTaskOrchestrationAsync was called
367369 this . orchestrationClient . Verify (
368- x => x . CreateTaskOrchestrationAsync ( It . Is < TaskMessage > ( msg =>
369- msg . Event is ExecutionStartedEvent startedEvent &&
370- startedEvent . Name == orchestratorName &&
371- startedEvent . Input == serializedInput &&
372- ( restartWithNewInstanceId ?
373- msg . OrchestrationInstance . InstanceId != originalInstanceId :
374- msg . OrchestrationInstance . InstanceId == originalInstanceId ) ) ) ,
370+ x => x . CreateTaskOrchestrationAsync ( It . IsAny < TaskMessage > ( ) ) ,
375371 Times . Once ) ;
372+
373+ // Verify the captured message details
374+ capturedMessage . Should ( ) . NotBeNull ( ) ;
375+ capturedMessage ! . Event . Should ( ) . BeOfType < ExecutionStartedEvent > ( ) ;
376+
377+ var startedEvent = ( ExecutionStartedEvent ) capturedMessage . Event ;
378+ startedEvent . Name . Should ( ) . Be ( orchestratorName ) ;
379+ startedEvent . Input . Should ( ) . Be ( serializedInput ) ;
380+ startedEvent . OrchestrationInstance . InstanceId . Should ( ) . Be ( restartedInstanceId ) ;
381+ startedEvent . OrchestrationInstance . ExecutionId . Should ( ) . NotBeNullOrEmpty ( ) ;
382+ startedEvent . OrchestrationInstance . ExecutionId . Should ( ) . NotBe ( originalState . OrchestrationInstance . ExecutionId ) ;
376383 }
377384
378385 [ Fact ]
0 commit comments