示例#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")));
        }