예제 #1
0
        public async Task be_active_if_current_environment_is_configured_with_different_case()
        {
            var toggle = Build
                         .Toggle <HostEnvironmentToggle>()
                         .AddParameter(Environments, Development)
                         .Build();

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

            var hostEnvironment = new FakeHostEnvironment("DeVeLoPmEnT");

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

            active.Should().BeTrue();
        }
예제 #2
0
        public async Task be_not_active_when_claim_type_and_value_are_successfully_configured_and_user_claims_contains_multiple_values_of_the_sample_type()
        {
            var toggle = Build
                         .Toggle <ClaimValueToggle>()
                         .AddParameter("ClaimType", "some_claim_type")
                         .AddParameter("ClaimValues", "three")
                         .Build();

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

            var context = new DefaultHttpContext();

            context.User = new ClaimsPrincipal(
                new ClaimsIdentity(new Claim[]
            {
                new Claim("some_claim_type", "one"),
                new Claim("some_claim_type", "two"),
                new Claim("some_claim_type", "three")
            }, "cookies"));

            var store            = new DelegatedValueFeatureStore((_, __, ___) => feature);
            var claimValueToggle = new ClaimValueToggle(new FakeHttpContextAccessor(context));

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

            active.Should()
            .BeFalse();
        }
예제 #3
0
        public async Task be_active_if_current_environment_is_configured_in_a_list()
        {
            var toggle = Build
                         .Toggle <EnvironmentVariableToggle>()
                         .AddParameter(EnvironmentVariable, "ASPNETCORE_ENVIRONMENT")
                         .AddParameter(Values, "Production;Development;Testing")
                         .Build();

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

            Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Testing", EnvironmentVariableTarget.Process);

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

            active.Should().BeTrue();
        }