Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update ConfigurationTests.cs
  • Loading branch information
maxkoshevoi committed Aug 15, 2021
commit d8bdc49f0c73941db9af853e9b309a1aca1311e2
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public void OnLoadErrorWillBeCalledOnIniLoadError()
_fileSystem.WriteFile("error.ini", @"IniKey1=IniValue1
IniKey1=IniValue2");

FileConfigurationProvider provider = null;
FileConfigurationProvider? provider = null;
Exception? error = null;
Action<FileLoadExceptionContext> loadError = c =>
{
Expand Down Expand Up @@ -452,7 +452,7 @@ public void OnLoadErrorCanIgnoreErrors()
{
_fileSystem.WriteFile("error.json", @"{""JsonKey1"": ");

FileConfigurationProvider provider = null;
FileConfigurationProvider? provider = null;
Action<FileLoadExceptionContext> jsonLoadError = c =>
{
provider = c.Provider;
Expand Down Expand Up @@ -490,7 +490,7 @@ public void CanSetValuesAndReloadValues()
foreach (var provider in configurationBuilder.Sources)
{
Assert.Equal("NewValue",
(provider as FileConfigurationProvider).Get("CommonKey1:CommonKey2:CommonKey3:CommonKey4"));
(provider as FileConfigurationProvider)?.Get("CommonKey1:CommonKey2:CommonKey3:CommonKey4"));
}

// Recover values by reloading
Expand All @@ -505,7 +505,7 @@ public void CanSetValuesAndReloadValues()
foreach (var provider in configurationBuilder.Sources)
{
Assert.Equal("NewValue",
(provider as FileConfigurationProvider).Get("CommonKey1:CommonKey2:CommonKey3:CommonKey4"));
(provider as FileConfigurationProvider)?.Get("CommonKey1:CommonKey2:CommonKey3:CommonKey4"));
}

// Recover values by reloading
Expand Down Expand Up @@ -834,7 +834,7 @@ public void LoadIncorrectJsonFile_ThrowException()
_fileSystem.WriteFile(_jsonFile, json);

var exception = Assert.Throws<InvalidDataException>(() => CreateBuilder().AddJsonFile(_jsonFile).Build());
Assert.Contains("Could not parse the JSON file.", exception.InnerException.Message);
Assert.Contains("Could not parse the JSON file.", exception.InnerException?.Message);
}

[Fact]
Expand Down