public void RootDisposesChangeTokenRegistrations() { var changeToken = new ChangeToken(); var providerMock = new Mock <IConfigurationProvider>(); providerMock.Setup(p => p.GetReloadToken()).Returns(changeToken); var config = new ConfigurationRoot(new IConfigurationProvider[] { providerMock.Object, }); Assert.NotEmpty(changeToken.Callbacks); config.Dispose(); Assert.Empty(changeToken.Callbacks); }
public void RootDisposesProviders() { var provider1 = new TestConfigurationProvider("foo", "foo-value"); var provider2 = new DisposableTestConfigurationProvider("bar", "bar-value"); var provider3 = new TestConfigurationProvider("baz", "baz-value"); var provider4 = new DisposableTestConfigurationProvider("qux", "qux-value"); var provider5 = new DisposableTestConfigurationProvider("quux", "quux-value"); var config = new ConfigurationRoot(new IConfigurationProvider[] { provider1, provider2, provider3, provider4, provider5 }); Assert.Equal("foo-value", config["foo"]); Assert.Equal("bar-value", config["bar"]); Assert.Equal("baz-value", config["baz"]); Assert.Equal("qux-value", config["qux"]); Assert.Equal("quux-value", config["quux"]); config.Dispose(); Assert.True(provider2.IsDisposed); Assert.True(provider4.IsDisposed); Assert.True(provider5.IsDisposed); }