forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptXmlTests.cs
More file actions
88 lines (75 loc) · 2.04 KB
/
Copy pathScriptXmlTests.cs
File metadata and controls
88 lines (75 loc) · 2.04 KB
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
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Xml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Waher.Script.Abstraction.Elements;
using Waher.Script.Objects;
using Waher.Script.Objects.Matrices;
using Waher.Script.Objects.Sets;
using Waher.Script.Units;
namespace Waher.Script.Test
{
[TestClass]
public class ScriptXmlTests
{
private void Test(string Script, string ExpectedOutput)
{
Variables v = new Variables();
Expression Exp = new Expression(Script);
XmlDocument Result = Exp.Evaluate(v) as XmlDocument;
Assert.IsNotNull(Result, "XmlDocument expected.");
Assert.AreEqual(ExpectedOutput ?? Script, Result.OuterXml);
}
[TestMethod]
public void XML_Test_01_Text()
{
this.Test("<a>Hello</a>", null);
}
[TestMethod]
public void XML_Test_02_Expression()
{
this.Test("<a><b>1</b><b><[1+2]></b></a>", "<a><b>1</b><b>3</b></a>");
}
[TestMethod]
public void XML_Test_03_Attributes()
{
this.Test("<a><b value=\"1\"/><b value=\"2\"/></a>", "<a><b value=\"1\" /><b value=\"2\" /></a>");
}
[TestMethod]
public void XML_Test_04_Attributes_Expression()
{
this.Test("x:=7;<a><b value=1/><b value=(2+x)/></a>", "<a><b value=\"1\" /><b value=\"9\" /></a>");
}
[TestMethod]
public void XML_Test_05_CDATA()
{
this.Test("<a><![CDATA[Hello World.]]></a>", null);
}
[TestMethod]
public void XML_Test_06_Comment()
{
this.Test("<a><!--Hello World.--></a>", null);
}
[TestMethod]
public void XML_Test_07_Mixed_1()
{
this.Test("<a>2+3=<[2+3]>.</a>", "<a>2+3=5.</a>");
}
[TestMethod]
public void XML_Test_08_Mixed_2()
{
this.Test("<a>2+3=<(2+3)>.</a>", "<a>2+3=5.</a>");
}
[TestMethod]
public void XML_Test_09_XML_Declaration()
{
this.Test("<?xml version=\"1.0\" encoding=\"UTF-8\"?><a>Hello</a>", null);
}
[TestMethod]
public void XML_Test_10_ProcessingInstruction()
{
this.Test("<?xml version=\"1.0\" encoding=\"UTF-8\"?><?xml-stylesheet type=\"text/xsl\" href=\"style.xsl\"?><a>Hello</a>", null);
}
}
}