Exemple #1
0
        public void VariationDetailSendsFeatureEventWithReasonForValidFlag()
        {
            var flag = new FeatureFlagBuilder().Value(LdValue.Of("a")).Variation(1).Version(1000)
                       .TrackEvents(true).DebugEventsUntilDate(UnixMillisecondTime.OfMillis(2000))
                       .Reason(EvaluationReason.OffReason).Build();

            _testData.Update(_testData.Flag("flag").PreconfiguredFlag(flag));
            using (LdClient client = MakeClient(user))
            {
                EvaluationDetail <string> result = client.StringVariationDetail("flag", "b");
                Assert.Equal("a", result.Value);
                Assert.Equal(EvaluationReason.OffReason, result.Reason);
                Assert.Collection(eventProcessor.Events,
                                  e => CheckIdentifyEvent(e, user),
                                  e => {
                    EvaluationEvent fe = Assert.IsType <EvaluationEvent>(e);
                    Assert.Equal("flag", fe.FlagKey);
                    Assert.Equal("a", fe.Value.AsString);
                    Assert.Equal(1, fe.Variation);
                    Assert.Equal(1000, fe.FlagVersion);
                    Assert.Equal("b", fe.Default.AsString);
                    Assert.True(fe.TrackEvents);
                    Assert.Equal(UnixMillisecondTime.OfMillis(2000), fe.DebugEventsUntilDate);
                    Assert.Equal(EvaluationReason.OffReason, fe.Reason);
                    Assert.NotEqual(0, fe.Timestamp.Value);
                });
            }
        }
Exemple #2
0
        public void BoolVariationDetailReturnsValue()
        {
            var reason = EvaluationReason.OffReason;
            var flag   = new FeatureFlagBuilder().Value(true).Variation(1).Reason(reason).Build();

            _testData.Update(_testData.Flag(flagKey).PreconfiguredFlag(flag));
            using (var client = MakeClient())
            {
                var expected = new EvaluationDetail <bool>(true, 1, reason);
                Assert.Equal(expected, client.BoolVariationDetail(flagKey, false));
            }
        }
Exemple #3
0
        public void IntVariationDetailReturnsValue()
        {
            var reason = EvaluationReason.OffReason;
            var flag   = new FeatureFlagBuilder().Value(LdValue.Of(3)).Variation(1).Reason(reason).Build();

            _testData.Update(_testData.Flag(flagKey).PreconfiguredFlag(flag));
            using (var client = MakeClient())
            {
                var expected = new EvaluationDetail <int>(3, 1, reason);
                Assert.Equal(expected, client.IntVariationDetail(flagKey, 0));
            }
        }
Exemple #4
0
        public void JsonVariationDetailReturnsValue()
        {
            var jsonValue = LdValue.BuildObject().Add("thing", "stuff").Build();
            var reason    = EvaluationReason.OffReason;
            var flag      = new FeatureFlagBuilder().Value(jsonValue).Variation(1).Reason(reason).Build();

            _testData.Update(_testData.Flag(flagKey).PreconfiguredFlag(flag));
            using (var client = MakeClient())
            {
                var expected = new EvaluationDetail <LdValue>(jsonValue, 1, reason);
                var result   = client.JsonVariationDetail(flagKey, LdValue.Of(3));
                Assert.Equal(expected.Value, result.Value);
                Assert.Equal(expected.VariationIndex, result.VariationIndex);
                Assert.Equal(expected.Reason, result.Reason);
            }
        }
Exemple #5
0
        public void VariationSendsFeatureEventForDefaultValue()
        {
            var flag = new FeatureFlagBuilder().Version(1000).Build();

            _testData.Update(_testData.Flag("flag").PreconfiguredFlag(flag));
            using (LdClient client = MakeClient(user))
            {
                string result = client.StringVariation("flag", "b");
                Assert.Equal("b", result);
                Assert.Collection(eventProcessor.Events,
                                  e => CheckIdentifyEvent(e, user),
                                  e => {
                    EvaluationEvent fe = Assert.IsType <EvaluationEvent>(e);
                    Assert.Equal("flag", fe.FlagKey);
                    Assert.Equal("b", fe.Value.AsString);
                    Assert.Null(fe.Variation);
                    Assert.Equal(1000, fe.FlagVersion);
                    Assert.Equal("b", fe.Default.AsString);
                    Assert.Null(fe.Reason);
                    Assert.NotEqual(0, fe.Timestamp.Value);
                });
            }
        }