예제 #1
0
        private LdClient MakeClient(IFeatureStore featureStore, MockEventProcessor ep)
        {
            Configuration config = Configuration.Default("secret")
                                   .WithFeatureStoreFactory(TestUtils.SpecificFeatureStore(featureStore))
                                   .WithEventProcessorFactory(TestUtils.SpecificEventProcessor(ep))
                                   .WithUpdateProcessorFactory(Components.NullUpdateProcessor);
            LdClient client = new LdClient(config);

            featureStore.Init(new Dictionary <IVersionedDataKind, IDictionary <string, IVersionedData> >());
            return(client);
        }
예제 #2
0
        public void TrackGeneratesCustomEvent()
        {
            MockEventProcessor ep     = new MockEventProcessor();
            LdClient           client = MakeClient(new InMemoryFeatureStore(), ep);

            User user = User.WithKey("user");

            client.Track("thing", user);

            Assert.Collection(ep.Events,
                              e => CheckCustomEvent(e, user, "thing", null));
        }
예제 #3
0
        public void IdentifyGeneratesIdentifyEvent()
        {
            MockEventProcessor ep     = new MockEventProcessor();
            LdClient           client = MakeClient(new InMemoryFeatureStore(), ep);

            User user = User.WithKey("user");

            client.Identify(user);

            Assert.Collection(ep.Events,
                              e => CheckIdentifyEvent(e, user));
        }
예제 #4
0
        public void EvaluatingUnknownFlagGeneratesEvent()
        {
            IFeatureStore      featureStore = new InMemoryFeatureStore();
            MockEventProcessor ep           = new MockEventProcessor();
            LdClient           client       = MakeClient(featureStore, ep);

            User user = User.WithKey("user");

            client.StringVariation("badflag", user, "default");

            Assert.Collection(ep.Events,
                              e => CheckUnknownFlagEvent(e, "badflag", user, new JValue("default")));
        }
예제 #5
0
        public void EvaluatingFlagWithNullUserGeneratesEvent()
        {
            IFeatureStore      featureStore = new InMemoryFeatureStore();
            MockEventProcessor ep           = new MockEventProcessor();
            LdClient           client       = MakeClient(featureStore, ep);

            FeatureFlag flag = new FeatureFlagBuilder("flagkey")
                               .OffVariation(0)
                               .Variations(new List <JToken> {
                new JValue("a"), new JValue("b")
            })
                               .Build();

            featureStore.Upsert(VersionedDataKind.Features, flag);

            client.StringVariation("flagkey", null, "default");

            Assert.Collection(ep.Events,
                              e => CheckFlagEvent(e, flag, flag.Version, null, null, new JValue("default"), new JValue("default")));
        }