@@ -239,26 +239,7 @@ await sqlServerCache.SetAsync(
239
239
// Assert
240
240
Assert . Null ( value ) ;
241
241
}
242
-
243
- [ IgnoreWhenNoSqlSetupFact ]
244
- public async Task ThrowsException_OnNoSlidingOrAbsoluteExpirationOptions ( )
245
- {
246
- // Arrange
247
- var key = Guid . NewGuid ( ) . ToString ( ) ;
248
- var sqlServerCache = GetCache ( ) ;
249
- var expectedValue = Encoding . UTF8 . GetBytes ( "Hello, World!" ) ;
250
-
251
- // Act & Assert
252
- var exception = await Assert . ThrowsAsync < InvalidOperationException > ( ( ) =>
253
- {
254
- return sqlServerCache . SetAsync (
255
- key ,
256
- expectedValue ,
257
- new DistributedCacheEntryOptions ( ) ) ;
258
- } ) ;
259
- Assert . Equal ( "Either absolute or sliding expiration needs to be provided." , exception . Message ) ;
260
- }
261
-
242
+
262
243
[ IgnoreWhenNoSqlSetupFact ]
263
244
public async Task DoesNotThrowException_WhenOnlyAbsoluteExpirationSupplied_AbsoluteExpirationRelativeToNow ( )
264
245
{
@@ -379,6 +360,24 @@ await AssertGetCacheItemFromDatabaseAsync(
379
360
absoluteExpiration : absoluteExpiration ,
380
361
expectedExpirationTime : absoluteExpiration ) ;
381
362
}
363
+
364
+ [ IgnoreWhenNoSqlSetupFact ]
365
+ public async Task SetCacheItem_Uses_DefaultSlidingExpiration_If_NoSlidingOrAbsoluteExpirationSupplied ( )
366
+ {
367
+ // Arrange
368
+ var key = Guid . NewGuid ( ) . ToString ( ) ;
369
+ var sqlServerCache = GetCache ( ) ;
370
+ var expectedValue = Encoding . UTF8 . GetBytes ( "Hello, World!" ) ;
371
+
372
+ await sqlServerCache . SetAsync (
373
+ key ,
374
+ expectedValue ,
375
+ new DistributedCacheEntryOptions ( ) ) ;
376
+
377
+ var cacheItem = await GetCacheItemFromDatabaseAsync ( key ) ;
378
+ Assert . NotNull ( cacheItem ) ;
379
+ Assert . Equal ( cacheItem . SlidingExpirationInSeconds , _databaseOptionsFixture . Options . Value . DefaultSlidingExpiration ) ;
380
+ }
382
381
383
382
[ IgnoreWhenNoSqlSetupFact ]
384
383
public async Task ExtendsExpirationTime_ForSlidingExpiration ( )
@@ -779,7 +778,8 @@ await sqlServerCache.SetAsync(
779
778
cacheItemInfo = await sqlServerCache . GetAsync ( key ) ;
780
779
Assert . Null ( cacheItemInfo ) ;
781
780
}
782
-
781
+
782
+
783
783
private MySqlCache GetCache ( ISystemClock testClock = null )
784
784
{
785
785
var options = _databaseOptionsFixture . Options . Value ;
0 commit comments