Skip to content

Commit

Permalink
Merge/enable tests from serilog#551.
Browse files Browse the repository at this point in the history
  • Loading branch information
nblumhardt committed Oct 31, 2015
1 parent 9ba747d commit 10417b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Serilog/Settings/AppSettings/AppSettingsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace Serilog.Settings.AppSettings
{
class AppSettingsSettings : ILoggerSettings
{
readonly string SettingPrefix;
readonly string _settingPrefix;

public AppSettingsSettings(string settingPrefix)
{
SettingPrefix = string.Format("{0}:", settingPrefix);
_settingPrefix = $"{settingPrefix}:";
}

public void Configure(LoggerConfiguration loggerConfiguration)
Expand All @@ -38,8 +38,8 @@ public void Configure(LoggerConfiguration loggerConfiguration)
var settings = ConfigurationManager.AppSettings;

var pairs = settings.AllKeys
.Where(k => k.StartsWith(SettingPrefix))
.ToDictionary(k => k.Substring(SettingPrefix.Length), k => Environment.ExpandEnvironmentVariables(settings[k]));
.Where(k => k.StartsWith(_settingPrefix))
.ToDictionary(k => k.Substring(_settingPrefix.Length), k => Environment.ExpandEnvironmentVariables(settings[k]));

// Add the FullNetFx assembly by default so that all built-in Serilog sinks are available without "using"
pairs.Add("using:_ImpliedSerilogFullNetFx", typeof(AppSettingsSettings).Assembly.FullName);
Expand Down
3 changes: 3 additions & 0 deletions test/Serilog.Tests/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"profiles": {
"test": {
"commandName": "test"
},
"test-dnxcore50": {
"commandName": "test",
"sdkVersion": "dnx-coreclr-win-x86.1.0.0-beta8"
}
Expand Down
2 changes: 1 addition & 1 deletion test/Serilog.Tests/Settings/AppSettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void EnvironmentVariableExpansionIsApplied()
Assert.NotEqual("%PATH%", evt.Properties["Path"].LiteralValue());
}

[Fact(Skip = "Fails on DNX451")]
[Fact]
public void CanUseCustomPrefixToConfigureSettings()
{
const string prefix1 = "custom1:serilog";
Expand Down
2 changes: 2 additions & 0 deletions test/Serilog.Tests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<configuration>
<appSettings>
<add key="serilog:enrich:with-property:Path" value="%PATH%" />
<add key="custom1:serilog:minimum-level" value="Warning" />
<add key="custom2:serilog:minimum-level" value="Error" />
</appSettings>
</configuration>
3 changes: 2 additions & 1 deletion test/Serilog.Tests/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"version": "2.0.0-beta-*",
"commands": {
"test": "xunit.runner.dnx"
"test": "xunit.runner.dnx",
"test-dnxcore50": "xunit.runner.dnx"
},
"dependencies": {
"Newtonsoft.Json": "7.0.1",
Expand Down

0 comments on commit 10417b6

Please sign in to comment.