public void StylePriorityCompound_Test() { PDFStyleMatcher matcher = "doc:Div .red"; Assert.AreEqual(21, matcher.Selector.Priority, "Element and class should be 21"); matcher = "doc:Div .red.blue"; Assert.AreEqual(31, matcher.Selector.Priority, "Element and multiple Classes should be 31"); matcher = "#id .red.blue"; Assert.AreEqual(35, matcher.Selector.Priority, "ID with classes should be 35"); matcher = "doc:Div .red.blue #id"; Assert.AreEqual(531, matcher.Selector.Priority, "Element, multiple Classes and id should be 531"); matcher = "#id .red.blue doc:Div"; Assert.AreEqual(135, matcher.Selector.Priority, "ID, classes and element should be 135"); matcher = "#id doc:Div.red.blue doc:Div.red"; Assert.AreEqual(345, matcher.Selector.Priority, "ID, element with classes and element with classes should be 345"); matcher = "#id doc:Div.red.blue doc:Div.red .green"; Assert.AreEqual(2345, matcher.Selector.Priority, "ID, element with classes, element with classes and class should be 2345"); }
public void StylePriorityMultiple_Test() { PDFStyleMatcher matcher = "doc:Div.red"; Assert.AreEqual(3, matcher.Selector.Priority, "Element and class should be 3"); matcher = "doc:Div.red.blue"; Assert.AreEqual(4, matcher.Selector.Priority, "Element and multiple Classes should be 4"); matcher = "#id.red.blue"; Assert.AreEqual(8, matcher.Selector.Priority, "ID with classes should be 8"); }
public void SimpleIsMatch_Test() { int priority; var defn = new StyleDefn(); defn.Match = PDFStyleMatcher.Parse(".red"); var div = new Div(); div.StyleClass = "red"; var result = defn.IsMatchedTo(div, out priority); Assert.IsTrue(result, "The definition did not match the component"); }
public void StyleMatcherSimpleParsing_Test() { string test = ".red"; var parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Class Test failed"); Assert.IsNull(parsed.Selector.AppliedElement, "Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Class Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "#NewComponentID"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual("NewComponentID", parsed.Selector.AppliedID, "ID Test failed"); Assert.IsNull(parsed.Selector.AppliedClass, "ID Test failed"); Assert.IsNull(parsed.Selector.AppliedElement, "ID Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "ID Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "ID Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "ID Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Component"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual("doc:Component", parsed.Selector.AppliedElement, "Type Test failed"); Assert.IsNull(parsed.Selector.AppliedClass, "Type Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Type Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Type Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Type Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Type Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); }
public void DualIsMatch_Test() { int priority; var defn = new StyleDefn(); defn.Match = PDFStyleMatcher.Parse("doc:Div.red"); var div = new Div(); div.ID = "MyDiv"; div.StyleClass = "red"; div.ElementName = "doc:Div"; var result = defn.IsMatchedTo(div, out priority); Assert.IsTrue(result, "The definition did not match the component"); }
public void StylePriorityCompoundParent_Test() { //Using a direct parent - we double that selector priority PDFStyleMatcher matcher = "doc:Div > .red"; Assert.AreEqual(41, matcher.Selector.Priority, "Element and class should be 41 (20*2+ 1)"); matcher = "doc:Div > .red.blue"; Assert.AreEqual(61, matcher.Selector.Priority, "Element and multiple Classes should be 61 (20*3 + 1)"); matcher = "#id > .red.blue"; Assert.AreEqual(65, matcher.Selector.Priority, "ID with child classes should be 65"); matcher = "doc:Div .red.blue > #id"; Assert.AreEqual(1031, matcher.Selector.Priority, "Element, multiple Classes and child id should be 1031 ((200 * 5) + (10 * 3) + 1)"); }
public void StylePrioritySingle_Test() { PDFStyleMatcher matcher = "doc:Div"; Assert.AreEqual(1, matcher.Selector.Priority, "Element on it's own should be 1"); matcher = ".red"; Assert.AreEqual(2, matcher.Selector.Priority, "Class on it's own should be 2"); matcher = ".red.blue"; Assert.AreEqual(3, matcher.Selector.Priority, "multiple Classes on their own should be 3"); matcher = ".red.blue.green"; Assert.AreEqual(4, matcher.Selector.Priority, "3 Classes on their own should be 4"); matcher = "#id"; Assert.AreEqual(5, matcher.Selector.Priority, "ID on it's own should be 5"); }
public void StyleMatcherMultiple_Test() { PDFStyleMatcher red = ".red"; Div div = new Div(); div.StyleClass = "red"; int priority; bool result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); div.StyleClass = "red bordered"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); div.StyleClass = "bordered red"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); div.StyleClass = "redish red"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); div.StyleClass = "redish red bordered"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); div.StyleClass = "redish reder bordered"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsFalse(result, "Should not have matched on the applied class of " + div.StyleClass); div.StyleClass = "redred red"; result = red.IsMatchedTo(div, ComponentState.Normal, out priority); Assert.IsTrue(result, "Did not match on the applied class of " + div.StyleClass); }
protected virtual PDFStyleMatcher AssertMatcher() { if (null == this._match) { this._fromApplied = true; if (string.IsNullOrEmpty(this.AppliedID) && string.IsNullOrEmpty(this.AppliedClass) && (null == this.AppliedType)) { return(new PDFStyleCatchAllMatcher()); } var stack = new PDFStyleSelector() { AppliedClass = string.IsNullOrEmpty(this.AppliedClass) ? null : new PDFStyleClassSelector(this.AppliedClass), AppliedID = this.AppliedID, AppliedType = this.AppliedType, AppliedState = this.AppliedState, Placement = StylePlacement.Any }; this._match = new PDFStyleMatcher(stack); } return(this._match); }
public StyleDefn(string match) : this() { this.Match = match; }
public void StyleMatcherDualParsing_Test() { string test = "doc:Table.red"; var parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Type.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Type.Class Test failed"); Assert.AreEqual("doc:Table", parsed.Selector.AppliedElement, "Type.Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Type.Class Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Type.Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Type.Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Div#NewComponentID"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual("NewComponentID", parsed.Selector.AppliedID, "Type.ID Test failed"); Assert.IsNull(parsed.Selector.AppliedClass, "Type.ID Test failed"); Assert.AreEqual("doc:Div", parsed.Selector.AppliedElement, "Type.ID Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Type.ID Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Type.ID Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Type.ID Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = ".red#ComponentID"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.IsNull(parsed.Selector.AppliedElement, "Class.Type Test failed"); Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Class.Type Test failed"); Assert.AreEqual("ComponentID", parsed.Selector.AppliedID, "Class.Type Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Class.Type Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Class.Type Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Class.Type Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = ".red.blue"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.IsNull(parsed.Selector.AppliedElement, "Class.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Class.Class Test failed"); Assert.AreEqual(".red.blue", parsed.Selector.AppliedClass.ToString(), "Class.Class Test failed"); //Check the class matcher values - stored in reverse order Assert.AreEqual("blue", parsed.Selector.AppliedClass.ClassName); Assert.IsNotNull(parsed.Selector.AppliedClass.AndClass); Assert.AreEqual("red", parsed.Selector.AppliedClass.AndClass.ClassName); Assert.IsNull(parsed.Selector.AppliedClass.AndClass.AndClass); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); }
public void StyleMatcherMultipleParsing_Test() { string test = "doc:Table.red, doc:Cell.red"; var parsed = PDFStyleMatcher.Parse(test); Assert.IsInstanceOfType(parsed, typeof(PDFStyleMultipleMatcher)); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); var multi = (PDFStyleMultipleMatcher)parsed; Assert.IsNotNull(multi); Assert.IsNotNull(multi.Selector); Assert.IsNotNull(multi.Next); Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Type.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Type.Class Test failed"); Assert.AreEqual("doc:Cell", parsed.Selector.AppliedElement, "Type.Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Type.Class Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Type.Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Type.Class Test failed"); parsed = multi.Next; Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Type.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Type.Class Test failed"); Assert.AreEqual("doc:Table", parsed.Selector.AppliedElement, "Type.Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Type.Class Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Type.Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Type.Class Test failed"); //3 with last complex test = "doc:Table.blue, doc:Cell.red, doc:Page.red.green > doc:Div#MyDiv"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); //Because these are parsed in reverse order, then they need to be tested in reverse order Assert.IsNull(parsed.Selector.AppliedClass, "First Tripple style Test failed"); Assert.AreEqual("MyDiv", parsed.Selector.AppliedID, "First Tripple style Test failed"); Assert.AreEqual("doc:Div", parsed.Selector.AppliedElement, "First Tripple style Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, "First Tripple style Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, "First Tripple style Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "First Tripple style Test failed"); Assert.AreEqual(".red.green", parsed.Selector.Ancestor.AppliedClass.ToString(), "First Tripple style Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, "First Tripple style Test failed"); Assert.AreEqual("doc:Page", parsed.Selector.Ancestor.AppliedElement, "First Tripple style Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.DirectParent, "First Tripple style Test failed"); //Move to the red cell Assert.IsInstanceOfType(parsed, typeof(PDFStyleMultipleMatcher)); multi = (PDFStyleMultipleMatcher)parsed; parsed = multi.Next; Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), "Second Tripple style Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Second Tripple style Test failed"); Assert.AreEqual("doc:Cell", parsed.Selector.AppliedElement, "Second Tripple style Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Second Tripple style Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Second Tripple style Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Second Tripple style Test failed"); //Move to the blue table Assert.IsInstanceOfType(parsed, typeof(PDFStyleMultipleMatcher)); multi = (PDFStyleMultipleMatcher)parsed; parsed = multi.Next; Assert.AreEqual(".blue", parsed.Selector.AppliedClass.ToString(), "Third Tripple style Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Third Tripple style Test failed"); Assert.AreEqual("doc:Table", parsed.Selector.AppliedElement, "Third Tripple style Test failed"); Assert.IsNull(parsed.Selector.Ancestor, "Third Tripple style Test failed"); Assert.IsFalse(parsed.Selector.HasAncestor, "Third Tripple style Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Third Tripple style Test failed"); }
public void StyleMatcherParentAncestor_Test() { string test = ".blue > .red"; var parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); //Because these are parsed in reverse order, then they need to be Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.AppliedElement, ".Class .Class Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, ".Class.Class Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, ".Class .Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, ".Class .Class Test failed"); Assert.AreEqual(".blue", parsed.Selector.Ancestor.AppliedClass.ToString(), ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedElement, ".Class .Class Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.DirectParent, ".Class .Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Page.red > doc:Div#MyDiv"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); //Because these are parsed in reverse order, then they need to be Assert.IsNull(parsed.Selector.AppliedClass, "Element.Class > Element.ID Test failed"); Assert.AreEqual("MyDiv", parsed.Selector.AppliedID, "Element.Class > Element.ID Test failed"); Assert.AreEqual("doc:Div", parsed.Selector.AppliedElement, "Element.Class > Element.ID Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, "Element.Class > Element.ID Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, "Element.Class > Element.ID Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Element.Class > Element.ID Test failed"); Assert.AreEqual(".red", parsed.Selector.Ancestor.AppliedClass.ToString(), "Element.Class > Element.ID Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, "Element.Class > Element.ID Test failed"); Assert.AreEqual("doc:Page", parsed.Selector.Ancestor.AppliedElement, "Element.Class > Element.ID Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.DirectParent, "Element.Class > Element.ID Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Page.red > doc:Table doc:Cell.alt.green doc:Date"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); PDFStyleSelector match = parsed.Selector; //Because these are parsed in reverse order, then they need to be read in that order //doc:Date Assert.IsNull(match.AppliedClass, "Element.Class > Element Element.Class Element Test failed"); Assert.IsNull(match.AppliedID, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual("doc:Date", match.AppliedElement, "Element.Class > Element Element.Class Element Test failed"); Assert.IsNotNull(match.Ancestor, "Element.Class > Element Element.Class Element Test failed"); Assert.IsTrue(match.HasAncestor, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual(match.Placement, StylePlacement.Any, "Element.Class > Element Element.Class Element Test failed"); //doc:Cell.alt match = match.Ancestor; Assert.AreEqual(".alt.green", match.AppliedClass.ToString(), "Element.Class > Element Element.Class Element Test failed"); Assert.IsNull(match.AppliedID, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual("doc:Cell", match.AppliedElement, "Element.Class > Element Element.Class Element Test failed"); Assert.IsNotNull(match.Ancestor, "Element.Class > Element Element.Class Element Test failed"); Assert.IsTrue(match.HasAncestor, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual(match.Placement, StylePlacement.Any, "Element.Class > Element Element.Class Element Test failed"); //doc.Table match = match.Ancestor; Assert.IsNull(match.AppliedClass, "Element.Class > Element Element.Class Element Test failed"); Assert.IsNull(match.AppliedID, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual("doc:Table", match.AppliedElement, "Element.Class > Element Element.Class Element Test failed"); Assert.IsNotNull(match.Ancestor, "Element.Class > Element Element.Class Element Test failed"); Assert.IsTrue(match.HasAncestor, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual(match.Placement, StylePlacement.Any, "Element.Class > Element Element.Class Element Test failed"); //doc:Page.red > match = match.Ancestor; Assert.AreEqual(".red", match.AppliedClass.ToString(), "Element.Class > Element Element.Class Element Test failed"); Assert.IsNull(match.AppliedID, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual("doc:Page", match.AppliedElement, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual(match.Placement, StylePlacement.DirectParent, "Element.Class > Element Element.Class Element Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); }
public void StyleMatcherSimpleAncestor_Test() { string test = ".blue .red"; var parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); //Because these are parsed in reverse order, then they need to be Assert.AreEqual(".red", parsed.Selector.AppliedClass.ToString(), ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.AppliedElement, ".Class .Class Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, ".Class.Class Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, ".Class .Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, ".Class .Class Test failed"); Assert.AreEqual(".blue", parsed.Selector.Ancestor.AppliedClass.ToString(), ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, ".Class .Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedElement, ".Class .Class Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.Any, ".Class .Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Table.red doc:Cell.blue"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); //Because these are parsed in reverse order, then they need to be Assert.AreEqual(".blue", parsed.Selector.AppliedClass.ToString(), "Element.Class Element.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Element.Class Element.Class Test failed"); Assert.AreEqual("doc:Cell", parsed.Selector.AppliedElement, "Element.Class Element.Class Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, "Element.ClassElement.Class Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, "Element.Class Element.Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Element.Class Element.Class Test failed"); Assert.AreEqual(".red", parsed.Selector.Ancestor.AppliedClass.ToString(), "Element.Class Element.Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, "Element.Class Element.Class Test failed"); Assert.AreEqual("doc:Table", parsed.Selector.Ancestor.AppliedElement, "Element.Class Element.Class Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.Any, "Element.Class Element.Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); test = "doc:Table.red.green doc:Cell.blue"; parsed = PDFStyleMatcher.Parse(test); Assert.IsNotNull(parsed); Assert.IsNotNull(parsed.Selector); //Because these are parsed in reverse order, then they need to be Assert.AreEqual(".blue", parsed.Selector.AppliedClass.ToString(), "Element.Class.Class Element.Class Test failed"); Assert.IsNull(parsed.Selector.AppliedID, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual("doc:Cell", parsed.Selector.AppliedElement, "Element.Class.Class Element.Class Test failed"); Assert.IsNotNull(parsed.Selector.Ancestor, "Element.Class.Class Element.Class Test failed"); Assert.IsTrue(parsed.Selector.HasAncestor, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual(parsed.Selector.Placement, StylePlacement.Any, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual(".red.green", parsed.Selector.Ancestor.AppliedClass.ToString(), "Element.Class.Class Element.Class Test failed"); Assert.AreEqual("green", parsed.Selector.Ancestor.AppliedClass.ClassName, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual("red", parsed.Selector.Ancestor.AppliedClass.AndClass.ClassName, "Element.Class.Class Element.Class Test failed"); Assert.IsNull(parsed.Selector.Ancestor.AppliedID, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual("doc:Table", parsed.Selector.Ancestor.AppliedElement, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual(parsed.Selector.Ancestor.Placement, StylePlacement.Any, "Element.Class.Class Element.Class Test failed"); Assert.AreEqual(test, parsed.ToString(), "ToString did not match"); }