Exemple #1
0
        public void OfflineClientGetsFlagFromDataStore()
        {
            var dataStore = new InMemoryDataStore();

            TestUtils.UpsertFlag(dataStore,
                                 new FeatureFlagBuilder("key").OffWithValue(LdValue.Of(true)).Build());
            var config = BasicConfig()
                         .Offline(true)
                         .DataStore(dataStore.AsSingletonFactory())
                         .Build();

            using (var client = new LdClient(config))
            {
                Assert.True(client.BoolVariation("key", User.WithKey("user"), false));
            }
        }
Exemple #2
0
        public void EvaluationReturnsDefaultValueIfNeitherClientNorDataStoreIsInited()
        {
            var dataStore = new InMemoryDataStore();
            var flag      = new FeatureFlagBuilder("key").OffWithValue(LdValue.Of(1)).Build();

            TestUtils.UpsertFlag(dataStore, flag);
            // note, the store is still not inited

            var config = BasicConfig()
                         .DataStore(dataStore.AsSingletonFactory())
                         .DataSource(MockDataSourceThatNeverStarts().AsSingletonFactory())
                         .Build();

            using (var client = new LdClient(config))
            {
                Assert.Equal(0, client.IntVariation("key", User.WithKey("user"), 0));
            }
        }
Exemple #3
0
        public void EvaluationUsesDataStoreIfClientIsNotInitedButStoreIsInited()
        {
            var dataStore = new InMemoryDataStore();

            dataStore.Init(FullDataSet <ItemDescriptor> .Empty());
            var flag = new FeatureFlagBuilder("key").OffWithValue(LdValue.Of(1)).Build();

            TestUtils.UpsertFlag(dataStore, flag);

            var config = BasicConfig()
                         .DataStore(dataStore.AsSingletonFactory())
                         .DataSource(MockDataSourceThatNeverStarts().AsSingletonFactory())
                         .Build();

            using (var client = new LdClient(config))
            {
                Assert.Equal(1, client.IntVariation("key", User.WithKey("user"), 0));
            }
        }