1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
//
// System.Xml.XmlCommentTests.cs
//
// Author: Duncan Mak (duncan@ximian.com)
// Author: Martin Willemoes Hansen (mwh@sysrq.dk)
//
// (C) Ximian, Inc.
// (C) 2003 Martin Willemoes Hansen
//
using System;
using System.Xml;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlCommentTests : Assertion
{
XmlDocument document;
XmlComment comment;
XmlNode original;
XmlNode deep;
XmlNode shallow;
[SetUp]
public void GetReady ()
{
document = new XmlDocument ();
}
[Test]
public void XmlCommentCloneNode ()
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
original = comment;
shallow = comment.CloneNode (false); // shallow
XmlNodeBaseProperties (original, shallow);
deep = comment.CloneNode (true); // deep
XmlNodeBaseProperties (original, deep);
AssertEquals ("Value incorrectly cloned",
original.Value, deep.Value);
AssertEquals ("deep cloning differs from shallow cloning",
deep.OuterXml, shallow.OuterXml);
}
[Test]
public void XmlCommentInnerAndOuterXml ()
{
comment = document.CreateComment ("foo");
AssertEquals (String.Empty, comment.InnerXml);
AssertEquals ("<!--foo-->", comment.OuterXml);
}
[Test]
public void XmlCommentIsReadOnly ()
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
AssertEquals ("XmlComment IsReadOnly property broken",
comment.IsReadOnly, false);
}
[Test]
public void XmlCommentLocalName ()
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
AssertEquals (comment.NodeType + " LocalName property broken",
comment.LocalName, "#comment");
}
[Test]
public void XmlCommentName ()
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
AssertEquals (comment.NodeType + " Name property broken",
comment.Name, "#comment");
}
[Test]
public void XmlCommentNodeType ()
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
AssertEquals ("XmlComment NodeType property broken",
comment.NodeType.ToString (), "Comment");
}
internal void XmlNodeBaseProperties (XmlNode original, XmlNode cloned)
{
document.LoadXml ("<root><foo></foo></root>");
comment = document.CreateComment ("Comment");
// assertequals (original.nodetype + " was incorrectly cloned.",
// original.baseuri, cloned.baseuri);
AssertNull (cloned.ParentNode);
AssertEquals ("Value incorrectly cloned",
original.Value, cloned.Value);
Assert ("Copies, not pointers", !Object.ReferenceEquals (original,cloned));
}
}
}
|