Skip to content

Commit

Permalink
Fixed unit test Xml_configuration_variableWithInnerAndAttribute_attri…
Browse files Browse the repository at this point in the history
…buteHasPrecedence (Ignore invalid config)
  • Loading branch information
snakefoot committed Jun 30, 2019
1 parent 10ba8e6 commit ba2e4de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/NLog/Config/NLogXmlElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public IEnumerable<KeyValuePair<string, string>> Values
if (SingleValueElement(child))
{
// Values assigned using nested node-elements. Maybe in combination with attributes
return Children.Where(item => SingleValueElement(item)).Select(item => new KeyValuePair<string, string>(item.Name, item.Value)).Concat(AttributeValues);
return AttributeValues.Concat(Children.Where(item => SingleValueElement(item)).Select(item => new KeyValuePair<string, string>(item.Name, item.Value)));
}
}
return AttributeValues;
Expand Down
14 changes: 8 additions & 6 deletions tests/NLog.UnitTests/Config/VariableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,17 @@ public void Xml_configuration_with_inner_returns_defined_variables_withValueElem
[Fact]
public void Xml_configuration_variableWithInnerAndAttribute_attributeHasPrecedence()
{
var configuration = XmlLoggingConfiguration.CreateFromXmlString(@"
<nlog throwExceptions='true'>
using (new NoThrowNLogExceptions())
{
var configuration = XmlLoggingConfiguration.CreateFromXmlString(@"
<nlog>
<variable name='var1' value='1'><value>2</value></variable>
</nlog>");
var nullEvent = LogEventInfo.CreateNullEvent();

var nullEvent = LogEventInfo.CreateNullEvent();

// Act & Assert
Assert.Equal("1", configuration.Variables["var1"].Render(nullEvent));
// Act & Assert
Assert.Equal("1", configuration.Variables["var1"].Render(nullEvent));
}
}

[Fact]
Expand Down

0 comments on commit ba2e4de

Please sign in to comment.