Now, Concatenates only works if given parsers are in the same page or have positive page numbers.
Instead of using a property for PageNumber, create a method to pass the current page and the relative page Parsinator is currently trying to parse. Maybe introduce a method in the base class?
[Test]
public void Parse_ConcatenateTwoPagedParsersANegativeAndPositivePageNumber_ParsersValueFromBothParsersInGivenPages()
{
var p = new Dictionary<String, IList<IParse>>
{
{
"Key",
new List<IParse>
{
new Concatenate(key: "Value", separator: "|", new List<IParse>
{
new ParseFromRegex(key: "Result", pageNumber: -1, pattern: new Regex(@"Result:\s*(\w+)")),
new ParseFromRegex(key: "Value", pageNumber: 2, pattern: new Regex(@"Value:\s*(\d+)"))
})
}
}
};
var lines = FromPagesText(
@"Page1 This is a dummy page Page-3",
@"Page2 Value: 123456 Page-2",
@"Page3 Result: Foo Page-1");
var parser = new Parser(p);
var ds = parser.Parse(lines);
Assert.AreEqual("Foo|123456", ds["Key"]["Value"]);
}
Now, Concatenates only works if given parsers are in the same page or have positive page numbers.
Instead of using a property for
PageNumber, create a method to pass the current page and the relative page Parsinator is currently trying to parse. Maybe introduce a method in the base class?