public void FlagsAreSavedToPersistentStorageByDefault() { var storage = new MockPersistentStorage(); var flagsJson = "{\"flag\": {\"value\": 100}}"; var config = TestUtil.ConfigWithFlagsJson(simpleUser, appKey, flagsJson) .FlagCacheManager(null) .UpdateProcessorFactory(MockPollingProcessor.Factory(flagsJson)) .PersistentStorage(storage) .Build(); using (var client = TestUtil.CreateClient(config, simpleUser)) { var storedJson = storage.GetValue(Constants.FLAGS_KEY_PREFIX + simpleUser.Key); var flags = JsonConvert.DeserializeObject <IDictionary <string, FeatureFlag> >(storedJson); Assert.Equal(new JValue(100), flags["flag"].value); } }
internal static ConfigurationBuilder ConfigWithFlagsJson(User user, string appKey, string flagsJson) { var flags = DecodeFlagsJson(flagsJson); IUserFlagCache stubbedFlagCache = new UserFlagInMemoryCache(); if (user != null && user.Key != null) { stubbedFlagCache.CacheFlagsForUser(flags, user); } return(Configuration.BuilderInternal(appKey) .FlagCacheManager(new MockFlagCacheManager(stubbedFlagCache)) .ConnectivityStateManager(new MockConnectivityStateManager(true)) .EventProcessor(new MockEventProcessor()) .UpdateProcessorFactory(MockPollingProcessor.Factory(null)) .PersistentStorage(new MockPersistentStorage()) .DeviceInfo(new MockDeviceInfo())); }