@@ -202,6 +202,67 @@ public async Task OrchestratationContextHasAllExpectedProperties()
202202 }
203203 }
204204
205+
206+ [ Fact ]
207+ public async Task ComplexExternalEventReturnsData ( )
208+ {
209+ var initialResponse = await Utilities . GetHttpTriggerResponse ( "DurableClient" , queryString : "?FunctionName=DurableOrchestratorComplexRaiseEvent" ) ;
210+ Assert . Equal ( HttpStatusCode . Accepted , initialResponse . StatusCode ) ;
211+
212+ var initialResponseBody = await initialResponse . Content . ReadAsStringAsync ( ) ;
213+ dynamic initialResponseBodyObject = JsonConvert . DeserializeObject ( initialResponseBody ) ;
214+ var statusQueryGetUri = ( string ) initialResponseBodyObject . statusQueryGetUri ;
215+ var raiseEventUri = ( string ) initialResponseBodyObject . sendEventPostUri ;
216+
217+ raiseEventUri = raiseEventUri . Replace ( "{eventName}" , "TESTEVENTNAME" ) ;
218+
219+ var startTime = DateTime . UtcNow ;
220+
221+ using ( var httpClient = new HttpClient ( ) )
222+ {
223+ while ( true )
224+ {
225+ // Send external event payload
226+ var json = JsonConvert . SerializeObject ( "helloWorld!" ) ;
227+ var httpContent = new StringContent ( json , Encoding . UTF8 , "application/json" ) ;
228+ await httpClient . PostAsync ( raiseEventUri , httpContent ) ;
229+
230+ var statusResponse = await httpClient . GetAsync ( statusQueryGetUri ) ;
231+ switch ( statusResponse . StatusCode )
232+ {
233+ case HttpStatusCode . Accepted :
234+ {
235+ var statusResponseBody = await GetResponseBodyAsync ( statusResponse ) ;
236+ var runtimeStatus = ( string ) statusResponseBody . runtimeStatus ;
237+ Assert . True (
238+ runtimeStatus == "Running" || runtimeStatus == "Pending" ,
239+ $ "Unexpected runtime status: { runtimeStatus } ") ;
240+
241+ if ( DateTime . UtcNow > startTime + _orchestrationCompletionTimeout )
242+ {
243+ Assert . True ( false , $ "The orchestration has not completed after { _orchestrationCompletionTimeout } ") ;
244+ }
245+
246+ await Task . Delay ( TimeSpan . FromSeconds ( 2 ) ) ;
247+ break ;
248+ }
249+
250+ case HttpStatusCode . OK :
251+ {
252+ var statusResponseBody = await GetResponseBodyAsync ( statusResponse ) ;
253+ Assert . Equal ( "Completed" , ( string ) statusResponseBody . runtimeStatus ) ;
254+ Assert . Contains ( "helloWorld!" , statusResponseBody . output . ToString ( ) ) ;
255+ return ;
256+ }
257+
258+ default :
259+ Assert . True ( false , $ "Unexpected orchestration status code: { statusResponse . StatusCode } ") ;
260+ break ;
261+ }
262+ }
263+ }
264+ }
265+
205266 [ Fact ]
206267 public async Task ExternalEventReturnsData ( )
207268 {
0 commit comments