public void TestDbConnectionQueryAsyncCachingViaQueryGroup() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; // Act var result = new CacheDbConnection().QueryAsync <CacheEntity>(where : (QueryGroup)null, orderBy: null, top: 0, hints: null, cacheKey: cacheKey, cacheItemExpiration: cacheItemExpiration, commandTimeout: null, transaction: null, cache: cache.Object, trace: null).Result; // Assert cache.Verify(c => c.Get <IEnumerable <CacheEntity> >(It.Is <string>(s => s == cacheKey), It.IsAny <bool>()), Times.Once); cache.Verify(c => c.Add <IEnumerable <CacheEntity> >(It.Is <string>(s => s == cacheKey), It.IsAny <IEnumerable <CacheEntity> >(), It.Is <int>(i => i == cacheItemExpiration), It.IsAny <bool>()), Times.Once); }
public void TestDbConnectionQueryAsyncCachingViaDynamics() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; // Act var result = new CacheDbConnection().QueryAsync <CacheEntity>((object)null, /* whereOrPrimaryKey */ (IEnumerable <OrderField>)null, /* orderBy */ (int?)null, /* top */ (string)null, /* hints */ cacheKey, /* cacheKey */ cacheItemExpiration, /* cacheItemExpiration */ (int?)null, /* commandTimeout */ (IDbTransaction)null, /* transaction */ cache.Object, /* cache */ (ITrace)null /* trace */).Result; // Assert cache.Verify(c => c.Get <IEnumerable <CacheEntity> >(It.Is <string>(s => s == cacheKey), It.IsAny <bool>()), Times.Once); cache.Verify(c => c.Add <IEnumerable <CacheEntity> >(It.Is <string>(s => s == cacheKey), It.IsAny <IEnumerable <CacheEntity> >(), It.Is <int>(i => i == cacheItemExpiration), It.IsAny <bool>()), Times.Once); }