Esempio n. 1
0
        public async Task be_active_when_claim_value_is_on_valid_partition()
        {
            var toggle = Build
                         .Toggle <GradualRolloutHeaderValueToggle>()
                         .AddParameter("HeaderName", "header-name")
                         .AddParameter("Percentage", 100)
                         .Build();

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

            var context = new DefaultHttpContext();

            context.Request.Headers.Add(new KeyValuePair <string, StringValues>("header-name", "header-value"));

            var partitioner = new DefaultValuePartitioner();

            var gradualRolloutHeaderValue = new GradualRolloutHeaderValueToggle(partitioner, new FakeHttpContextAccessor(context));

            var active = await gradualRolloutHeaderValue.IsActiveAsync(
                ToggleExecutionContext.FromToggle(
                    feature.Name,
                    EsquioConstants.DEFAULT_PRODUCT_NAME,
                    EsquioConstants.DEFAULT_DEPLOYMENT_NAME,
                    toggle));

            active.Should()
            .BeTrue();
        }
        public async Task be_active_when_claim_value_is_on_valid_partition()
        {
            var toggle = Build
                         .Toggle <GradualRolloutHeaderValueToggle>()
                         .AddOneParameter("HeaderName", "header-name")
                         .AddOneParameter("Percentage", 100)
                         .Build();

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

            var context = new DefaultHttpContext();

            context.Request.Headers.Add(new KeyValuePair <string, StringValues>("header-name", "header-value"));

            var store       = new DelegatedValueFeatureStore((_, __) => feature);
            var partitioner = new DefaultValuePartitioner();

            var gradualRolloutHeaderValue = new GradualRolloutHeaderValueToggle(partitioner, store, new FakeHttpContextAccesor(context));

            var active = await gradualRolloutHeaderValue.IsActiveAsync(Constants.FeatureName);

            active.Should()
            .BeTrue();
        }
Esempio n. 3
0
        public async Task use_partition_for_claim_value(int percentage)
        {
            var valid        = false;
            var header_value = default(string);

            do
            {
                header_value = Guid.NewGuid().ToString();
                var partition = new DefaultValuePartitioner().ResolvePartition(Constants.FeatureName + header_value, partitions: 100);

                if (partition <= percentage)
                {
                    valid = true;
                }
            } while (!valid);

            var toggle = Build
                         .Toggle <GradualRolloutHeaderValueToggle>()
                         .AddParameter("HeaderName", "header-name")
                         .AddParameter("Percentage", percentage)
                         .Build();

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

            var context = new DefaultHttpContext();

            context.Request.Headers.Add(new KeyValuePair <string, StringValues>("header-name", header_value));

            var partitioner = new DefaultValuePartitioner();

            var gradualRolloutHeaderValue = new GradualRolloutHeaderValueToggle(partitioner, new FakeHttpContextAccessor(context));

            var active = await gradualRolloutHeaderValue.IsActiveAsync(
                ToggleExecutionContext.FromToggle(
                    feature.Name,
                    EsquioConstants.DEFAULT_PRODUCT_NAME,
                    EsquioConstants.DEFAULT_DEPLOYMENT_NAME,
                    toggle));

            active.Should()
            .BeTrue();
        }
        public async Task use_partition_for_claim_value(int percentage)
        {
            var valid        = false;
            var header_value = default(string);

            do
            {
                header_value = Guid.NewGuid().ToString();
                var partition = new DefaultValuePartitioner().ResolvePartition(Constants.FeatureName + header_value, partitions: 100);

                if (partition <= percentage)
                {
                    valid = true;
                }
            } while (!valid);

            var toggle = Build
                         .Toggle <GradualRolloutHeaderValueToggle>()
                         .AddOneParameter("HeaderName", "header-name")
                         .AddOneParameter("Percentage", percentage)
                         .Build();

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

            var context = new DefaultHttpContext();

            context.Request.Headers.Add(new KeyValuePair <string, StringValues>("header-name", header_value));

            var store       = new DelegatedValueFeatureStore((_, __) => feature);
            var partitioner = new DefaultValuePartitioner();

            var gradualRolloutHeaderValue = new GradualRolloutHeaderValueToggle(partitioner, store, new FakeHttpContextAccesor(context));

            var active = await gradualRolloutHeaderValue.IsActiveAsync(Constants.FeatureName);

            active.Should()
            .BeTrue();
        }