@@ -259,7 +259,7 @@ public void Stop_Root_Activity_With_129_Nesting_Depth()
259259 public void Should_Not_Create_RootActivity_If_AspNetListener_Not_Enabled ( )
260260 {
261261 var context = HttpContextHelper . GetFakeHttpContext ( ) ;
262- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
262+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
263263
264264 Assert . Null ( rootActivity ) ;
265265 }
@@ -269,7 +269,7 @@ public void Should_Not_Create_RootActivity_If_AspNetActivity_Not_Enabled()
269269 {
270270 var context = HttpContextHelper . GetFakeHttpContext ( ) ;
271271 this . EnableAspNetListenerOnly ( ) ;
272- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
272+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
273273
274274 Assert . Null ( rootActivity ) ;
275275 }
@@ -279,7 +279,7 @@ public void Should_Not_Create_RootActivity_If_AspNetActivity_Not_Enabled_With_Ar
279279 {
280280 var context = HttpContextHelper . GetFakeHttpContext ( ) ;
281281 this . EnableAspNetListenerAndDisableActivity ( ) ;
282- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
282+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
283283
284284 Assert . Null ( rootActivity ) ;
285285 }
@@ -289,27 +289,45 @@ public void Can_Create_RootActivity_And_Restore_Info_From_Request_Header()
289289 {
290290 var requestHeaders = new Dictionary < string , string >
291291 {
292- { ActivityExtensions . RequestIDHeaderName , "|aba2f1e978b2cab6.1" } ,
292+ { ActivityExtensions . RequestIDHeaderName , "|aba2f1e978b2cab6.1. " } ,
293293 { ActivityExtensions . CorrelationContextHeaderName , this . baggageInHeader }
294294 } ;
295295
296296 var context = HttpContextHelper . GetFakeHttpContext ( headers : requestHeaders ) ;
297297 this . EnableAspNetListenerAndActivity ( ) ;
298- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
298+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
299299
300300 Assert . NotNull ( rootActivity ) ;
301- Assert . True ( rootActivity . ParentId == "|aba2f1e978b2cab6.1" ) ;
301+ Assert . True ( rootActivity . ParentId == "|aba2f1e978b2cab6.1. " ) ;
302302 var expectedBaggage = this . baggageItems . OrderBy ( item => item . Value ) ;
303303 var actualBaggage = rootActivity . Baggage . OrderBy ( item => item . Value ) ;
304304 Assert . Equal ( expectedBaggage , actualBaggage ) ;
305305 }
306306
307+ [ Fact ]
308+ public void Can_Create_RootActivity_And_Ignore_Info_From_Request_Header_If_ParseHeaders_Is_False ( )
309+ {
310+ var requestHeaders = new Dictionary < string , string >
311+ {
312+ { ActivityExtensions . RequestIDHeaderName , "|aba2f1e978b2cab6.1." } ,
313+ { ActivityExtensions . CorrelationContextHeaderName , this . baggageInHeader }
314+ } ;
315+
316+ var context = HttpContextHelper . GetFakeHttpContext ( headers : requestHeaders ) ;
317+ this . EnableAspNetListenerAndActivity ( ) ;
318+ var rootActivity = ActivityHelper . CreateRootActivity ( context , parseHeaders : false ) ;
319+
320+ Assert . NotNull ( rootActivity ) ;
321+ Assert . Null ( rootActivity . ParentId ) ;
322+ Assert . Empty ( rootActivity . Baggage ) ;
323+ }
324+
307325 [ Fact ]
308326 public void Can_Create_RootActivity_And_Start_Activity ( )
309327 {
310328 var context = HttpContextHelper . GetFakeHttpContext ( ) ;
311329 this . EnableAspNetListenerAndActivity ( ) ;
312- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
330+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
313331
314332 Assert . NotNull ( rootActivity ) ;
315333 Assert . True ( ! string . IsNullOrEmpty ( rootActivity . Id ) ) ;
@@ -320,7 +338,7 @@ public void Can_Create_RootActivity_And_Saved_In_HttContext()
320338 {
321339 var context = HttpContextHelper . GetFakeHttpContext ( ) ;
322340 this . EnableAspNetListenerAndActivity ( ) ;
323- var rootActivity = ActivityHelper . CreateRootActivity ( context ) ;
341+ var rootActivity = ActivityHelper . CreateRootActivity ( context , true ) ;
324342
325343 Assert . NotNull ( rootActivity ) ;
326344 Assert . Same ( rootActivity , context . Items [ ActivityHelper . ActivityKey ] ) ;
0 commit comments