public void ProviderThrowsDirectoryNotFoundExceptionWhenNotFound(string physicalPath) { var fileProviderMock = new Mock <IFileProvider>(); fileProviderMock.Setup(fp => fp.Watch(It.IsAny <string>())).Returns(new ConfigurationRootTest.ChangeToken()); fileProviderMock.Setup(fp => fp.GetFileInfo(It.IsAny <string>())).Returns(new FileInfoImpl(physicalPath)); var source = new FileConfigurationSourceImpl { FileProvider = fileProviderMock.Object, ReloadOnChange = true, }; var provider = new FileConfigurationProviderImpl(source); var exception = Assert.Throws <DirectoryNotFoundException>(() => provider.Load()); Assert.Contains(physicalPath, exception.Message); }
public void ProviderDisposesChangeTokenRegistration() { var changeToken = new ConfigurationRootTest.ChangeToken(); var fileProviderMock = new Mock <IFileProvider>(); fileProviderMock.Setup(fp => fp.Watch(It.IsAny <string>())).Returns(changeToken); var provider = new FileConfigurationProviderImpl(new FileConfigurationSourceImpl { FileProvider = fileProviderMock.Object, ReloadOnChange = true, }); Assert.NotEmpty(changeToken.Callbacks); provider.Dispose(); Assert.Empty(changeToken.Callbacks); }