diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2008-10-14 22:33:13 +0400 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2008-10-14 22:33:13 +0400 |
commit | 19098dd864d9536086d004593e3e9a33bba2fb66 (patch) | |
tree | 92458eed054fc1207a75346ed1edb7ec6388c5c0 /mcs/class/System.Security/Test | |
parent | 2b9876326aa2aac5d1c87646eba5b524d9f7901b (diff) |
* XmlDsigXsltTranformTest.cs: Added test for .ctor (bool).
* XmlDsigEnvelopedTransformTest.cs: Added test for .ctor (bool). Use
Assert class. Improved properties tests.
* XmlDsigC14TransformTest.cs: Added test for .ctor (bool).
* XmlDsigExcC14NTransformTest.cs: Added .ctor tests and added asserts
IncludsiveNamespacesPrefixList
* XmlDsigExcC14NWithCommentsTransformTest.cs: Added basic .ctor and
properties tests.
* XmlDsigC14NWithCommentsTransformTest.cs: Fixed line endings.
* XmlLicenseTransformTest.cs: Added basic .ctor and properties tests.
* XmlDsigBase64Transform.cs: Use constant for Algorithm namespace.
* XmlDsigExcC14NTransform.cs: Fixed ctors to use WithComments
algorithm if includeComments is true. Assign includeNamespacesPrefixList
to instance field.
* XmlDsigExcC14NWithCommentsTransform.cs: Remove unnecessary
assignment to Algorithm now that base ctor is fixed.
* XmlDsigC14NWithCommentsTransform.cs: Remove unnecessary assignment
to Algorithm now that base ctor is fixed.
* XmlDsigC14NTransform.cs: In default ctor, just invoke .ctor (bool).
In .ctor (bool), assign WithComments algorithm if includeComments is
true. Use constants for Algorithm namespace.
* XmlDsigEnvelopedSignatureTransform.cs: Use constant for Algorithm
namespace.
* XmlDsigXPathTransform.cs: Use constant for Algorithm namespace.
* XmlDsigXsltTransform.cs: Use constant for Algorithm namespace.
* XmlLicenseTransform.cs: Assign Algorithm in ctor.
* XmlSignature.cs: Added constant for XmlLicenseTransform algorithm.
* System.Security_test.dll.sources: Added XmlLicenseTransformTest.cs
and XmlDsigExcC14NWithCommentsTransformTest.cs.
svn path=/trunk/mcs/; revision=115803
Diffstat (limited to 'mcs/class/System.Security/Test')
7 files changed, 441 insertions, 34 deletions
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog index eb530a614c3..e5820b3bca9 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ChangeLog @@ -1,3 +1,16 @@ +2008-10-14 Gert Driesen <drieseng@users.sourceforge.net> + + * XmlDsigXsltTranformTest.cs: Added test for .ctor (bool). + * XmlDsigEnvelopedTransformTest.cs: Added test for .ctor (bool). Use + Assert class. Improved properties tests. + * XmlDsigC14TransformTest.cs: Added test for .ctor (bool). + * XmlDsigExcC14NTransformTest.cs: Added .ctor tests and added asserts + IncludsiveNamespacesPrefixList + * XmlDsigExcC14NWithCommentsTransformTest.cs: Added basic .ctor and + properties tests. + * XmlDsigC14NWithCommentsTransformTest.cs: Fixed line endings. + * XmlLicenseTransformTest.cs: Added basic .ctor and properties tests. + 2008-09-17 Sebastien Pouliot <sebastien@ximian.com> * SignedXmlTest.cs: Add test cases for HMACSHA[256|384|512] and diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs index ba1074399ea..0b76d3ea656 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NTransformTest.cs @@ -23,6 +23,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { // Note: GetInnerXml is protected in XmlDsigC14NTransform making it // difficult to test properly. This class "open it up" :-) public class UnprotectedXmlDsigC14NTransform : XmlDsigC14NTransform { + public UnprotectedXmlDsigC14NTransform () + { + } + + public UnprotectedXmlDsigC14NTransform (bool includeComments) + : base (includeComments) + { + } public XmlNodeList UnprotectedGetInnerXml () { return base.GetInnerXml (); @@ -52,11 +60,27 @@ namespace MonoTests.System.Security.Cryptography.Xml { catch {} } - [Test] - public void Properties () + [Test] // ctor () + public void Constructor1 () { AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm); + CheckProperties (transform); + } + [Test] // ctor (Boolean) + public void Constructor2 () + { + transform = new UnprotectedXmlDsigC14NTransform (true); + AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", transform.Algorithm); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigC14NTransform (false); + AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm); + CheckProperties (transform); + } + + void CheckProperties (XmlDsigC14NTransform transform) + { Type[] input = transform.InputTypes; Assert ("Input #", (input.Length == 3)); // check presence of every supported input types diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs index 967bd47c283..15cfee93d91 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransformTest.cs @@ -22,6 +22,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { // Note: GetInnerXml is protected in XmlDsigEnvelopedSignatureTransform making it // difficult to test properly. This class "open it up" :-) public class UnprotectedXmlDsigEnvelopedSignatureTransform : XmlDsigEnvelopedSignatureTransform { + public UnprotectedXmlDsigEnvelopedSignatureTransform () + { + } + + public UnprotectedXmlDsigEnvelopedSignatureTransform (bool includeComments) + : base (includeComments) + { + } public XmlNodeList UnprotectedGetInnerXml () { @@ -30,59 +38,73 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigEnvelopedSignatureTransformTest : Assertion { - - protected UnprotectedXmlDsigEnvelopedSignatureTransform transform; + public class XmlDsigEnvelopedSignatureTransformTest { + private UnprotectedXmlDsigEnvelopedSignatureTransform transform; [SetUp] - protected void SetUp () + public void SetUp () { transform = new UnprotectedXmlDsigEnvelopedSignatureTransform (); } - [Test] - public void Properties () + [Test] // ctor () + public void Constructor1 () + { + CheckProperties (transform); + } + + [Test] // ctor (Boolean) + public void Constructor2 () + { + transform = new UnprotectedXmlDsigEnvelopedSignatureTransform (true); + CheckProperties (transform); + transform = new UnprotectedXmlDsigEnvelopedSignatureTransform (false); + CheckProperties (transform); + } + + void CheckProperties (XmlDsigEnvelopedSignatureTransform transform) { - AssertEquals ("Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#enveloped-signature", + transform.Algorithm, "Algorithm"); - Type[] input = transform.InputTypes; - AssertEquals ("Input Length", 3, input.Length); + Type [] input = transform.InputTypes; + Assert.AreEqual (3, input.Length, "Input Length"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; bool ixmlnl = false; foreach (Type t in input) { - if (t.ToString () == "System.Xml.XmlDocument") + if (t == typeof (XmlDocument)) ixmldoc = true; - if (t.ToString () == "System.Xml.XmlNodeList") + if (t == typeof (XmlNodeList)) ixmlnl = true; + if (t == typeof (Stream)) + istream = true; } - Assert ("No Input Stream", !istream); - Assert ("Input XmlDocument", ixmldoc); - Assert ("Input XmlNodeList", ixmlnl); + Assert.IsTrue (istream, "Input Stream"); + Assert.IsTrue (ixmldoc, "Input XmlDocument"); + Assert.IsTrue (ixmlnl, "Input XmlNodeList"); - Type[] output = transform.OutputTypes; - AssertEquals ("Output Length", 2, output.Length); + Type [] output = transform.OutputTypes; + Assert.AreEqual (2, output.Length, "Output Length"); // check presence of every supported output types bool oxmlnl = false; bool oxmldoc = false; foreach (Type t in output) { - if (t == null) - throw new InvalidOperationException (); - if (t.ToString () == "System.Xml.XmlNodeList") + if (t == typeof (XmlNodeList)) oxmlnl = true; - if (t.ToString () == "System.Xml.XmlDocument") + if (t == typeof (XmlDocument)) oxmldoc = true; } - Assert ("Output XmlNodeList", oxmlnl); - Assert ("Output XmlDocument", oxmldoc); + Assert.IsTrue (oxmlnl, "Output XmlNodeList"); + Assert.IsTrue (oxmldoc, "Output XmlDocument"); } - protected void AssertEquals (string msg, XmlNodeList expected, XmlNodeList actual) + void AssertEquals (XmlNodeList expected, XmlNodeList actual, string msg) { - for (int i=0; i < expected.Count; i++) { + for (int i = 0; i < expected.Count; i++) { if (expected [i].OuterXml != actual [i].OuterXml) - Fail (msg + " [" + i + "] expected " + expected[i].OuterXml + " bug got " + actual[i].OuterXml); + Assert.Fail (msg + " [" + i + "] expected " + expected [i].OuterXml + " bug got " + actual [i].OuterXml); } } @@ -90,7 +112,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void GetInnerXml () { // Always returns null - AssertNull (transform.UnprotectedGetInnerXml ()); + Assert.IsNull (transform.UnprotectedGetInnerXml ()); } private XmlDocument GetDoc () @@ -108,7 +130,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = GetDoc (); transform.LoadInput (doc); object o = transform.GetOutput (); - AssertEquals ("EnvelopedSignature result", doc, o); + Assert.AreEqual (doc, o, "EnvelopedSignature result"); } [Test] @@ -117,7 +139,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = GetDoc (); transform.LoadInput (doc.ChildNodes); XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); - AssertEquals ("EnvelopedSignature result", doc.ChildNodes, xnl); + AssertEquals (doc.ChildNodes, xnl, "EnvelopedSignature result"); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs index 1ba7a8ef6cc..14837ddd250 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NTransformTest.cs @@ -34,6 +34,24 @@ namespace MonoTests.System.Security.Cryptography.Xml { // Note: GetInnerXml is protected in XmlDsigExcC14NTransform making it // difficult to test properly. This class "open it up" :-) public class UnprotectedXmlDsigExcC14NTransform : XmlDsigExcC14NTransform { + public UnprotectedXmlDsigExcC14NTransform () + { + } + + public UnprotectedXmlDsigExcC14NTransform (bool includeComments) + : base (includeComments) + { + } + + public UnprotectedXmlDsigExcC14NTransform (string inclusiveNamespacesPrefixList) + : base (inclusiveNamespacesPrefixList) + { + } + + public UnprotectedXmlDsigExcC14NTransform (bool includeComments, string inclusiveNamespacesPrefixList) + : base (includeComments, inclusiveNamespacesPrefixList) + { + } public XmlNodeList UnprotectedGetInnerXml () { return base.GetInnerXml (); @@ -63,11 +81,83 @@ namespace MonoTests.System.Security.Cryptography.Xml { catch {} } - [Test] - public void Properties () + [Test] // ctor () + public void Constructor1 () { AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + } + + [Test] // ctor (Boolean) + public void Constructor2 () + { + transform = new UnprotectedXmlDsigExcC14NTransform (true); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (false); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + } + [Test] // ctor (String) + public void Constructor3 () + { + transform = new UnprotectedXmlDsigExcC14NTransform (null); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (string.Empty); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", string.Empty, transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform ("#default xsd"); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", "#default xsd", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + } + + [Test] // ctor (Boolean, String) + public void Constructor4 () + { + transform = new UnprotectedXmlDsigExcC14NTransform (true, null); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (true, string.Empty); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", string.Empty, transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (true, "#default xsd"); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", "#default xsd", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (false, null); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (false, string.Empty); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", string.Empty, transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + + transform = new UnprotectedXmlDsigExcC14NTransform (false, "#default xsd"); + AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); + AssertEquals ("InclusiveNamespacesPrefixList", "#default xsd", transform.InclusiveNamespacesPrefixList); + CheckProperties (transform); + } + + void CheckProperties (XmlDsigExcC14NTransform transform) + { Type[] input = transform.InputTypes; Assert ("Input #", (input.Length == 3)); // check presence of every supported input types diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs new file mode 100644 index 00000000000..7d1ca4b4071 --- /dev/null +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransformTest.cs @@ -0,0 +1,143 @@ +// +// 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 +// + +#if NET_2_0 + +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]); + } + } +} + +#endif diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs index 5d835ac7018..568023c8ac1 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXsltTransformTest.cs @@ -24,6 +24,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { // Note: GetInnerXml is protected in XmlDsigXsltTransform making it // difficult to test properly. This class "open it up" :-) public class UnprotectedXmlDsigXsltTransform : XmlDsigXsltTransform { + public UnprotectedXmlDsigXsltTransform () + { + } + + public UnprotectedXmlDsigXsltTransform (bool includeComments) + : base (includeComments) + { + } public XmlNodeList UnprotectedGetInnerXml () { return base.GetInnerXml (); @@ -41,8 +49,22 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform = new UnprotectedXmlDsigXsltTransform (); } - [Test] - public void Properties () + [Test] // ctor () + public void Constructor1 () + { + CheckProperties (transform); + } + + [Test] // ctor (Boolean) + public void Constructor2 () + { + transform = new UnprotectedXmlDsigXsltTransform (true); + CheckProperties (transform); + transform = new UnprotectedXmlDsigXsltTransform (false); + CheckProperties (transform); + } + + void CheckProperties (XmlDsigXsltTransform transform) { AssertEquals ("Algorithm", "http://www.w3.org/TR/1999/REC-xslt-19991116", transform.Algorithm); diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs new file mode 100644 index 00000000000..ecc16f62a46 --- /dev/null +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlLicenseTransformTest.cs @@ -0,0 +1,93 @@ +// +// XmlLicenseTransformTest.cs - NUnit Test Cases for XmlLicenseTransform +// +// 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 +// + +#if NET_2_0 + +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 UnprotectedXmlLicenseTransform : XmlLicenseTransform { + public XmlNodeList UnprotectedGetInnerXml () + { + return base.GetInnerXml (); + } + } + + [TestFixture] + public class XmlLicenseTransformTest { + private UnprotectedXmlLicenseTransform transform; + + [SetUp] + public void SetUp () + { + transform = new UnprotectedXmlLicenseTransform (); + } + + [Test] // ctor () + public void Constructor1 () + { + Assert.AreEqual ("urn:mpeg:mpeg21:2003:01-REL-R-NS:licenseTransform", + transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.Decryptor, "Decryptor"); + + Type[] input = transform.InputTypes; + Assert.AreEqual (1, input.Length, "Input #"); + Assert.AreEqual (typeof (XmlDocument), input [0], "Input Type"); + + Type[] output = transform.OutputTypes; + Assert.AreEqual (1, output.Length, "Output #"); + Assert.AreEqual (typeof (XmlDocument), output [0], "Output Type"); + } + + [Test] + public void InputTypes () + { + // property does not return a clone + transform.InputTypes [0] = null; + Assert.IsNull (transform.InputTypes [0]); + + // it's not a static array + transform = new UnprotectedXmlLicenseTransform (); + Assert.IsNotNull (transform.InputTypes [0]); + } + + [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], "#1"); + + // it's not a static array + transform = new UnprotectedXmlLicenseTransform (); + Assert.IsNotNull (transform.OutputTypes [0], "#2"); + } + } +} + +#endif |