public void IsDisabledShouldInvertFeatureContext(IFeatureContext context, IFeature feature, bool enabled) { A.CallTo(() => context.IsEnabled(feature)) .Returns(enabled); bool result = FeatureContextExtensions.IsDisabled(context, feature); Assert.Equal(!enabled, result); A.CallTo(() => context.IsEnabled(feature)) .MustHaveHappened(); }
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 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)); }
public void ReturnsIsEnabledFromContext(IFeature feature, IFeatureContext context, bool expected) { A.CallTo(() => context.IsEnabled(feature)) .Returns(expected); bool result; using (ContextSwitcher.For(context)) { result = Feature.IsEnabled(feature); } Assert.Equal(expected, result); A.CallTo(() => context.IsEnabled(feature)) .MustHaveHappened(); }
public void ReturnsIsEnabledFromContext(IFeature feature, IFeatureContext context, bool expected) { A.CallTo(() => context.IsEnabled(feature)) .Returns(expected); bool result; using (ContextSwitcher.For(context)) { result = Feature.IsDisabled(feature); } Assert.Equal(!expected, result); A.CallTo(() => context.IsEnabled(feature)) .MustHaveHappened(); }
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); }
/// <summary> /// Checks to see if a feature is disabled. /// </summary> /// <param name="featureContext">The feature context.</param> /// <param name="feature">The feature.</param> /// <exception cref="System.ArgumentNullException"><paramref name="featureContext"/> is <see langword="null" />.</exception> /// <exception cref="System.ArgumentNullException"><paramref name="feature"/> is <see langword="null" />.</exception> /// <exception cref="Exceptions.FeatureStateNotFoundException">The given feature has no value assoicated with it.</exception> /// <returns><c>true</c> if the feature is disabled; otherwise, <c>false</c>.</returns> public static bool IsDisabled(this IFeatureContext featureContext, IFeature feature) { if (featureContext == null) { throw new ArgumentNullException(nameof(featureContext)); } if (feature == null) { throw new ArgumentNullException(nameof(feature)); } return(!featureContext.IsEnabled(feature)); }
/// <summary> /// Check to see if the given feature is enabled. /// </summary> /// <param name="feature">The feature</param> /// <exception cref="ArgumentNullException"><paramref name="feature"/> is <see langword="null" />.</exception> /// <exception cref="MissingFeatureContextException"><see cref="Feature.Context"/> is <see langword="null" />.</exception> /// <returns><c>true</c> if the feature is enabled; otherwise, <c>false</c>.</returns> public static bool IsEnabled(IFeature feature) { if (feature == null) { throw new ArgumentNullException(nameof(feature)); } if (Context == null) { throw new MissingFeatureContextException(); } return(Context.IsEnabled(feature)); }
public bool?IsEnabled(IFeatureContext featureContext, IFeature feature) { if (featureContext == null) { throw new ArgumentNullException(nameof(featureContext)); } if (feature == null) { throw new ArgumentNullException(nameof(feature)); } foreach (DependentFeatureTrait trait in feature.Traits.OfType <DependentFeatureTrait>()) { if (!featureContext.IsEnabled(trait.DependentFeature)) { return(false); } } return(null); }
public void FeatureContextHasDefaultValue() { Assert.True(_featureContext.IsEnabled(_testFeature)); }
public void ChildFeatureShouldBeDisabled() { bool result = _featureContext.IsEnabled(ChildFeature); Assert.False(result); }