@@ -28,7 +28,8 @@ public RedisCacheTests()
2828 try
2929 {
3030 // See if we have a running copy of redis in a K8s Cluster
31- // helm install --name redis-dev --set password=secretpassword --set master.disableCommands= stable/redis
31+ // helm upgrade --install redis-dev --set password=secretpassword --set master.disableCommands= bitnami/redis
32+
3233 // kubectl get secret --namespace default redis-dev -o jsonpath="{.data.redis-password}" | base64 --decode
3334 // kubectl port-forward --namespace default svc/redis-dev-master 6379:6379
3435 var connString = "localhost:6379,password=secretpassword" ;
@@ -38,12 +39,12 @@ public RedisCacheTests()
3839 AdminConnectionString = string . Join ( "," , connString , "allowAdmin=true" ) ;
3940
4041 }
41- catch ( Exception )
42+ catch ( Exception )
4243 {
4344 // Could not connect to redis above, so start a local copy
4445 RedisStorageEmulatorManager . Instance . StartProcess ( false ) ;
4546 }
46-
47+
4748 }
4849
4950 [ TestMethod ]
@@ -98,7 +99,7 @@ public void Item_still_returned_after_sliding_expiration_period()
9899
99100 object fromCache = null ;
100101 // In a loop of 20 seconds retrieve the item every 5 second seconds.
101- for ( var i = 0 ; i < 4 ; i ++ )
102+ for ( var i = 0 ; i < 4 ; i ++ )
102103 {
103104 Thread . Sleep ( 5000 ) ; // Wait 5 seconds
104105 // Retrieve item again. This should update LastAccess and as such keep the item 'alive'
@@ -155,7 +156,7 @@ public void Count_returns_numers_of_cached_entries()
155156 Assert . AreEqual ( 0 , cache . Count ) ;
156157 }
157158
158-
159+
159160 [ TestMethod ]
160161 public async Task ThreadingBlockTest ( )
161162 {
@@ -167,8 +168,10 @@ public async Task ThreadingBlockTest()
167168
168169 cache . CachingFailed += ( sender , e ) =>
169170 {
170- if ( e ? . InnerException is LockTimeoutException )
171+ if ( e ? . InnerException is LockTimeoutException )
172+ {
171173 exception = e . InnerException ;
174+ }
172175 } ;
173176 cache . Purge ( ) ;
174177
@@ -185,20 +188,21 @@ public async Task ThreadingBlockTest()
185188
186189 var tasks = new Task [ 10 ] ;
187190
188- for ( var i = 0 ; i < 10 ; i ++ )
191+ for ( var i = 0 ; i < 10 ; i ++ )
189192 {
190193 var icopy = i ;
191194 tasks [ i ] = Task . Run ( ( ) =>
192195 {
193196 var watch = new Stopwatch ( ) ;
194197 watch . Start ( ) ;
195198 Debug . WriteLine ( $ "Invalidate { icopy } start") ;
196- if ( i == 9 )
199+ if ( i == 9 )
200+ {
197201 cache . InvalidateItem ( "1" ) ;
202+ }
198203 else
199204 {
200- object val ;
201- cache . GetItem ( "1" , out val ) ;
205+ cache . GetItem ( "1" , out var val ) ;
202206 }
203207 watch . Stop ( ) ;
204208 Debug . WriteLine ( $ "Invalidate { icopy } complete after { watch . ElapsedMilliseconds } ") ;
@@ -211,8 +215,7 @@ public async Task ThreadingBlockTest()
211215 Debug . WriteLine ( $ "Get start") ;
212216 var watch = new Stopwatch ( ) ;
213217 watch . Start ( ) ;
214- object value ;
215- cache . GetItem ( "1" , out value ) ;
218+ cache . GetItem ( "1" , out var value ) ;
216219 watch . Stop ( ) ;
217220 Debug . WriteLine ( $ "Get complete after { watch . ElapsedMilliseconds } ") ;
218221 } ) ;
@@ -227,10 +230,7 @@ public async Task ThreadingBlockTest()
227230
228231 }
229232
230- private void Cache_CachingFailed ( object sender , RedisCacheException e )
231- {
232- throw new NotImplementedException ( ) ;
233- }
233+ private void Cache_CachingFailed ( object sender , RedisCacheException e ) => throw new NotImplementedException ( ) ;
234234
235235
236236 [ TestMethod ]
@@ -244,7 +244,7 @@ public void Count_does_not_return_expired_entries()
244244
245245 cache . PutItem ( "1" , new object ( ) , new string [ 0 ] , TimeSpan . MaxValue , DateTimeOffset . Now . AddSeconds ( 1 ) ) ;
246246
247- Assert . AreEqual ( 1 , cache . Count ) ;
247+ Assert . AreEqual ( 1 , cache . Count ) ;
248248
249249 Thread . Sleep ( 1000 ) ;
250250
@@ -282,31 +282,19 @@ public void GetItem_validates_parameters()
282282
283283 [ TestMethod ]
284284 [ ExpectedException ( typeof ( ArgumentOutOfRangeException ) ) ]
285- public void PutItem_validates_key_parameter ( )
286- {
287- new RedisCache ( RegularConnectionString ) . PutItem ( null , 42 , new string [ 0 ] , TimeSpan . Zero , DateTimeOffset . Now ) ;
288- }
285+ public void PutItem_validates_key_parameter ( ) => new RedisCache ( RegularConnectionString ) . PutItem ( null , 42 , new string [ 0 ] , TimeSpan . Zero , DateTimeOffset . Now ) ;
289286
290287 [ TestMethod ]
291288 [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
292- public void PutItem_validates_dependentEntitySets_parameter ( )
293- {
294- new RedisCache ( RegularConnectionString ) . PutItem ( "1" , 42 , null , TimeSpan . Zero , DateTimeOffset . Now ) ;
295- }
289+ public void PutItem_validates_dependentEntitySets_parameter ( ) => new RedisCache ( RegularConnectionString ) . PutItem ( "1" , 42 , null , TimeSpan . Zero , DateTimeOffset . Now ) ;
296290
297291 [ TestMethod ]
298292 [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
299- public void InvalidateSets_validates_parameters ( )
300- {
301- new RedisCache ( RegularConnectionString ) . InvalidateSets ( null ) ;
302- }
293+ public void InvalidateSets_validates_parameters ( ) => new RedisCache ( RegularConnectionString ) . InvalidateSets ( null ) ;
303294
304295 [ TestMethod ]
305296 [ ExpectedException ( typeof ( ArgumentOutOfRangeException ) ) ]
306- public void InvalidateItem_validates_parameters ( )
307- {
308- new RedisCache ( RegularConnectionString ) . InvalidateItem ( null ) ;
309- }
297+ public void InvalidateItem_validates_parameters ( ) => new RedisCache ( RegularConnectionString ) . InvalidateItem ( null ) ;
310298
311299 [ TestMethod ]
312300 public void GetItem_does_not_crash_if_cache_is_unavailable ( )
0 commit comments