Example #1
0
        public void should_include_user_in_the_release()
        {
            var user1 = KUser.Create("oscar",
                                     new[] { new KUserAttribute("age", 32), new KUserAttribute("country", "spain") });
            var user2 = KUser.Create("serrano",
                                     new[] { new KUserAttribute("age", 32), new KUserAttribute("country", "spain") });

            Fixture.fifty_percent_feature.Evaluate(Fixture.store, user1).Should().BeFalse();
            Fixture.fifty_percent_feature.Evaluate(Fixture.store, user2).Should().BeTrue();
        }
Example #2
0
        private static void PrintData(object state)
        {
            // var user = new KUser("*****@*****.**", new Dictionary<string, IKValue> // Create user if needed
            // {
            //     {"country", IKValue.Create("spain")},
            //     {"age", IKValue.Create(18)}
            // });

            var user = KUser.Create("*****@*****.**")
                       .With("country", "spain")
                       .With("age", 18);

            var single      = _client.IsEnabled("someFeature", user);                                  // Get feature flag boolean for the user
            var withoutUser = _client.IsEnabled("someFeature");                                        // Get feature flag boolean without any user (anonymous)
            var result      = _client.EvaluatedFeaturesForUser(user);                                  // Get all the feature flags (used mostly for debug)
            var rc          = _client.ValueOf("sap-user", user);                                       // Get remote config value for the user
            var nonrc       = _client.ValueOf("non-existing-host", user, "defaultValueOfNonExisting"); // Get remote config value for the user with default value
            var anonymous   = _client.ValueOf("non-existing-host", "defaultValueOfNonExisting");       // Same methods as above but without user aka DefaultValue of the remote config

            Console.WriteLine($"Single Feature {JsonConvert.SerializeObject(single)}");
            Console.WriteLine($"Features {JsonConvert.SerializeObject(result)}");
            Console.WriteLine($"Remote configs {JsonConvert.SerializeObject(rc)}");
            Console.WriteLine($"Default Remote configs {JsonConvert.SerializeObject(nonrc)}");
        }
Example #3
0
 public void evaluate_oscar_should_be_ADMIN()
 {
     Fixture.roles_remoteConfig.Evaluate(Fixture.store, KUser.Create("ogalindo")).Should()
     .BeEquivalentTo("ADMIN");
 }
Example #4
0
 public void evaluate_other_should_be_GUEST()
 {
     Fixture.roles_remoteConfig.Evaluate(Fixture.store, KUser.Create("whatever")).Should()
     .BeEquivalentTo("GUEST");
 }
Example #5
0
 public void evaluate_ivana_should_be_COLLABORATOR()
 {
     Fixture.roles_remoteConfig.Evaluate(Fixture.store, KUser.Create("ivana")).Should()
     .BeEquivalentTo("COLLABORATOR");
 }