Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 58 additions & 0 deletions tests/dotenv.net.Tests/DotEnv.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,62 @@ public void AutoConfigShouldLoadDefaultEnvWithProbeOptions()
.Should()
.Be("world");
}

[Fact]
public void Should_Parse_Key_With_Colon_Correctly_Using_Read()
{
// Arrange
var envFiles = new[] { "appsettings-oidc-config.env" };

// Act
var result = new DotEnvOptions()
.WithEnvFiles(envFiles)
.Read();

// Assert
result.ContainsKey("OidcAuthentication:ClientId")
.Should()
.BeTrue();

result["OidcAuthentication:ClientId"]
.Should()
.Be("your-client-id");

result.ContainsKey("OidcAuthentication:ClientSecret")
.Should()
.BeTrue();

result["OidcAuthentication:ClientSecret"]
.Should()
.Be("your-client-secret");
}
// TODO: Uncomment if Loading Configuration Syntax get's correctly loaded via Envrionment Variables and returned
// [Fact]
// public void Should_Parse_Key_With_Colon_Correctly_And_Load_To_Environment() // this is failing because colones are not supported in environment variable names on Windows. TODO: Evaluate to add a extension or Helper to enable dotenv usage in hostbuilder IConfigurationBuilder?
// {
// // Arrange
// var envFiles = new[] { "appsettings-oidc-config.env" };

// // Act
// new DotEnvOptions()
// .WithEnvFiles(envFiles)
// .WithProbeForEnv()
// .WithExceptions()
// .Load();

// // Assert
// EnvReader.TryGetStringValue("OidcAuthentication:ClientId", out var value)
// .Should()
// .BeTrue();

// value.Should()
// .Be("your-client-id");

// EnvReader.TryGetStringValue("OidcAuthentication:ClientSecret", out value)
// .Should()
// .BeTrue();

// value.Should()
// .Be("your-client-secret");
// }
}
2 changes: 2 additions & 0 deletions tests/dotenv.net.Tests/appsettings-oidc-config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OidcAuthentication:ClientId=your-client-id
OidcAuthentication:ClientSecret=your-client-secret
3 changes: 3 additions & 0 deletions tests/dotenv.net.Tests/dotenv.net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Update="appsettings-oidc-config.env">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ascii.env">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down