@@ -239,26 +239,7 @@ await sqlServerCache.SetAsync(
239239 // Assert
240240 Assert . Null ( value ) ;
241241 }
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+
262243 [ IgnoreWhenNoSqlSetupFact ]
263244 public async Task DoesNotThrowException_WhenOnlyAbsoluteExpirationSupplied_AbsoluteExpirationRelativeToNow ( )
264245 {
@@ -379,6 +360,24 @@ await AssertGetCacheItemFromDatabaseAsync(
379360 absoluteExpiration : absoluteExpiration ,
380361 expectedExpirationTime : absoluteExpiration ) ;
381362 }
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+ }
382381
383382 [ IgnoreWhenNoSqlSetupFact ]
384383 public async Task ExtendsExpirationTime_ForSlidingExpiration ( )
@@ -779,7 +778,8 @@ await sqlServerCache.SetAsync(
779778 cacheItemInfo = await sqlServerCache . GetAsync ( key ) ;
780779 Assert . Null ( cacheItemInfo ) ;
781780 }
782-
781+
782+
783783 private MySqlCache GetCache ( ISystemClock testClock = null )
784784 {
785785 var options = _databaseOptionsFixture . Options . Value ;
0 commit comments