-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from andrewlock/net8
Update to test on .NET 8
- Loading branch information
Showing
10 changed files
with
173 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
11 changes: 2 additions & 9 deletions
11
...pades.Configuration.KubeSecrets.Tests/NetEscapades.Configuration.KubeSecrets.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/NetEscapades.Configuration.Tests.Common/Directory.Build.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Project> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../../'))" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
...capades.Configuration.Validation.Tests/NetEscapades.Configuration.Validation.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...scapades.Configuration.Yaml.Tests/YamlConfigurationExtensionsConfigurationManagerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.Extensions.Configuration; | ||
using NetEscapades.Configuration.Tests.Common; | ||
using Xunit; | ||
|
||
#if NET6_0_OR_GREATER | ||
|
||
namespace NetEscapades.Configuration.Yaml | ||
{ | ||
public class YamlConfigurationExtensionsConfigurationManagerTests | ||
{ | ||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("")] | ||
public void AddYamlFile_ThrowsIfFilePathIsNullOrEmpty(string path) | ||
{ | ||
// Arrange | ||
var configurationManager = new ConfigurationManager(); | ||
|
||
// Act and Assert | ||
var ex = Assert.Throws<ArgumentException>(() => YamlConfigurationExtensions.AddYamlFile(configurationManager, path)); | ||
Assert.Equal("path", ex.ParamName); | ||
Assert.StartsWith("File path must be a non-empty string.", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlFile_ThrowsIfFileDoesNotExistAtPathAndIsOptional() | ||
{ | ||
// Arrange | ||
var path = "file-does-not-exist.Yaml"; | ||
|
||
// Act and Assert | ||
var ex = Assert.Throws<FileNotFoundException>(() => new ConfigurationManager().AddYamlFile(path).Build()); | ||
Assert.StartsWith($"The configuration file '{path}' was not found and is not optional.", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlFile_DoesNotThrowIfFileDoesNotExistAndIsOptional() | ||
{ | ||
// Arrange | ||
var path = "file-does-not-exist.Yaml"; | ||
|
||
// Act and Assert | ||
new ConfigurationManager().AddYamlFile(path, optional: true).Build(); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlFile_DoesNotThrowIfAbsolutePathDirectoryDoesNotExist() | ||
{ | ||
// Arrange | ||
var path = Path.Combine(Directory.GetCurrentDirectory(), "does", "not", "exist", "file-does-not-exist.Yaml"); | ||
|
||
// Act and Assert | ||
new ConfigurationManager() | ||
.AddYamlFile(path, optional: true) | ||
.Build(); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlStream_ThrowIfIsNull() | ||
{ | ||
// Act and Assert | ||
Assert.Throws<ArgumentNullException>(() => new ConfigurationManager().AddYamlStream(null).Build()); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlStream_DoesNotThrowIfIsNotNull() | ||
{ | ||
// Arrange | ||
var stream = TestStreamHelpers.StringToStream("Test: test"); | ||
|
||
// Act and Assert | ||
var builder = new ConfigurationManager().AddYamlStream(stream); | ||
var config = builder.Build(); | ||
Assert.Equal("test", config["Test"]); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlStream_SupportsLoadingDataTwice() | ||
{ | ||
// Arrange | ||
var stream = TestStreamHelpers.StringToStream("Test: test"); | ||
|
||
var builder = new ConfigurationManager() | ||
.AddYamlStream(stream); | ||
builder.Build(); | ||
|
||
var config = builder.Build(); | ||
Assert.Equal("test", config["Test"]); | ||
} | ||
|
||
[Fact] | ||
public void AddYamlStream_SupportsDisposingStream() | ||
{ | ||
// Arrange | ||
var builder = new ConfigurationManager(); | ||
using (var stream = TestStreamHelpers.StringToStream("Test: test")) | ||
{ | ||
builder.AddYamlStream(stream); | ||
} | ||
|
||
Assert.Equal("test", builder["Test"]); | ||
} | ||
} | ||
} | ||
|
||
#endif |