public void OneNodeMarked() { string xml = "<root><foo/></root>"; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//root"); IDocument doc = MockDocument.Create(); doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); List <TextMarker> markers = new List <TextMarker>(); foreach (TextMarker marker in markerStrategy.TextMarker) { markers.Add(marker); } // Remove markers. XPathNodeTextMarker.RemoveMarkers(markerStrategy); List <TextMarker> markersAfterRemove = new List <TextMarker>(); foreach (TextMarker markerAfterRemove in markerStrategy.TextMarker) { markers.Add(markerAfterRemove); } XPathNodeTextMarker xpathNodeTextMarker = (XPathNodeTextMarker)markers[0]; Assert.AreEqual(1, markers.Count); Assert.AreEqual(1, xpathNodeTextMarker.Offset); Assert.AreEqual(4, xpathNodeTextMarker.Length); Assert.AreEqual(TextMarkerType.SolidBlock, xpathNodeTextMarker.TextMarkerType); Assert.AreEqual(0, markersAfterRemove.Count); Assert.AreEqual(XPathNodeTextMarker.MarkerBackColor, xpathNodeTextMarker.Color); }
public void NamespaceQuery() { string xml = "<?xml version='1.0'?>\r\n" + "<Xml1></Xml1>"; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//namespace::*"); IDocument doc = MockDocument.Create(); doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); List <TextMarker> markers = new List <TextMarker>(); foreach (TextMarker marker in markerStrategy.TextMarker) { markers.Add(marker); } Assert.AreEqual(0, markers.Count); Assert.AreEqual(1, nodes.Length); }
public void EmptyCommentNode() { string xml = "<!----><root/>"; XPathNodeMatch[] nodes = XmlView.SelectNodes(xml, "//comment()"); IDocument doc = MockDocument.Create(); doc.TextContent = xml; MarkerStrategy markerStrategy = new MarkerStrategy(doc); XPathNodeTextMarker.AddMarkers(markerStrategy, nodes); List <TextMarker> markers = new List <TextMarker>(); foreach (TextMarker marker in markerStrategy.TextMarker) { markers.Add(marker); } Assert.AreEqual(0, markers.Count); Assert.AreEqual(1, nodes.Length); }