@@ -44,9 +44,10 @@ public async Task Should_Return_From_Memory_If_Cache_Exist_In_Memory(string cach
4444 _memoryClientMock . Setup ( q => q . TryGetValue ( cacheKey , out response ) ) . Returns ( true ) ;
4545
4646 var multiCacheManager = _autoMock . Create < RedisMultiCacheManager > ( ) ;
47- var cachedResult = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
47+ var ( cachedResult , fromCache ) = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
4848
4949 Assert . Equal ( response , cachedResult ) ;
50+ Assert . True ( fromCache ) ;
5051 _memoryClientMock . Verify ( q => q . TryGetValue ( cacheKey , out response ) , Times . Once ) ;
5152 }
5253
@@ -58,10 +59,10 @@ public async Task Should_Return_Empty_If_Cache_Doesnt_Exist_In_Memory_And_Redis(
5859 _redisClientMock . Setup ( q => q . GetWithExpiryAsync ( cacheKey , default ) ) . ReturnsAsync ( ( ) => ( null , TimeSpan . Zero ) ) ;
5960
6061 var multiCacheManager = _autoMock . Create < RedisMultiCacheManager > ( ) ;
61- var cachedResult = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
62+ var ( cachedResult , fromCache ) = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
6263
6364 Assert . Equal ( default , cachedResult ) ;
64-
65+ Assert . False ( fromCache ) ;
6566 _memoryClientMock . Verify ( q => q . TryGetValue ( cacheKey , out response ) , Times . Once ) ;
6667 _redisClientMock . Verify ( q => q . GetWithExpiryAsync ( cacheKey , It . IsAny < CancellationToken > ( ) ) , Times . Once ) ;
6768 }
@@ -77,9 +78,10 @@ public async Task Should_Return_From_Redis_And_Set_Memory_With_TTL_When_Cache_Ex
7778 _redisClientMock . Setup ( q => q . GetWithExpiryAsync ( cacheKey , default ) ) . ReturnsAsync ( ( ) => ( JsonSerializer . SerializeToUtf8Bytes ( response ) , redisTtl ) ) ;
7879
7980 var multiCacheManager = _autoMock . Create < RedisMultiCacheManager > ( ) ;
80- var cachedResult = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
81+ var ( cachedResult , fromCache ) = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
8182
8283 Assert . Equal ( response , cachedResult ) ;
84+ Assert . True ( fromCache ) ;
8385 _memoryClientMock . Verify ( q => q . TryGetValue ( cacheKey , out response ) , Times . Once ) ;
8486 _memoryClientMock . Verify ( q => q . Set ( cacheKey , response , redisTtl ) , Times . Once ) ;
8587 _redisClientMock . Verify ( q => q . GetWithExpiryAsync ( cacheKey , It . IsAny < CancellationToken > ( ) ) , Times . Once ) ;
@@ -95,12 +97,13 @@ public async Task Should_Return_From_Redis_And_Set_Memory_Without_TTL_When_Cache
9597 _redisClientMock . Setup ( q => q . GetWithExpiryAsync ( cacheKey , default ) ) . ReturnsAsync ( ( ) => ( JsonSerializer . SerializeToUtf8Bytes ( response ) , null ) ) ;
9698
9799 var multiCacheManager = _autoMock . Create < RedisMultiCacheManager > ( ) ;
98- var cachedResult = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
100+ var ( cachedResult , fromCache ) = await multiCacheManager . GetAsync < string > ( cacheKey ) ;
99101
100102 Assert . Equal ( response , cachedResult ) ;
103+ Assert . True ( fromCache ) ;
101104 _memoryClientMock . Verify ( q => q . TryGetValue ( cacheKey , out response ) , Times . Once ) ;
102105 _memoryClientMock . Verify ( q => q . Set ( cacheKey , response ) , Times . Once ) ;
103106 _redisClientMock . Verify ( q => q . GetWithExpiryAsync ( cacheKey , It . IsAny < CancellationToken > ( ) ) , Times . Once ) ;
104107 }
105108 }
106- }
109+ }
0 commit comments