public void Feature_CacheResult_UnlessRefresh() { b.Info.Flow(); const int CALLSTOMAKE = 4; try { var mfp = new MockFeatureProvider(); mfp.MockAddBoolFeature(FEATURENAME, true); Feature.AddProvider(mfp); var ft = Feature.GetFeatureByName(FEATURENAME); for (int i = 0; i < CALLSTOMAKE; i++) { // Not really part of the test, we just want to call active but might as well make it an assertion. Assert.True(ft.IsActive()); } var ct = mfp.HowManyCallsForThisFeature(FEATURENAME); // +1 because of the first GetFeatureByName, then the additonal CALLSTOMAKE in the loop. Assert.Equal(CALLSTOMAKE + 1, ct); } finally { Feature.Reset(); } }
public void Feature_CacheResult() { b.Info.Flow(); const int CALLSTOMAKE = 4; try { var mfp = new MockFeatureProvider(); mfp.MockAddBoolFeature(FEATURENAME, true); Feature.AddProvider(mfp); var ft = Feature.GetFeatureByName(FEATURENAME); for (int i = 0; i < CALLSTOMAKE; i++) { // Not really part of the test, we just want to call active but might as well make it an assertion. Assert.True(ft.Active); } var ct = mfp.HowManyCallsForThisFeature(FEATURENAME); Assert.Equal(1, ct); } finally { Feature.Reset(); } }
public void Provider_ReturnsNamedFeature() { b.Info.Flow(); try { var mfp = new MockFeatureProvider(); mfp.MockAddBoolFeature(FEATURENAME, true); Feature.AddProvider(mfp); var ft = Feature.GetFeatureByName(FEATURENAME); Assert.NotNull(ft); Assert.True(ft.Active); } finally { Feature.Reset(); } }
public void Provider_ReturnsOnlyOnesItProvides() { b.Info.Flow(); try { string featureName1 = FEATURENAME + "1"; string featureName2 = FEATURENAME + "2"; var mfp = new MockFeatureProvider(); mfp.MockAddBoolFeature(featureName1, true); Feature.AddProvider(mfp); var f1 = Feature.GetFeatureByName(featureName1); var f2 = Feature.GetFeatureByName(featureName2); Assert.NotNull(f1); Assert.Null(f2); } finally { Feature.Reset(); } }