Skip to content

Commit

Permalink
Added testcase for <variable> with inner <value> (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
304NotModified committed Jun 12, 2019
1 parent 46847fa commit 00709be
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/NLog.UnitTests/Config/VariableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,29 @@ public void Xml_configuration_returns_defined_variables()
Assert.Equal("]]", LogManager.Configuration.Variables["suffix"].OriginalText);
}

[Fact]
public void Xml_configuration_with_inner_returns_defined_variables_withValueElement()
{
var configuration = XmlLoggingConfiguration.CreateFromXmlString(@"
<nlog throwExceptions='true'>
<variable name='prefix'>
<value><![CDATA[
newline
]]></value>
</variable>
<variable name='suffix'><value>]]</value></variable>
</nlog>");

var nullEvent = LogEventInfo.CreateNullEvent();

// Act & Assert
Assert.Equal("\nnewline\n", configuration.Variables["prefix"].Render(nullEvent).Replace("\r", ""));
Assert.Equal("]]", configuration.Variables["suffix"].Render(nullEvent));
}


[Fact]
public void NLogConfigurationExceptionShouldThrown_WhenVariableNodeIsWrittenToWrongPlace()
{
Expand Down

0 comments on commit 00709be

Please sign in to comment.