44using BitFaster . Caching . Atomic ;
55using FluentAssertions ;
66using Xunit ;
7+ using Xunit . Abstractions ;
78
89namespace BitFaster . Caching . UnitTests . Atomic
910{
1011 public class ScopedAsyncAtomicFactoryTests
1112 {
13+ private readonly ITestOutputHelper outputHelper ;
14+
15+ public ScopedAsyncAtomicFactoryTests ( ITestOutputHelper outputHelper )
16+ {
17+ this . outputHelper = outputHelper ;
18+ }
19+
1220 [ Fact ]
1321 public void WhenScopeIsNotCreatedScopeIfCreatedReturnsNull ( )
1422 {
@@ -105,7 +113,7 @@ public void WhenValueIsCreatedDisposeDisposesValue()
105113 {
106114 var holder = new IntHolder ( ) { actualNumber = 2 } ;
107115 var atomicFactory = new ScopedAsyncAtomicFactory < int , IntHolder > ( holder ) ;
108-
116+
109117 atomicFactory . Dispose ( ) ;
110118
111119 holder . disposed . Should ( ) . BeTrue ( ) ;
@@ -152,7 +160,7 @@ public async Task WhenCallersRunConcurrentlyResultIsFromWinner()
152160
153161 result1 . l . Value . actualNumber . Should ( ) . Be ( winningNumber ) ;
154162 result2 . l . Value . actualNumber . Should ( ) . Be ( winningNumber ) ;
155-
163+
156164 winnerCount . Should ( ) . Be ( 1 ) ;
157165 }
158166
@@ -199,14 +207,14 @@ await Task.WhenAll(first, second)
199207 }
200208
201209 [ Fact ]
202- public async Task WhenValueCreateThrowsDoesNotCauseUnobservedTaskException ( )
210+ public async Task WhenCreateFromFactoryLifetimeThrowsDoesNotCauseUnobservedTaskException ( )
203211 {
204212 bool unobservedExceptionThrown = false ;
205213 TaskScheduler . UnobservedTaskException += OnUnobservedTaskException ;
206214
207215 try
208216 {
209- await AsyncAtomicFactoryGetValueAsync ( ) ;
217+ await ScopedAsyncAtomicFactoryTryCreateLifetimeAsync ( ) ;
210218
211219 GC . Collect ( ) ;
212220 GC . WaitForPendingFinalizers ( ) ;
@@ -220,11 +228,12 @@ public async Task WhenValueCreateThrowsDoesNotCauseUnobservedTaskException()
220228
221229 void OnUnobservedTaskException ( object sender , UnobservedTaskExceptionEventArgs e )
222230 {
231+ outputHelper . WriteLine ( $ "Unobserved task exception { e . Exception } ") ;
223232 unobservedExceptionThrown = true ;
224233 e . SetObserved ( ) ;
225234 }
226235
227- static async Task AsyncAtomicFactoryGetValueAsync ( )
236+ static async Task ScopedAsyncAtomicFactoryTryCreateLifetimeAsync ( )
228237 {
229238 var a = new ScopedAsyncAtomicFactory < int , IntHolder > ( ) ;
230239 try
0 commit comments