public void TestBaseRepositoryQueryCachingWithoutExpression() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; var repository = new CacheEntityRepository(cache.Object, cacheItemExpiration); // Act repository.Query(where : (QueryGroup)null, orderBy: null, top: 0, hints: null, cacheKey: cacheKey, transaction: null); // 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 TestBaseRepositoryQueryCachingViaDynamics() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; var repository = new CacheEntityRepository(cache.Object, cacheItemExpiration); // Act repository.Query((object)null, /* whereOrPrimaryKey */ (IEnumerable <OrderField>)null, /* orderBy */ (int?)null, /* top */ (string)null, /* hints */ cacheKey, /* cacheKey */ (IDbTransaction)null); // 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 TestBaseRepositoryQueryCachingViaQueryFields() { // Prepare var cache = new Mock <ICache>(); var cacheKey = "MemoryCacheKey"; var cacheItemExpiration = 60; var repository = new CacheEntityRepository(cache.Object, cacheItemExpiration); // Act repository.Query(where : (IEnumerable <QueryField>)null, orderBy: null, top: 0, hints: null, cacheKey: cacheKey, transaction: null); // 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); }