Ejemplo n.º 1
0
        public void IsFeatureEnabled_ServerIsDown_ReturnsFalse()
        {
            var client = new FeatureHttpClient(new HttpClient(), new FeatuRSettings {
                BaseUrl = "http://doesntexist"
            });
            var sut = new RestFeatureService(client);
            var act = sut.IsFeatureEnabled("test");

            Assert.False(act);
        }
Ejemplo n.º 2
0
        public async Task IsFeatureEnabled_FeatureIsEnabled_ReturnsTrue()
        {
            var featureId = Guid.NewGuid().ToString();

            _fixture.MockIsFeatureEnabledResponse(featureId, isEnabled: true);
            var client = new FeatureHttpClient(new HttpClient(), _fixture.Settings);
            var sut    = new RestFeatureService(client);

            Assert.True(sut.IsFeatureEnabled(featureId));
            Assert.True(await sut.IsFeatureEnabledAsync(featureId));
            Assert.True(await sut.IsFeatureEnabledAsync(featureId, CancellationToken.None));
        }
Ejemplo n.º 3
0
        public async Task GetEnabledFeatures_ReturnsAllEnabled()
        {
            var features = new List <string>
            {
                "feature1",
                "feature2"
            };

            _fixture.MockGetAllEnabledFeaturesResponse(features);
            var client  = new FeatureHttpClient(new HttpClient(), _fixture.Settings);
            var sut     = new RestFeatureService(client);
            var context = new FeatureContext();

            Assert.Equal(features, sut.GetEnabledFeatures(context));
            Assert.Equal(features, await sut.GetEnabledFeaturesAsync(context));
            Assert.Equal(features, await sut.GetEnabledFeaturesAsync(context, CancellationToken.None));
        }
Ejemplo n.º 4
0
        public async Task IsFeatureEnabled_FeatureIsEnabled_ForTheUser_ReturnsTrue()
        {
            var featureId = Guid.NewGuid().ToString();

            _fixture.MockIsFeatureEnabledResponse(featureId, isEnabled: true, parameters: new Dictionary <string, string>
            {
                ["userid"] = "1"
            });
            var client  = new FeatureHttpClient(new HttpClient(), _fixture.Settings);
            var sut     = new RestFeatureService(client);
            var context = new FeatureContext
            {
                Parameters = new Dictionary <string, string> {
                    ["userid"] = "1"
                }
            };

            Assert.True(sut.IsFeatureEnabled(featureId, context));
            Assert.True(await sut.IsFeatureEnabledAsync(featureId, context));
            Assert.True(await sut.IsFeatureEnabledAsync(featureId, context, CancellationToken.None));
        }
Ejemplo n.º 5
0
        public async Task EvaluateFeatures_ReturnsAllEnabled()
        {
            var expected = new Dictionary <string, bool>
            {
                ["feature1"] = true,
                ["feature2"] = false,
            };
            var features = new List <string>
            {
                "feature1",
                "feature2"
            };

            _fixture.MockEvaluateFeaturesResponse(expected);
            var client  = new FeatureHttpClient(new HttpClient(), _fixture.Settings);
            var sut     = new RestFeatureService(client);
            var context = new FeatureContext();

            Assert.Equal(expected, sut.EvaluateFeatures(features, context));
            Assert.Equal(expected, await sut.EvaluateFeaturesAsync(features, context));
            Assert.Equal(expected, await sut.EvaluateFeaturesAsync(features, context, CancellationToken.None));
        }