@@ -31,8 +31,7 @@ private class Fixture
3131 public Fixture ( )
3232 {
3333 Scope = new ( ) ;
34- Hub . When ( hub => hub . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
35- . Do ( callback => callback . Arg < Action < Scope > > ( ) . Invoke ( Scope ) ) ;
34+ Hub . SubstituteConfigureScope ( Scope ) ;
3635
3736 Hub . When ( hub => hub . CaptureEvent ( Arg . Any < SentryEvent > ( ) , Arg . Any < Scope > ( ) ) )
3837 . Do ( _ => Scope . Evaluate ( ) ) ;
@@ -157,23 +156,16 @@ public async Task InvokeAsync_ScopePushed_BeforeConfiguringScope()
157156 [ Fact ]
158157 public async Task InvokeAsync_LocksScope_BeforeConfiguringScope ( )
159158 {
160- var verified = false ;
161- var scope = new Scope ( ) ;
162- _fixture . Hub
163- . When ( h => h . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
164- . Do ( Callback
165- . First ( c => c . ArgAt < Action < Scope > > ( 0 ) ( scope ) )
166- . Then ( _ =>
167- {
168- Assert . True ( scope . Locked ) ;
169- verified = true ;
170- } ) ) ;
159+ var scopeLocked = false ;
160+ _fixture . Hub . When ( h => h . PushAndLockScope ( ) ) . Do ( _ => scopeLocked = true ) ;
161+ _fixture . Hub . When ( h => h . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
162+ . Do ( _ => Assert . True ( scopeLocked ) ) ;
171163
172164 var sut = _fixture . GetSut ( ) ;
173165
174166 await sut . InvokeAsync ( _fixture . HttpContext , _fixture . RequestDelegate ) ;
175167
176- Assert . True ( verified ) ;
168+ _fixture . Hub . Received ( ) . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) ;
177169 }
178170
179171 [ Fact ]
@@ -182,8 +174,7 @@ public async Task InvokeAsync_OnEvaluating_HttpContextDataSet()
182174 const string expectedTraceIdentifier = "trace id" ;
183175 _ = _fixture . HttpContext . TraceIdentifier . Returns ( expectedTraceIdentifier ) ;
184176 var scope = new Scope ( ) ;
185- _fixture . Hub . When ( h => h . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
186- . Do ( c => c . Arg < Action < Scope > > ( ) ( scope ) ) ;
177+ _fixture . Hub . SubstituteConfigureScope ( scope ) ;
187178
188179 var sut = _fixture . GetSut ( ) ;
189180
@@ -200,8 +191,7 @@ public async Task InvokeAsync_OnEvaluatingClonedScope_HttpContextDataSet()
200191 const string expectedTraceIdentifier = "trace id" ;
201192 _ = _fixture . HttpContext . TraceIdentifier . Returns ( expectedTraceIdentifier ) ;
202193 var scope = new Scope ( ) ;
203- _fixture . Hub . When ( h => h . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
204- . Do ( c => c . Arg < Action < Scope > > ( ) ( scope ) ) ;
194+ _fixture . Hub . SubstituteConfigureScope ( scope ) ;
205195
206196 var sut = _fixture . GetSut ( ) ;
207197
@@ -664,7 +654,7 @@ public async Task InvokeAsync_InstrumenterOpenTelemetry_SavesScope()
664654 // Arrange
665655 _fixture . Options . Instrumenter = Instrumenter . OpenTelemetry ;
666656 var scope = new Scope ( ) ;
667- _fixture . Hub . ConfigureScope ( Arg . Do < Action < Scope > > ( action => action . Invoke ( scope ) ) ) ;
657+ _fixture . Hub . SubstituteConfigureScope ( scope ) ;
668658 var sut = _fixture . GetSut ( ) ;
669659 var activity = new Activity ( "test" ) . Start ( ) ;
670660
0 commit comments