Welcome to mirror list, hosted at ThFree Co, Russian Federation.

XmlDsigExcC14NWithCommentsTransformTest.cs « System.Security.Cryptography.Xml « Test « System.Security « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9562da1864e55f4cfb544e89b9b6a7f82dece80a (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// XmlDsigExcC14NWithCommentsTransformTest.cs - NUnit Test Cases for
// XmlDsigExcC14NWithCommentsTransform
//
// Author:
//  original:
//	Sebastien Pouliot <sebastien@ximian.com>
//	Aleksey Sanin (aleksey@aleksey.com)
//  this file:
//	Gert Driesen <drieseng@users.sourceforge.net>
//
// (C) 2003 Aleksey Sanin (aleksey@aleksey.com)
// (C) 2004 Novell (http://www.novell.com)
// (C) 2008 Gert Driesen
//


using System;
using System.IO;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Xml;

using NUnit.Framework;

namespace MonoTests.System.Security.Cryptography.Xml {
	public class UnprotectedXmlDsigExcC14NWithCommentsTransform : XmlDsigExcC14NWithCommentsTransform {
		public UnprotectedXmlDsigExcC14NWithCommentsTransform ()
		{
		}

		public UnprotectedXmlDsigExcC14NWithCommentsTransform (string inclusiveNamespacesPrefixList)
			: base (inclusiveNamespacesPrefixList)
		{
		}

		public XmlNodeList UnprotectedGetInnerXml ()
		{
			return base.GetInnerXml ();
		}
	}

	[TestFixture]
	public class XmlDsigExcC14NWithCommentsTransformTest {
		private UnprotectedXmlDsigExcC14NWithCommentsTransform transform;

		[SetUp]
		public void SetUp ()
		{
			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform ();
		}

		[Test] // ctor ()
		public void Constructor1 ()
		{
			CheckProperties (transform);
			Assert.IsNull (transform.InclusiveNamespacesPrefixList);
		}

		[Test] // ctor (Boolean)
		public void Constructor2 ()
		{
			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform (null);
			CheckProperties (transform);
			Assert.IsNull (transform.InclusiveNamespacesPrefixList);

			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform (string.Empty);
			CheckProperties (transform);
			Assert.AreEqual (string.Empty, transform.InclusiveNamespacesPrefixList);

			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform ("#default xsd");
			CheckProperties (transform);
			Assert.AreEqual ("#default xsd", transform.InclusiveNamespacesPrefixList);
		}

		void CheckProperties (XmlDsigExcC14NWithCommentsTransform transform)
		{
			Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments",
				transform.Algorithm, "Algorithm");

			Type[] input = transform.InputTypes;
			Assert.AreEqual (3, input.Length, "Input #");
			// check presence of every supported input types
			bool istream = false;
			bool ixmldoc = false;
			bool ixmlnl = false;
			foreach (Type t in input) {
				if (t == typeof (Stream))
					istream = true;
				if (t == typeof (XmlDocument))
					ixmldoc = true;
				if (t == typeof (XmlNodeList))
					ixmlnl = true;
			}
			Assert.IsTrue (istream, "Input Stream");
			Assert.IsTrue (ixmldoc, "Input XmlDocument");
			Assert.IsTrue (ixmlnl, "Input XmlNodeList");

			Type[] output = transform.OutputTypes;
			Assert.AreEqual (1, output.Length, "Output #");
			Assert.AreEqual (typeof (Stream), output [0], "Output Type");
		}

		[Test]
		public void InputTypes ()
		{
			Type [] input = transform.InputTypes;
			input [0] = null;
			input [1] = null;
			input [2] = null;
			// property does not return a clone
			foreach (Type t in transform.InputTypes)
				Assert.IsNull (t);

			// it's not a static array
			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform ();
			foreach (Type t in transform.InputTypes)
				Assert.IsNotNull (t);
		}

		[Test]
		public void GetInnerXml ()
		{
			XmlNodeList xnl = transform.UnprotectedGetInnerXml ();
			Assert.IsNull (xnl, "Default InnerXml");
		}

		[Test]
		public void OutputTypes ()
		{
			// property does not return a clone
			transform.OutputTypes [0] = null;
			Assert.IsNull (transform.OutputTypes [0]);

			// it's not a static array
			transform = new UnprotectedXmlDsigExcC14NWithCommentsTransform ();
			Assert.IsNotNull (transform.OutputTypes [0]);
		}
	}
}