Exemplo n.º 1
0
        public void VariationSendsFeatureEventWithReasonForUnknownFlagWhenClientIsNotInitialized()
        {
            var config = BasicConfig()
                         .DataSource(new MockDataSourceThatNeverInitializes().AsSingletonFactory())
                         .Events(_factory);

            using (LdClient client = TestUtil.CreateClient(config.Build(), user))
            {
                EvaluationDetail <string> result = client.StringVariationDetail("flag", "b");
                var expectedReason = EvaluationReason.ErrorReason(EvaluationErrorKind.ClientNotReady);
                Assert.Equal("b", result.Value);
                Assert.Equal(expectedReason, result.Reason);
                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.Null(fe.FlagVersion);
                    Assert.Equal("b", fe.Default.AsString);
                    Assert.False(fe.TrackEvents);
                    Assert.Null(fe.DebugEventsUntilDate);
                    Assert.Equal(expectedReason, fe.Reason);
                    Assert.NotEqual(0, fe.Timestamp.Value);
                });
            }
        }
Exemplo n.º 2
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);
                });
            }
        }
Exemplo n.º 3
0
 public void VariationDetailSendsFeatureEventWithReasonForUnknownFlag()
 {
     using (LdClient client = MakeClient(user))
     {
         EvaluationDetail <string> result = client.StringVariationDetail("flag", "b");
         var expectedReason = EvaluationReason.ErrorReason(EvaluationErrorKind.FlagNotFound);
         Assert.Equal("b", result.Value);
         Assert.Equal(expectedReason, result.Reason);
         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.Null(fe.FlagVersion);
             Assert.Equal("b", fe.Default.AsString);
             Assert.False(fe.TrackEvents);
             Assert.Null(fe.DebugEventsUntilDate);
             Assert.Equal(expectedReason, fe.Reason);
             Assert.NotEqual(0, fe.Timestamp.Value);
         });
     }
 }