Exemplo n.º 1
0
        public async Task be_active_if_user_is_equal_to_users_parameters_value()
        {
            var toggle = Build
                         .Toggle <UserNameToggle>()
                         .AddOneParameter(Users, "user1")
                         .Build();
            var feature = Build
                          .Feature(Constants.FeatureName)
                          .AddOne(toggle)
                          .Build();
            var store            = new DelegatedValueFeatureStore((_, __) => feature);
            var userNameProvider = new DelegatedUserNameProviderService(() => "user1");

            var active = await new UserNameToggle(userNameProvider, store).IsActiveAsync(Constants.FeatureName, Constants.ProductName);

            active.Should().BeTrue();
        }
Exemplo n.º 2
0
        public async Task be_not_active_if_parameter_is_not_configured()
        {
            var toggle = Build
                         .Toggle <UserNameToggle>()
                         .AddOneParameter("Users", "SomeUser")
                         .Build();
            var feature = Build
                          .Feature(Constants.FeatureName)
                          .AddOne(toggle)
                          .Build();
            var store            = new DelegatedValueFeatureStore((_, __) => feature);
            var userNameProvider = new DelegatedUserNameProviderService(() => "User1");

            var active = await new UserNameToggle(userNameProvider, store).IsActiveAsync(Constants.FeatureName, Constants.ProductName);

            active.Should().BeFalse();
        }
        public async Task be_no_active_when_percentage_is_zero_percent()
        {
            var toggle = Build
                         .Toggle <GradualRolloutUserNameToggle>()
                         .AddOneParameter(Percentage, 0)
                         .Build();
            var feature = Build
                          .Feature(Constants.FeatureName)
                          .AddOne(toggle)
                          .Build();
            var store            = new DelegatedValueFeatureStore((_, __) => feature);
            var userNameProvider = new DelegatedUserNameProviderService(() => "User1");

            var active = await new GradualRolloutUserNameToggle(userNameProvider, store).IsActiveAsync(Constants.FeatureName, Constants.ProductName);

            active.Should().BeFalse();
        }
        public void throw_if_partitioner_is_null()
        {
            var toggle = Build
                         .Toggle <GradualRolloutUserNameToggle>()
                         .AddOneParameter(Percentage, 100)
                         .Build();

            var feature = Build
                          .Feature(Constants.FeatureName)
                          .AddOne(toggle)
                          .Build();

            var store            = new DelegatedValueFeatureStore((_, __) => feature);
            var userNameProvider = new DelegatedUserNameProviderService(() => "User1");

            Assert.Throws <ArgumentNullException>(() =>
            {
                new GradualRolloutUserNameToggle(partitioner: null, userNameProvider, store);
            });
        }
        public async Task be_active_when_user_partition_is_on_percent_bucket(string username, int percentage)
        {
            var partition = Partitioner.ResolveToLogicalPartition(username, 100);
            var expected  = partition <= percentage;

            var toggle = Build
                         .Toggle <GradualRolloutUserNameToggle>()
                         .AddOneParameter(Percentage, percentage)
                         .Build();

            var feature = Build
                          .Feature(Constants.FeatureName)
                          .AddOne(toggle)
                          .Build();

            var store            = new DelegatedValueFeatureStore((_, __) => feature);
            var userNameProvider = new DelegatedUserNameProviderService(() => username);

            var actual = await new GradualRolloutUserNameToggle(userNameProvider, store).IsActiveAsync(Constants.FeatureName, Constants.ProductName);

            actual.Should().Be(expected);
        }