@@ -9,41 +9,41 @@ namespace BitFaster.Caching.UnitTests
99 public class SingletonCacheTests
1010 {
1111 [ Fact ]
12- public void AcquireWithSameKeyUsingCustomComparerReturnsSameHandle ( )
12+ public void AcquireWithSameKeyUsingCustomComparerReturnsSameLifetime ( )
1313 {
1414 var cache = new SingletonCache < string , object > ( 1 , 3 , StringComparer . OrdinalIgnoreCase ) ;
1515
16- var handle1 = cache . Acquire ( "foo" ) ;
17- var handle2 = cache . Acquire ( "FOO" ) ;
18- handle1 . Value . Should ( ) . BeSameAs ( handle2 . Value ) ;
19- handle1 . Dispose ( ) ;
20- handle2 . Dispose ( ) ;
16+ var lifetime1 = cache . Acquire ( "foo" ) ;
17+ var lifetime2 = cache . Acquire ( "FOO" ) ;
18+ lifetime1 . Value . Should ( ) . BeSameAs ( lifetime2 . Value ) ;
19+ lifetime1 . Dispose ( ) ;
20+ lifetime2 . Dispose ( ) ;
2121 }
2222
2323 [ Fact ]
24- public void AcquireWithSameKeyReturnsSameHandle ( )
24+ public void AcquireWithSameKeyReturnsSameLifetime ( )
2525 {
2626 var cache = new SingletonCache < string , object > ( ) ;
2727
28- var handle1 = cache . Acquire ( "Foo" ) ;
29- var handle2 = cache . Acquire ( "Foo" ) ;
30- handle1 . Value . Should ( ) . BeSameAs ( handle2 . Value ) ;
31- handle1 . Dispose ( ) ;
32- handle2 . Dispose ( ) ;
28+ var lifetime1 = cache . Acquire ( "Foo" ) ;
29+ var lifetime2 = cache . Acquire ( "Foo" ) ;
30+ lifetime1 . Value . Should ( ) . BeSameAs ( lifetime2 . Value ) ;
31+ lifetime1 . Dispose ( ) ;
32+ lifetime2 . Dispose ( ) ;
3333 }
3434
3535 [ Fact ]
3636 public void AcquireReleaseAcquireReturnsDifferentValue ( )
3737 {
3838 var cache = new SingletonCache < string , object > ( ) ;
3939
40- var handle1 = cache . Acquire ( "Foo" ) ;
41- handle1 . Dispose ( ) ;
40+ var lifetime1 = cache . Acquire ( "Foo" ) ;
41+ lifetime1 . Dispose ( ) ;
4242
43- var handle2 = cache . Acquire ( "Foo" ) ;
44- handle2 . Dispose ( ) ;
43+ var lifetime2 = cache . Acquire ( "Foo" ) ;
44+ lifetime2 . Dispose ( ) ;
4545
46- handle1 . Value . Should ( ) . NotBeSameAs ( handle2 . Value ) ;
46+ lifetime1 . Value . Should ( ) . NotBeSameAs ( lifetime2 . Value ) ;
4747 }
4848
4949 [ Fact ]
@@ -54,34 +54,34 @@ public async Task AcquireWithSameKeyOnTwoDifferentThreadsReturnsSameValue()
5454 EventWaitHandle event1 = new EventWaitHandle ( false , EventResetMode . AutoReset ) ;
5555 EventWaitHandle event2 = new EventWaitHandle ( false , EventResetMode . AutoReset ) ;
5656
57- SingletonCache < string , object > . Handle handle1 = null ;
58- SingletonCache < string , object > . Handle handle2 = null ;
57+ Lifetime < object > lifetime1 = null ;
58+ Lifetime < object > lifetime2 = null ;
5959
6060 Task task1 = Task . Run ( ( ) =>
6161 {
6262 event1 . WaitOne ( ) ;
63- handle1 = cache . Acquire ( "Foo" ) ;
63+ lifetime1 = cache . Acquire ( "Foo" ) ;
6464 event2 . Set ( ) ;
6565
6666 event1 . WaitOne ( ) ;
67- handle1 . Dispose ( ) ;
67+ lifetime1 . Dispose ( ) ;
6868 event2 . Set ( ) ;
6969 } ) ;
7070
7171 Task task2 = Task . Run ( ( ) =>
7272 {
7373 event1 . Set ( ) ;
7474 event2 . WaitOne ( ) ;
75- handle2 = cache . Acquire ( "Foo" ) ;
75+ lifetime2 = cache . Acquire ( "Foo" ) ;
7676
7777 event1 . Set ( ) ;
7878 event2 . WaitOne ( ) ;
79- handle2 . Dispose ( ) ;
79+ lifetime2 . Dispose ( ) ;
8080 } ) ;
8181
8282 await Task . WhenAll ( task1 , task2 ) ;
8383
84- handle1 . Value . Should ( ) . BeSameAs ( handle2 . Value ) ;
84+ lifetime1 . Value . Should ( ) . BeSameAs ( lifetime2 . Value ) ;
8585 }
8686
8787 [ Fact ]
@@ -99,9 +99,9 @@ public async Task AcquireWithSameKeyOnManyDifferentThreadsReturnsSameValue()
9999 {
100100 for ( int i = 0 ; i < 100000 ; i ++ )
101101 {
102- using ( var handle = cache . Acquire ( "Foo" ) )
102+ using ( var lifetime = cache . Acquire ( "Foo" ) )
103103 {
104- lock ( handle . Value )
104+ lock ( lifetime . Value )
105105 {
106106 int result = Interlocked . Increment ( ref count ) ;
107107 result . Should ( ) . Be ( 1 ) ;
@@ -120,7 +120,7 @@ public void WhenValueIsDisposableItIsDisposedWhenReleased()
120120 {
121121 var cache = new SingletonCache < string , DisposeTest > ( ) ;
122122
123- using ( var handle = cache . Acquire ( "Foo" ) )
123+ using ( var lifetime = cache . Acquire ( "Foo" ) )
124124 {
125125 DisposeTest . WasDisposed . Should ( ) . BeFalse ( ) ;
126126 }
0 commit comments