public void SelectedImageKey() { XmlComment comment = doc.CreateComment(String.Empty); XmlCommentTreeNode node = new XmlCommentTreeNode(comment); Assert.AreEqual(XmlCommentTreeNode.XmlCommentTreeNodeImageKey, node.SelectedImageKey); }
public void Init() { treeViewContainer = new XmlTreeViewContainerControl(); XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema(); XmlSchemaCompletionData xhtmlSchema = new XmlSchemaCompletionData(reader); XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection(); XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xhtmlSchema, String.Empty); treeViewContainer.LoadXml("<!-- comment --><html><body class='a'><p>Text</p></body></html>", provider); doc = treeViewContainer.Document; treeView = treeViewContainer.TreeView; commentTreeNode = (XmlCommentTreeNode)treeView.Nodes[0]; htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[1]; htmlTreeNode.Expanding(); bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0]; bodyTreeNode.Expanding(); paraTreeNode = (XmlElementTreeNode)bodyTreeNode.Nodes[0]; paraTreeNode.Expanding(); textTreeNode = (XmlTextTreeNode)paraTreeNode.Nodes[0]; }
public void WhiteSpaceRemoved() { XmlComment comment = doc.CreateComment(" \t\tTest\t\t "); XmlCommentTreeNode node = new XmlCommentTreeNode(comment); Assert.AreEqual("Test", node.Text); }
public void SetUp() { XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty); treeViewContainer = new DerivedXmlTreeViewContainerControl(); treeViewContainer.LoadXml("<!-- Root comment --><root><!-- Child comment --><child></child></root>", completionDataProvider); doc = treeViewContainer.Document; treeView = treeViewContainer.TreeView; // Get the root comment node in the tree. rootCommentNode = (XmlComment)doc.FirstChild; rootCommentTreeNode = treeView.Nodes[0] as XmlCommentTreeNode; // Get the child comment node in the tree. rootElementTreeNode = (XmlElementTreeNode)treeView.Nodes[1]; rootElementTreeNode.Expanding(); rootElement = rootElementTreeNode.XmlElement; childCommentTreeNode = rootElementTreeNode.Nodes[0] as XmlCommentTreeNode; childCommentNode = (XmlComment)rootElementTreeNode.XmlElement.FirstChild; childElementTreeNode = rootElementTreeNode.Nodes[1] as XmlElementTreeNode; childElement = childElementTreeNode.XmlElement; }
public void XmlCommentIsSame() { XmlComment comment = doc.CreateComment(String.Empty); XmlCommentTreeNode node = new XmlCommentTreeNode(comment); Assert.AreSame(comment, node.XmlComment); }
public void SetUp() { treeViewContainer = new DerivedXmlTreeViewContainerControl(); string xml = "<!-- Root comment --><root><!-- Child comment --><child></child></root>"; treeViewContainer.LoadXml(xml); doc = treeViewContainer.Document; treeView = treeViewContainer.TreeView; // Get the root comment node in the tree. rootCommentNode = (XmlComment)doc.FirstChild; rootCommentTreeNode = treeView.Nodes[0] as XmlCommentTreeNode; // Get the child comment node in the tree. rootElementTreeNode = (XmlElementTreeNode)treeView.Nodes[1]; rootElementTreeNode.Expanding(); rootElement = rootElementTreeNode.XmlElement; childCommentTreeNode = rootElementTreeNode.Nodes[0] as XmlCommentTreeNode; childCommentNode = (XmlComment)rootElementTreeNode.XmlElement.FirstChild; childElementTreeNode = rootElementTreeNode.Nodes[1] as XmlElementTreeNode; childElement = childElementTreeNode.XmlElement; }
public void SetUp() { XmlCompletionDataProvider completionDataProvider = new XmlCompletionDataProvider(new XmlSchemaCompletionDataCollection(), null, String.Empty); treeViewContainerControl = new XmlTreeViewContainerControl(); treeView = treeViewContainerControl.TreeView; treeViewContainerControl.LoadXml(GetXml(), completionDataProvider); doc = treeViewContainerControl.Document; clipboardHandler = treeViewContainerControl as IClipboardHandler; htmlElement = doc.DocumentElement; bodyElement = htmlElement.FirstChild as XmlElement; paragraphElement = bodyElement.SelectSingleNode("p") as XmlElement; paragraphText = paragraphElement.SelectSingleNode("text()") as XmlText; bodyComment = bodyElement.SelectSingleNode("comment()") as XmlComment; htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode; htmlTreeNode.PerformInitialization(); bodyTreeNode = htmlTreeNode.FirstNode as XmlElementTreeNode; bodyTreeNode.PerformInitialization(); bodyCommentTreeNode = bodyTreeNode.FirstNode as XmlCommentTreeNode; paragraphTreeNode = bodyTreeNode.LastNode as XmlElementTreeNode; paragraphTreeNode.PerformInitialization(); paragraphTextTreeNode = paragraphTreeNode.FirstNode as XmlTextTreeNode; }
public void InsertCommentAfterChildElement() { treeView.SelectedNode = childElementTreeNode; XmlComment newCommentNode = doc.CreateComment(String.Empty); treeView.InsertCommentAfter(newCommentNode); XmlCommentTreeNode commentNode = childElementTreeNode.NextNode as XmlCommentTreeNode; Assert.AreEqual(String.Empty, commentNode.Text); Assert.AreEqual(newCommentNode, commentNode.XmlComment); }
public void InsertCommentBeforeChildElement() { treeView.SelectedNode = childElementTreeNode; XmlComment newCommentNode = doc.CreateComment(String.Empty); treeView.InsertCommentBefore(newCommentNode); XmlCommentTreeNode commentNode = childElementTreeNode.PrevNode as XmlCommentTreeNode; Assert.AreEqual(String.Empty, commentNode.Text); Assert.AreEqual(newCommentNode, commentNode.XmlComment); Assert.IsNotNull(commentNode.Parent); }
public void CopyAndPasteCommentNode() { treeView.SelectedNode = bodyCommentTreeNode; treeViewContainerControl.Copy(); treeView.SelectedNode = htmlTreeNode; treeViewContainerControl.Paste(); XmlComment pastedCommentNode = htmlElement.LastChild as XmlComment; XmlCommentTreeNode pastedTreeNode = htmlTreeNode.LastNode as XmlCommentTreeNode; Assert.AreEqual(pastedCommentNode.InnerText, bodyComment.InnerText); Assert.AreEqual(bodyComment.InnerText.Trim(), pastedTreeNode.Text); Assert.IsTrue(treeViewContainerControl.IsDirty); }
public void GhostImage() { XmlComment comment = doc.CreateComment(String.Empty); XmlCommentTreeNode node = new XmlCommentTreeNode(comment); Assert.IsFalse(node.ShowGhostImage); node.ShowGhostImage = false; Assert.AreEqual(XmlCommentTreeNode.XmlCommentTreeNodeImageKey, node.ImageKey); node.ShowGhostImage = true; Assert.IsTrue(node.ShowGhostImage); Assert.AreEqual(XmlCommentTreeNode.XmlCommentTreeNodeGhostImageKey, node.ImageKey); }
public void InsertCommentAfterRootComment() { treeView.SelectedNode = rootCommentTreeNode; XmlComment newCommentNode = doc.CreateComment(String.Empty); treeView.InsertCommentAfter(newCommentNode); XmlCommentTreeNode commentNode = treeView.Nodes[1] as XmlCommentTreeNode; XmlCommentTreeNode originalCommentNode = treeView.Nodes[0] as XmlCommentTreeNode; Assert.AreEqual(3, treeView.Nodes.Count); Assert.AreEqual(String.Empty, commentNode.Text); Assert.AreEqual(newCommentNode, commentNode.XmlComment); Assert.AreSame(rootCommentTreeNode, originalCommentNode); Assert.IsNull(commentNode.Parent); }
public void InsertCommentAfter() { treeView.SelectedNode = bodyTreeNode; InsertCommentAfterCommand command = new InsertCommentAfterCommand(); command.Owner = treeViewContainer; command.Run(); XmlComment comment = bodyElement.NextSibling as XmlComment; Assert.IsNotNull(comment, "Expected a new comment node to be inserted."); XmlCommentTreeNode treeNode = bodyTreeNode.NextNode as XmlCommentTreeNode; Assert.IsNotNull(treeNode); Assert.AreSame(comment, treeNode.XmlComment); }
public void AddChildCommentNode() { treeView.SelectedNode = bodyTreeNode; AddChildCommentCommand command = new AddChildCommentCommand(); command.Owner = treeViewContainer; command.Run(); XmlComment comment = bodyElement.SelectSingleNode("comment()") as XmlComment; Assert.IsTrue(bodyElement.HasChildNodes); Assert.IsNotNull(comment, "Expected a new comment node to be appended."); XmlCommentTreeNode treeNode = bodyTreeNode.Nodes[0] as XmlCommentTreeNode; Assert.IsNotNull(treeNode); }
public void Init() { treeViewContainer = new DerivedXmlTreeViewContainerControl(); treeViewContainer.LoadXml("<!-- comment --><html><body class='a'><p>Text</p></body></html>"); doc = treeViewContainer.Document; treeView = treeViewContainer.TreeView; commentTreeNode = (XmlCommentTreeNode)treeView.Nodes[0]; htmlTreeNode = (XmlElementTreeNode)treeView.Nodes[1]; htmlTreeNode.Expanding(); bodyTreeNode = (XmlElementTreeNode)htmlTreeNode.Nodes[0]; bodyTreeNode.Expanding(); paraTreeNode = (XmlElementTreeNode)bodyTreeNode.Nodes[0]; paraTreeNode.Expanding(); textTreeNode = (XmlTextTreeNode)paraTreeNode.Nodes[0]; }
public void CutAndPasteCommentNode() { treeView.SelectedNode = bodyCommentTreeNode; treeViewContainerControl.Cut(); string bodyCommentTreeNodeImageKeyAfterCut = bodyCommentTreeNode.ImageKey; treeView.SelectedNode = htmlTreeNode; treeViewContainerControl.Paste(); XmlComment pastedCommentNode = htmlElement.LastChild as XmlComment; XmlCommentTreeNode pastedTreeNode = htmlTreeNode.LastNode as XmlCommentTreeNode; Assert.AreSame(bodyComment, pastedCommentNode); Assert.AreSame(bodyComment, pastedTreeNode.XmlComment); Assert.IsNull(bodyElement.SelectSingleNode("comment()")); Assert.AreEqual(XmlCommentTreeNode.XmlCommentTreeNodeGhostImageKey, bodyCommentTreeNodeImageKeyAfterCut); Assert.AreEqual(XmlCommentTreeNode.XmlCommentTreeNodeImageKey, pastedTreeNode.ImageKey, "Should not be ghost image."); }
public void SetUp() { treeViewContainerControl = new DerivedXmlTreeViewContainerControl(); treeView = treeViewContainerControl.TreeView; treeViewContainerControl.LoadXml(GetXml()); doc = treeViewContainerControl.Document; clipboardHandler = treeViewContainerControl as IClipboardHandler; htmlElement = doc.DocumentElement; bodyElement = htmlElement.FirstChild as XmlElement; paragraphElement = bodyElement.SelectSingleNode("p") as XmlElement; paragraphText = paragraphElement.SelectSingleNode("text()") as XmlText; bodyComment = bodyElement.SelectSingleNode("comment()") as XmlComment; htmlTreeNode = treeView.Nodes[0] as XmlElementTreeNode; htmlTreeNode.PerformInitialization(); bodyTreeNode = htmlTreeNode.FirstNode as XmlElementTreeNode; bodyTreeNode.PerformInitialization(); bodyCommentTreeNode = bodyTreeNode.FirstNode as XmlCommentTreeNode; paragraphTreeNode = bodyTreeNode.LastNode as XmlElementTreeNode; paragraphTreeNode.PerformInitialization(); paragraphTextTreeNode = paragraphTreeNode.FirstNode as XmlTextTreeNode; }