public void ResolveFilePath() { var testFile = Path.GetTempFileName(); var testDir = Path.GetDirectoryName(testFile); var testFileName = Path.GetFileName(testFile); var mockSourceRoot = new MockConfigurationBuilder { BasePath = testDir }; var actualPath = ConfigurationHelper.ResolveConfigurationFilePath(mockSourceRoot, testFileName); Assert.Equal(testFile, actualPath); }
public void NotThrowWhenFileDoesNotExists() { var testFile = Path.GetTempFileName(); var testDir = Path.GetDirectoryName(testFile); var testFileName = Path.GetFileName(testFile); var mockBuilder = new MockConfigurationBuilder { BasePath = testDir }; File.Delete(testFile); var path = ConfigurationHelper.ResolveConfigurationFilePath(mockBuilder, testFileName); Assert.Equal(testFile, path); }
public void ThrowWhenBasePathIsNull() { var testFile = "config.j"; var mockSourceRoot = new MockConfigurationBuilder(); var expectErrorMessage = Resources.FormatError_MissingBasePath( testFile, typeof(IConfigurationBuilder).Name, nameof(mockSourceRoot.BasePath)); var exception = Assert.Throws<InvalidOperationException>(() => { ConfigurationHelper.ResolveConfigurationFilePath(mockSourceRoot, testFile); }); Assert.Equal(expectErrorMessage, exception.Message); }
public void ThrowWhenBasePathIsNull() { var testFile = "config.j"; var mockSourceRoot = new MockConfigurationBuilder(); var expectErrorMessage = Resources.FormatError_MissingBasePath( testFile, typeof(IConfigurationBuilder).Name, nameof(mockSourceRoot.BasePath)); var exception = Assert.Throws <InvalidOperationException>(() => { ConfigurationHelper.ResolveConfigurationFilePath(mockSourceRoot, testFile); }); Assert.Equal(expectErrorMessage, exception.Message); }