Ejemplo n.º 1
0
        public async Task GetEnabledFeatures_DefaultStrategyHandler_ReturnsTrue()
        {
            string featureId;
            var    enabledFeatures    = 4;
            var    disabledFeatures   = 3;
            var    disabledFeatureIds = new List <string>();

            for (var i = 0; i < enabledFeatures; i++)
            {
                featureId = Guid.NewGuid().ToString();
                InMemoryFeatureStore.Features.TryAdd(featureId, FeatureExtensions.CreateFeatureWithDefaultStrategy(featureId, enabled: true));
            }

            for (var i = 0; i < disabledFeatures; i++)
            {
                featureId = Guid.NewGuid().ToString();
                disabledFeatureIds.Add(featureId);
                InMemoryFeatureStore.Features.TryAdd(featureId, FeatureExtensions.CreateFeatureWithDefaultStrategy(featureId, enabled: false));
            }

            var features      = _sut.GetEnabledFeatures(context: null);
            var featuresAsync = await _sut.GetEnabledFeaturesAsync(context : null, token : CancellationToken.None);

            Assert.Equal(0, features.Count(p => disabledFeatureIds.Any(f => f == p)));
            Assert.Equal(0, featuresAsync.Count(p => disabledFeatureIds.Any(f => f == p)));
        }