コード例 #1
0
        public void AddJsonFile_ThrowsIfFileDoesNotExistAtPath()
        {
            // Arrange
            var path    = Path.Combine(Directory.GetCurrentDirectory(), "file-does-not-exist.ini");
            var builder = new ConfigurationBuilder();

            // Act and Assert
            var ex = Assert.Throws <FileNotFoundException>(
                () => IniConfigurationExtension.AddIniFile(builder, path));

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

            // Act and Assert
            var ex = Assert.Throws <ArgumentException>(
                () => IniConfigurationExtension.AddIniFile(builder, path));

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