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