Ejemplo n.º 1
0
        public void GetAllFilters_ReturnsAllTaskFilters()
        {
            var sut    = new TaskFilterService(_cache, _configuration);
            var result = sut.GetTaskFilters();

            Assert.IsNotNull(result);
            Assert.AreEqual(5, result.Count());
        }
Ejemplo n.º 2
0
        public void GetAllFilters_CacheExpiryComesFromSettings()
        {
            var sut = new TaskFilterService(_cache, _configuration);

            sut.GetTaskFilters();

            var cachedExpiryDays = _cache.Get <int>(CacheKeys.TaskFiltersExpiryDays);

            Assert.AreEqual(3, cachedExpiryDays);
        }
Ejemplo n.º 3
0
        public void GetAllFilters_SavesFiltersToCache()
        {
            var sut    = new TaskFilterService(_cache, _configuration);
            var result = sut.GetTaskFilters();

            var cachedEntry = _cache.Get <IEnumerable <TaskFilterModel> >(CacheKeys.TaskFilters);

            Assert.IsNotEmpty(cachedEntry);
            Assert.AreEqual(result, cachedEntry);
        }
Ejemplo n.º 4
0
        public void GetAllFilters_CacheExpiryUsesFallbackWhenExpirySettingNotFound()
        {
            var myJsonConfig = "{   \"Cache\": { \"TaskFilters\": { \"INCORRECT\": \"3\" } }}";
            var stream       = new MemoryStream(Encoding.UTF8.GetBytes(myJsonConfig));

            var configuration = new ConfigurationBuilder()
                                .AddJsonStream(stream)
                                .Build();

            var sut = new TaskFilterService(_cache, configuration);

            sut.GetTaskFilters();

            var cachedExpiryDays = _cache.Get <int>(CacheKeys.TaskFiltersExpiryDays);

            Assert.AreEqual(1, cachedExpiryDays);
        }