示例#1
0
        public void AddXmlFile_ThrowsIfFileDoesNotExistAtPath()
        {
            // Arrange
            var path = Path.Combine(Directory.GetCurrentDirectory(), "file-does-not-exist.xml");
            var configurationBuilder = new ConfigurationBuilder();

            // Act and Assert
            var ex = Assert.Throws <FileNotFoundException>(() => XmlConfigurationExtensions.AddXmlFile(configurationBuilder, path));

            Assert.Equal($"The configuration file '{path}' was not found and is not optional.", ex.Message);
        }
示例#2
0
        public void AddXmlFile_ThrowsIfFilePathIsNullOrEmpty(string path)
        {
            // Arrange
            var configurationBuilder = new ConfigurationBuilder();

            // Act and Assert
            var ex = Assert.Throws <ArgumentException>(() => XmlConfigurationExtensions.AddXmlFile(configurationBuilder, path));

            Assert.Equal("path", ex.ParamName);
            Assert.StartsWith("File path must be a non-empty string.", ex.Message);
        }