public void Setup() { string connectionString = "Server=.\\sqlexpress;Database=Database1;Integrated Security=true"; var redisCacheOptions = new RedisCacheOptions() { Hostname = "localhost", Prefix = "cacheCountryTests", Port = "6379", }; var cacheTtlOptions = Options.Create(new CacheTtlOptions() { CountriesTtlInSeconds = 10 }); _cache = new RedisAppCache(redisCacheOptions); _repo = new SqlCachingCountryRepository(new SqlServerDataContext(connectionString, 200, NullLogger <SqlServerDataContext> .Instance), _cache, cacheTtlOptions, NullLogger <SqlCachingCountryRepository> .Instance); }
public async Task CacheDown_GetFromDatabase() { string connectionString = "Server=.\\sqlexpress;Database=Database1;Integrated Security=true"; var redisCacheOptions = new RedisCacheOptions() { Hostname = "incorrect_host", Prefix = "cacheCountryTests", Port = "6379", }; var cacheTtlOptions = Options.Create(new CacheTtlOptions() { CountriesTtlInSeconds = 10 }); var redisAppCache = new RedisAppCache(redisCacheOptions); var repo = new SqlCachingCountryRepository(new SqlServerDataContext(connectionString, 200, NullLogger <SqlServerDataContext> .Instance), redisAppCache, cacheTtlOptions, NullLogger <SqlCachingCountryRepository> .Instance); var countries = await repo.Get(); Assert.AreEqual(2, countries.ToList().Count); }