public void TestDbConnectionQueryAsyncCachingViaQueryGroup() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; // Act var result = new CustomDbConnectionForDbConnectionICache().QueryAsync <CacheEntity>(where : (QueryGroup)null, orderBy: null, top: 0, hints: null, cacheKey: cacheKey, cacheItemExpiration: cacheItemExpiration, commandTimeout: null, transaction: null, cache: cache.Object, trace: null, statementBuilder: new SqlServerStatementBuilder()).Result; // Assert cache.Verify(c => c.Get(It.Is <string>(s => s == cacheKey), It.IsAny <bool>()), Times.Once); cache.Verify(c => c.Add(It.Is <string>(s => s == cacheKey), It.IsAny <object>(), 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 CustomDbConnectionForDbConnectionICache().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 */ new SqlServerStatementBuilder() /* statementBulder */).Result; // Assert cache.Verify(c => c.Get(It.Is <string>(s => s == cacheKey), It.IsAny <bool>()), Times.Once); cache.Verify(c => c.Add(It.Is <string>(s => s == cacheKey), It.IsAny <object>(), It.Is <int>(i => i == cacheItemExpiration), It.IsAny <bool>()), Times.Once); }