public void AddJsonFile_ThrowsIfFileDoesNotExistAtPath() { // Arrange var path = Path.Combine(Directory.GetCurrentDirectory(), "file-does-not-exist.json"); var builder = new ConfigurationBuilder(); // Act and Assert var ex = Assert.Throws <FileNotFoundException>(() => JsonConfigurationExtension.AddJsonFile(builder, path)); Assert.Equal($"The configuration file '{path}' was not found and is not optional.", ex.Message); }
public void AddJsonFile_ThrowsIfFilePathIsNullOrEmpty(string path) { // Arrange var builder = new ConfigurationBuilder(); // Act and Assert var ex = Assert.Throws <ArgumentException>(() => JsonConfigurationExtension.AddJsonFile(builder, path)); Assert.Equal("path", ex.ParamName); Assert.StartsWith("File path must be a non-empty string.", ex.Message); }