示例#1
0
        public void InitializeSettingCacheProvider()
        {
            LazyLoadSettingCacheProvider provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments());

            provider.InitializeSettingCacheProvider();
            Assert.IsFalse(provider.IsInitalized);
        }
示例#2
0
        public void ManagerArguments()
        {
            LazyLoadSettingCacheProvider provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments());

            Assert.IsNotNull(provider.ManagerArguments);
            Assert.IsTrue(provider.ManagerArguments.GetType() == typeof(LazyLoadManagerArguments));
        }
示例#3
0
        public void GetDbAppSetting_NotInitialized()
        {
            Assert.Throws(typeof(Exception), () =>
            {
                DummyReturnOneLazyLoadSettingDao dao  = new DummyReturnOneLazyLoadSettingDao();
                LazyLoadSettingCacheProvider provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments()
                {
                    LazyLoadSettingDao = dao, CacheRefreshTimeout = () => TimeSpan.FromMilliseconds(0)
                });

                provider.GetDbAppSetting <DbAppSettingTestSetting, int>();
            });
        }
示例#4
0
        public void SettingWatchTaskAction_Results()
        {
            DummyReturnOneLazyLoadSettingDao dao      = new DummyReturnOneLazyLoadSettingDao();
            LazyLoadSettingCacheProvider     provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments()
            {
                LazyLoadSettingDao = dao, CacheRefreshTimeout = () => TimeSpan.FromMilliseconds(0)
            });

            provider.InitalizeSettingWatchTask();

            SpinWait.SpinUntil(() => SettingCacheProviderBase.SettingDtosByKey.Count > 0);

            Assert.IsTrue(SettingCacheProviderBase.SettingDtosByKey.Count == 1);
        }
示例#5
0
        public void SettingWatchTaskAction_NoResults()
        {
            DummyLazyLoadSettingDao      dao      = new DummyLazyLoadSettingDao();
            LazyLoadSettingCacheProvider provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments()
            {
                LazyLoadSettingDao = dao, CacheRefreshTimeout = () => TimeSpan.FromMilliseconds(0)
            });

            provider.InitalizeSettingWatchTask();

            SpinWait.SpinUntil(() => dao.GetChangedDbAppSettingsHitCount > 0);

            Assert.IsTrue(dao.GetChangedDbAppSettingsHitCount > 1);
        }
示例#6
0
        public void GetDbAppSettingInitialized()
        {
            DummyReturnDbAppSettingTestSettingLazyLoadSettingDao dao = new DummyReturnDbAppSettingTestSettingLazyLoadSettingDao();
            LazyLoadSettingCacheProvider provider = new LazyLoadSettingCacheProvider(new LazyLoadManagerArguments()
            {
                LazyLoadSettingDao = dao, CacheRefreshTimeout = () => TimeSpan.FromMilliseconds(0)
            });

            SettingCacheProviderBase.Initalized = true;

            Assert.IsTrue(SettingCacheProviderBase.SettingDtosByKey.Count == 0);
            DbAppSetting <DbAppSettingTestSetting, int> result = provider.GetDbAppSetting <DbAppSettingTestSetting, int>();

            Assert.IsTrue(SettingCacheProviderBase.SettingDtosByKey.Count == 1);
            Assert.IsTrue(result.InternalValue == 100);
            Assert.IsTrue(dao.GetDbAppSettingHitCount == 1);
        }