public void WithCacheClient_ThrowsArgumentNullException_IfNullCacheClient()
        {
            var    appSettings = new CachedAppSettings(internalAppSetting);
            Action action      = () => appSettings.WithCacheClient(null);

            action.ShouldThrow <ArgumentNullException>();
        }
        public void Ctor_WithTimeout_UsesTimeoutForCalls()
        {
            const int ttl      = 9000;
            var       settings = new CachedAppSettings(internalAppSetting, ttl).WithCacheClient(cacheClient);

            settings.Set(SampleKey, 22);
            A.CallTo(() => cacheClient.Set(SampleKey, 22, TimeSpan.FromMilliseconds(ttl))).MustHaveHappened();
        }
Exemplo n.º 3
0
        public void when_cached_settings_do_not_exist_but_app_settings_do()
        {
            var appSettings     = A.Fake <IAppSettings>();
            var storageSettings = A.Fake <IStorageSettings>();
            var sut             = new CachedAppSettings(appSettings, storageSettings, new DateTime());

            A.CallTo(() => appSettings.GetByKey("IsProcessingSamsaraLocation", false)).Returns(true);
            A.CallTo(() => storageSettings.GetByKey("IsProcessingSamsaraLocation")).Returns(null);
            A.CallTo(() => storageSettings.GetByKey("IsProcessingSamsaraLocation", false)).Returns(false);
            sut.GetByKey("IsProcessingSamsaraLocation", false).ShouldBe(true);
        }
Exemplo n.º 4
0
        public CachedAppSettingsTests()
        {
            cacheClient        = A.Fake <ICacheClient>();
            internalAppSetting = A.Fake <IAppSettings>();
            appSettings        = new CachedAppSettings(internalAppSetting).WithCacheClient(cacheClient);
            defaultTtl         = TimeSpan.FromMilliseconds(2000);
            human = new Human {
                Age = 99, Name = "Test Person"
            };

            dict = new Dictionary <string, string>
            {
                { "One", "ValOne" },
                { "Two", "ValTwo" }
            };
            list = new List <string> {
                "Rolles", "Rickson", "Royler", "Royce"
            };
        }