コード例 #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);
        }
コード例 #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));
        }
コード例 #3
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));
        }