public void FeatureWithMultipleDefaultValueTraitsThrows(FeatureFixture feature, IEnumerable <DefaultValueTrait> defaultValueTraits, DefaultValueToggler sut) { feature.Traits.AddRange(defaultValueTraits); Assert.Throws <InvalidFeatureException>(() => sut.IsEnabled(null, feature)); }
public void ReturnsNullWhenNoValueExists(FeatureFixture feature, Fixture fixture, AppSettingsToggler sut) { feature.Id = fixture.Create <string>(); bool?result = sut.IsEnabled(null, feature); Assert.Equal(null, result); }
public void FeatureWithDefaultValueTraitShouldReturnDefaultValue(FeatureFixture feature, DefaultValueTrait defaultValueTrait, DefaultValueToggler sut) { feature.Traits.Add(defaultValueTrait); bool?result = sut.IsEnabled(null, feature); Assert.Equal(defaultValueTrait.DefaultValue, result); }
public void ChecksStateOfDependentFeatures(IFeatureContext featureContext, FeatureFixture feature, IFeature dependentFeature, DependentFeatureToggler sut) { A.CallTo(() => featureContext.IsEnabled(dependentFeature)) .Returns(true); feature.Traits.Add(new DependentFeatureTrait(dependentFeature)); sut.IsEnabled(featureContext, feature); A.CallTo(() => featureContext.IsEnabled(dependentFeature)) .MustHaveHappened(); }
public void ReturnsAppSettingValueWhenSet(string value, bool?expected, FeatureFixture feature, Fixture fixture, AppSettingsToggler sut) { // Apparently AutoFixture will reuse the feature feature.Id = fixture.Create <string>(); using (AppSetting.Use($"{AppSettingsToggler.SettingsPrefix}{feature.Id}", value)) { bool?result = sut.IsEnabled(null, feature); Assert.Equal(expected, result); } }
public void FeatureWithoutDefaultValueTraitShouldReturnNull(FeatureFixture feature, DefaultValueToggler sut) { bool?result = sut.IsEnabled(null, feature); Assert.Null(result); }
public void ReturnsFalseWhenDependentFeatureIsEnabled(IFeatureContext featureContext, FeatureFixture feature, IFeature dependentFeature, DependentFeatureToggler sut) { A.CallTo(() => featureContext.IsEnabled(dependentFeature)) .Returns(true); feature.Traits.Add(new DependentFeatureTrait(dependentFeature)); bool?result = sut.IsEnabled(featureContext, feature); Assert.Null(result); }
public void ChecksStateOfAllDependentFeatures(IFeatureContext featureContext, FeatureFixture feature, IFeature dependentFeature, DependentFeatureToggler sut) { A.CallTo(() => featureContext.IsEnabled(dependentFeature)) .Returns(true); // Hey, it works! feature.Traits.Add(new DependentFeatureTrait(dependentFeature)); feature.Traits.Add(new DependentFeatureTrait(dependentFeature)); feature.Traits.Add(new DependentFeatureTrait(dependentFeature)); sut.IsEnabled(featureContext, feature); A.CallTo(() => featureContext.IsEnabled(dependentFeature)) .MustHaveHappened(Repeated.Exactly.Times(3)); }