blob: b1c0ce7cfb95b636acc101d936cb95d5fd7f45b7 (
plain)
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
|
//
// System.Xml.XmlTextWriterTests
//
// Authors:
// Kral Ferch <kral_ferch@hotmail.com>
// Martin Willemoes Hansen <mwh@sysrq.dk>
//
// (C) 2002 Kral Ferch
// (C) 2003 Martin Willemoes Hansen
//
using System;
using System.Xml;
using NUnit.Framework;
namespace MonoTests.System.Xml
{
[TestFixture]
public class XmlTextTests
{
XmlDocument document;
XmlText text;
bool inserted;
bool inserting;
bool changed;
bool changing;
bool removed;
bool removing;
[SetUp]
public void GetReady ()
{
document = new XmlDocument ();
}
private void EventNodeInserted(Object sender, XmlNodeChangedEventArgs e)
{
inserted = true;
}
private void EventNodeInserting (Object sender, XmlNodeChangedEventArgs e)
{
inserting = true;
}
private void EventNodeChanged(Object sender, XmlNodeChangedEventArgs e)
{
changed = true;
}
private void EventNodeChanging (Object sender, XmlNodeChangedEventArgs e)
{
changing = true;
}
private void EventNodeRemoved(Object sender, XmlNodeChangedEventArgs e)
{
removed = true;
}
private void EventNodeRemoving (Object sender, XmlNodeChangedEventArgs e)
{
removing = true;
}
[Test]
public void InnerAndOuterXml ()
{
text = document.CreateTextNode ("&<>\"'");
Assert.AreEqual (String.Empty, text.InnerXml);
Assert.AreEqual ("&<>\"'", text.OuterXml);
}
[Test]
public void SplitText ()
{
document.LoadXml ("<root>test text.</root>");
document.NodeInserted += new XmlNodeChangedEventHandler(EventNodeInserted);
document.NodeChanged += new XmlNodeChangedEventHandler(EventNodeChanged);
document.NodeRemoved += new XmlNodeChangedEventHandler(EventNodeRemoved);
XmlText t = document.DocumentElement.FirstChild as XmlText;
t.SplitText (5);
Assert.IsNotNull (t.NextSibling);
Assert.AreEqual ("test ", t.Value);
Assert.AreEqual ("text.", t.NextSibling.Value);
Assert.IsTrue (changed);
Assert.IsTrue (inserted);
Assert.IsTrue (!removed);
}
}
}
|