public void ProviderReloadWillReloadProperly() { string testFlagName = nameof(testFlagName); var originalFlag = new FeatureFlag(testFlagName, false); var featureFlagOptions = new FeatureFlagOption() { { testFlagName, originalFlag } }; string otherTestFlagName = nameof(otherTestFlagName); var otherFlag = new FeatureFlag(otherTestFlagName, false); var otherFeatureFlagOptions = new FeatureFlagOption() { { testFlagName, otherFlag } }; var optionsMonitor = new TestOptionsMonitor(featureFlagOptions); var provider = new ConfigurationFeatureFlagProvider(optionsMonitor); var originalFlags = provider.GetFlags(); optionsMonitor.Set(otherFeatureFlagOptions); var otherFlags = provider.GetFlags(); Assert.Single(originalFlags); Assert.NotNull(originalFlags.FirstOrDefault()); Assert.Equal(testFlagName, originalFlags.FirstOrDefault().Name); Assert.Single(otherFlags); Assert.NotNull(otherFlags.FirstOrDefault()); Assert.Equal(otherTestFlagName, otherFlags.FirstOrDefault().Name); }
public void ProviderReadsFromTheMonitor() { string testFlagName = nameof(testFlagName); var testFlag = new FeatureFlag(testFlagName, false); var optionMonitor = new Mock <IOptionsMonitor <FeatureFlagOption> >(); optionMonitor.Setup(x => x.CurrentValue).Returns(new FeatureFlagOption() { { testFlagName, testFlag } }); var provider = new ConfigurationFeatureFlagProvider(optionMonitor.Object); var flags = provider.GetFlags(); Assert.Single(flags); Assert.NotNull(flags.FirstOrDefault()); Assert.Equal(testFlagName, flags.FirstOrDefault().Name); }