async public Task EnabledFlagWorksIsTrueOnlyOnTrue() { var ctx = new ClientEvalFeatureContext(_repository, null, (repo, config) => null); Assert.AreEqual(false, ctx.IsSet("1")); Assert.AreEqual(false, ctx.IsEnabled("1")); _repository.Notify(SSEResultState.Features, RepositoryTest.EncodeFeatures(true, 2, FeatureValueType.BOOLEAN)); Assert.AreEqual(true, ctx.IsEnabled("1")); _repository.Notify(SSEResultState.Features, RepositoryTest.EncodeFeatures(false, 3, FeatureValueType.BOOLEAN)); Assert.AreEqual(false, ctx.IsEnabled("1")); Assert.AreEqual(true, ctx.IsSet("1")); Assert.IsNull(ctx.EdgeService); await ctx.Build(); ctx.Close(); }
public void BasicBooleanStrategy() { // given: we have a basic boolean feature var feature = new FeatureState(); feature.Key = "bool1"; feature.Value = true; feature.Version = 1; feature.Type = FeatureValueType.BOOLEAN; var strategy = new RolloutStrategy("id", "name"); strategy.Value = false; var ruleset = new RolloutStrategyAttribute(); ruleset.Conditional = RolloutStrategyAttributeConditional.EQUALS; ruleset.Type = RolloutStrategyFieldType.STRING; ruleset.FieldName = GetEnumMemberValue(StrategyAttributeWellKnownNames.Country); ruleset.Values = new List <object> { GetEnumMemberValue(StrategyAttributeCountryName.Turkey) }; strategy.Attributes = new List <RolloutStrategyAttribute> { ruleset }; feature.Strategies = new List <RolloutStrategy> { strategy }; repo.Notify(new List <FeatureState> { feature }); var matchCC = new TestClientContext().Country(StrategyAttributeCountryName.Turkey); var unmatchCC = new TestClientContext().Country(StrategyAttributeCountryName.Newzealand); Assert.AreEqual(false, repo.GetFeature("bool1").WithContext(matchCC).BooleanValue); Assert.AreEqual(true, repo.GetFeature("bool1").WithContext(unmatchCC).BooleanValue); Assert.AreEqual(true, repo.GetFeature("bool1").BooleanValue); }
public void ReadynessWhenFeaturesAppear() { var found = false; _repository.ReadynessHandler += (sender, readyness) => { found = true; }; _repository.Notify(SSEResultState.Features, EncodeFeatures()); Assert.AreEqual(true, found); }
public void ABooleanIsStoredCorrectly() { _repository.Notify(SSEResultState.Features, EncodeFeatures(true, 1, FeatureValueType.BOOLEAN)); Assert.AreEqual(true, _repository.GetFlag("1")); }