1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
4
using ICSharpCode.XmlEditor;
9
using XmlEditor.Tests.Utils;
11
namespace XmlEditor.Tests.Tree
14
/// Tests that a child element is added to the XML document by the
15
/// XmlTreeEditor with the correct namespace.
18
public class ExplicitNamespaceTestFixture : XmlTreeViewTestFixtureBase
20
XmlElement bodyElement;
26
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
27
nsManager.AddNamespace("h", "http://www.w3.org/1999/xhtml");
28
bodyElement = (XmlElement)editor.Document.SelectSingleNode("/h:html/h:body", nsManager);
29
mockXmlTreeView.SelectedElement = bodyElement;
30
mockXmlTreeView.SelectedNewElementsToReturn.Add("h1");
32
editor.AppendChildElement();
36
public void HeadlineElementNamespace()
38
XmlElement element = (XmlElement)bodyElement.FirstChild;
39
Assert.AreEqual("http://www.w3.org/1999/xhtml", element.NamespaceURI);
43
public void InsertBeforeDifferentNamespaceElementSelected()
45
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
46
nsManager.AddNamespace("a", "http://asp.net");
47
XmlElement buttonElement = (XmlElement)editor.Document.SelectSingleNode("//a:button", nsManager);
48
XmlElement headElement = (XmlElement)buttonElement.ParentNode;
49
mockXmlTreeView.SelectedElement = buttonElement;
50
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
51
mockXmlTreeView.SelectedNewElementsToReturn.Add("title");
53
editor.InsertElementBefore();
55
XmlElement titleElement = (XmlElement)headElement.FirstChild;
56
Assert.AreEqual(2, headElement.ChildNodes.Count);
57
Assert.AreEqual("title", titleElement.LocalName);
58
Assert.AreEqual("http://www.w3.org/1999/xhtml", titleElement.NamespaceURI);
62
public void InsertAfterDifferentNamespaceElementSelected()
64
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
65
nsManager.AddNamespace("a", "http://asp.net");
66
XmlElement buttonElement = (XmlElement)editor.Document.SelectSingleNode("//a:button", nsManager);
67
XmlElement headElement = (XmlElement)buttonElement.ParentNode;
68
mockXmlTreeView.SelectedElement = buttonElement;
69
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
70
mockXmlTreeView.SelectedNewElementsToReturn.Add("title");
72
editor.InsertElementAfter();
74
XmlElement titleElement = (XmlElement)headElement.LastChild;
75
Assert.AreEqual(2, headElement.ChildNodes.Count);
76
Assert.AreEqual("title", titleElement.LocalName);
77
Assert.AreEqual("http://www.w3.org/1999/xhtml", titleElement.NamespaceURI);
81
/// Returns the xhtml strict schema as the default schema.
83
protected override XmlSchemaCompletion DefaultSchemaCompletion {
84
get { return new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema()); }
87
protected override string GetXml()
89
return "<html xmlns='http://www.w3.org/1999/xhtml'>\r\n" +
91
"\t\t<asp:button xmlns:asp='http://asp.net'/>\r\n" +