Skip to content

Conversation

@tsimbalar
Copy link
Member

@tsimbalar tsimbalar commented Oct 13, 2018

Trying to figure out the bug #142 by adding a failing test.

Given a sink configuration method like :

public static LoggerConfiguration DummyWithConfiguration(
	this LoggerSinkConfiguration loggerSinkConfiguration,
	IConfiguration appConfiguration,
	IConfigurationSection configurationSection,
	string pathFormat,
	LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
{
	return loggerSinkConfiguration.Sink(new DummyConfigurationSink(appConfiguration, configurationSection), restrictedToMinimumLevel);
}

This test fails (at the first assertion) :

[Fact]
public void SinkWithIConfigurationArguments()
{
	var json = @"{
		""Serilog"": {            
			""Using"": [""TestDummies""],
			""WriteTo"": [{
				""Name"": ""DummyWithConfiguration"",
				""Args"": {""pathFormat"" : ""C:\\"",
						   ""configurationSection"" : { ""foo"" : ""bar"" } }
			}]        
		}
	}";

	// IConfiguration and IConfigurationSection arguments do not have
	// default values so they will throw if they are not populated


	DummyConfigurationSink.Reset();
	var log = ConfigFromJson(json)
		.CreateLogger();


	log.Write(Some.InformationEvent());

	Assert.NotNull(DummyConfigurationSink.Configuration);
	Assert.NotNull(DummyConfigurationSink.ConfigSection);
	Assert.Equal("bar", DummyConfigurationSink.ConfigSection["foo"]);
}

First I want to be sure that this test should pass, and I understand how the IConfiguration/IConfigurationSection support works.

@MV10 if you come by, do you agree with me that such a test should pass ? Thanks !

@tsimbalar
Copy link
Member Author

Closing this PR in favor of #144 that provides fixes for both #142 and #143

@tsimbalar tsimbalar closed this Oct 14, 2018
@tsimbalar tsimbalar deleted the bugfix2 branch October 17, 2018 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant