(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Security / Test / System.Security.Cryptography.Xml / KeyInfoRetrievalMethodTest.cs
blob3e970d1989201ba22e29a8b414543d8deba34454
1 //
2 // KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using System;
11 using System.Security.Cryptography;
12 using System.Security.Cryptography.Xml;
13 using System.Xml;
15 using NUnit.Framework;
17 namespace MonoTests.System.Security.Cryptography.Xml {
19 [TestFixture]
20 public class KeyInfoRetrievalMethodTest : Assertion {
22 [Test]
23 public void TestNewEmptyKeyNode ()
25 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
26 #if NET_1_0
27 AssertEquals ("Empty", "<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
28 #else
29 AssertEquals ("Empty", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
30 #endif
33 [Test]
34 public void TestNewKeyNode ()
36 string uri = "http://www.go-mono.com/";
37 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
38 uri1.Uri = uri;
39 XmlElement xel = uri1.GetXml ();
41 KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri);
42 uri2.LoadXml (xel);
44 AssertEquals ("uri1==uri2", (uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml));
45 AssertEquals ("uri==Uri", uri, uri1.Uri);
48 [Test]
49 public void TestImportKeyNode ()
51 #if NET_1_0
52 string value = "<RetrievalElement URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
53 #else
54 string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
55 #endif
56 XmlDocument doc = new XmlDocument ();
57 doc.LoadXml (value);
59 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
60 uri1.LoadXml (doc.DocumentElement);
62 // verify that proper XML is generated (equals to original)
63 string s = (uri1.GetXml ().OuterXml);
64 AssertEquals ("Xml", value, s);
66 // verify that property is parsed correctly
67 AssertEquals ("Uri", "http://www.go-mono.com/", uri1.Uri);
70 [Test]
71 [ExpectedException (typeof (ArgumentNullException))]
72 public void InvalidKeyNode1 ()
74 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
75 uri1.LoadXml (null);
78 [Test]
79 public void InvalidKeyNode2 ()
81 string bad = "<Test></Test>";
82 XmlDocument doc = new XmlDocument ();
83 doc.LoadXml (bad);
85 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
86 // no exception is thrown
87 uri1.LoadXml (doc.DocumentElement);
88 // note that URI="" is present (unlike a empty Uri)
89 #if NET_1_0
90 AssertEquals("invalid", "<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
91 #else
92 AssertEquals("invalid", "<RetrievalMethod URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
93 #endif