Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Comment in tasks of sequential task makes preprocessor loose its count #161

Merged
merged 1 commit into from

2 participants

@RubenWillems

No description provided.

@RubenWillems RubenWillems merged commit b45cd4c into ccnet:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 23, 2012
  1. @obones @RubenWillems

    Issue 193: Comments in the structure should not count towards the fin…

    obones authored RubenWillems committed
    …al index as they will be stripped out in the end.
This page is out of date. Refresh to see the latest.
View
52 project/UnitTests/Core/Tasks/TaskBaseTests.cs
@@ -243,6 +243,31 @@ public void PreprocessParametersAddsDirectValueForValidNestedNodesDynamicValueWi
}
[Test]
+ public void PreprocessParametersAddsDirectValueForValidNestedNodesDynamicValueWithoutDefaultWithComment()
+ {
+ var document = new XmlDocument();
+ var xml = "<item attrib=\"value\"><subItems><subItem>$[value]</subItem><!-- this is a comment --><subItem>$[value2]</subItem></subItems></item>";
+ document.LoadXml(xml);
+
+ var task = new TestTask();
+ NetReflectorTypeTable typeTable = new NetReflectorTypeTable();
+ typeTable.Add(typeof(Item));
+ var actual = task.PreprocessParameters(typeTable, document.DocumentElement);
+ var expected = "<item attrib=\"value\"><subItems><subItem></subItem><!-- this is a comment --><subItem></subItem></subItems>" +
+ "<dynamicValues>" +
+ "<directValue>" +
+ "<parameter>value</parameter>" +
+ "<property>subItems[0]</property>" +
+ "</directValue>" +
+ "<directValue>" +
+ "<parameter>value2</parameter>" +
+ "<property>subItems[1]</property>" +
+ "</directValue>" +
+ "</dynamicValues></item>";
+ Assert.AreEqual(expected, actual.OuterXml);
+ }
+
+ [Test]
public void PreprocessParametersAddsDirectValueForValidDoublyNestedNodesDynamicValueWithoutDefault()
{
var document = new XmlDocument();
@@ -270,6 +295,33 @@ public void PreprocessParametersAddsDirectValueForValidDoublyNestedNodesDynamicV
}
[Test]
+ public void PreprocessParametersAddsDirectValueForValidDoublyNestedNodesDynamicValueWithoutDefaultWithComment()
+ {
+ var document = new XmlDocument();
+ var xml = "<item attrib=\"value\"><subItems><subItem><subSubItems><subSubItem><value>$[value]</value></subSubItem><!-- this is a comment --><subSubItem><value>$[value2]</value></subSubItem></subSubItems></subItem></subItems></item>";
+ document.LoadXml(xml);
+
+ var task = new TestTask();
+ NetReflectorTypeTable typeTable = new NetReflectorTypeTable();
+ typeTable.Add(typeof(Item));
+ typeTable.Add(typeof(SubItem));
+ typeTable.Add(typeof(subSubItem));
+ var actual = task.PreprocessParameters(typeTable, document.DocumentElement);
+ var expected = "<item attrib=\"value\"><subItems><subItem><subSubItems><subSubItem><value></value></subSubItem><!-- this is a comment --><subSubItem><value></value></subSubItem></subSubItems></subItem></subItems>" +
+ "<dynamicValues>" +
+ "<directValue>" +
+ "<parameter>value</parameter>" +
+ "<property>subItems[0].subSubItems[0].value</property>" +
+ "</directValue>" +
+ "<directValue>" +
+ "<parameter>value2</parameter>" +
+ "<property>subItems[0].subSubItems[1].value</property>" +
+ "</directValue>" +
+ "</dynamicValues></item>";
+ Assert.AreEqual(expected, actual.OuterXml);
+ }
+
+ [Test]
public void PreprocessParametersAddsSingleReplacementValueForValidAttributeDynamicValue()
{
var document = new XmlDocument();
View
3  project/core/tasks/DynamicValueUtility.cs
@@ -417,7 +417,8 @@ public static XmlNode ConvertXmlToDynamicValues(NetReflectorTypeTable typeTable,
// Find the index of the node
while (indexNode.PreviousSibling != null)
{
- position++;
+ if (indexNode.NodeType != XmlNodeType.Comment)
+ position++;
indexNode = indexNode.PreviousSibling;
}
Something went wrong with that request. Please try again.