static RedirectRepository()
        {
            var settingsUtility = new SettingsUtility();

            // define the cache duration
            var cacheDuration = settingsUtility.AppSettingExists(SettingsKeys.CacheDurationKey) ?
                                settingsUtility.GetAppSetting <int>(SettingsKeys.CacheDurationKey) : DEFAULT_CACHE_DURATION;

            // define cache enabled
            var cacheEnabled = settingsUtility.AppSettingExists(SettingsKeys.CacheEnabledKey) ?
                               settingsUtility.GetAppSetting <bool>(SettingsKeys.CacheEnabledKey) :
                               true;

            _cacheManager = new CacheManager(cacheDuration, cacheEnabled);
        }
Esempio n. 2
0
        public void GetAppSettingTest()
        {
            Assert.AreEqual(true, SettingsUtility.GetAppSetting("IsEnabled", false));
            Assert.AreEqual(99, SettingsUtility.GetAppSetting("Count", 30));
            Assert.AreEqual(new DateTime(2012, 1, 1, 10, 20, 30), SettingsUtility.GetAppSetting("Since", new DateTime(2000, 1, 1)));
            Assert.AreEqual(TimeSpan.FromSeconds(90), SettingsUtility.GetAppSetting("Timeout", TimeSpan.FromSeconds(30)));
            Assert.AreEqual(DayOfWeek.Monday, SettingsUtility.GetAppSetting("DayOfWeek", DayOfWeek.Sunday));

            Assert.AreEqual(false, SettingsUtility.GetAppSetting("Nokey", false));
            Assert.AreEqual(123, SettingsUtility.GetAppSetting("Nokey", 123));
        }