-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
IniConfigurationExtensionsTest.cs
51 lines (43 loc) · 1.78 KB
/
IniConfigurationExtensionsTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using Xunit;
namespace Microsoft.Extensions.Configuration.Ini.Test
{
public class IniConfigurationExtensionsTest
{
[Theory]
[InlineData(null)]
[InlineData("")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/50867", TestPlatforms.Android)]
public void AddIniFile_ThrowsIfFilePathIsNullOrEmpty(string path)
{
// Arrange
var configurationBuilder = new ConfigurationBuilder();
// Act and Assert
var ex = Assert.Throws<ArgumentException>(
() => IniConfigurationExtensions.AddIniFile(configurationBuilder, path));
Assert.Equal("path", ex.ParamName);
Assert.StartsWith("File path must be a non-empty string.", ex.Message);
}
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/50867", TestPlatforms.Android)]
public void AddIniFile_ThrowsIfFileDoesNotExistAtPath()
{
// Arrange
var path = "file-does-not-exist.ini";
// Act and Assert
var ex = Assert.Throws<FileNotFoundException>(() => new ConfigurationBuilder().AddIniFile(path).Build());
Assert.StartsWith($"The configuration file '{path}' was not found and is not optional. The expected physical path was '", ex.Message);
}
[Fact]
public void AddIniFile_DoesNotThrowsIfFileDoesNotExistAtPathAndOptional()
{
// Arrange
var path = "file-does-not-exist.ini";
// Act and Assert
new ConfigurationBuilder().AddIniFile(path, optional: true).Build();
}
}
}