diff options
Diffstat (limited to 'mcs/class/System.Security/Test')
20 files changed, 410 insertions, 427 deletions
diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs index 52086318e7d..68faddc904a 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/AssertCrypto.cs @@ -15,7 +15,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { - public class AssertCrypto : Assertion { + public class AssertCrypto { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -23,9 +23,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -38,7 +38,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); - Assert (msg, a); + Assert.IsTrue (a, msg); } private const string xmldsig = " xmlns=\"http://www.w3.org/2000/09/xmldsig#\""; @@ -48,7 +48,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { { expected = expected.Replace (xmldsig, String.Empty); actual = actual.Replace (xmldsig, String.Empty); - AssertEquals (msg, expected, actual); + Assert.AreEqual (expected, actual, msg); } } } 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 2a0a2dd3d3b..83c42484667 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,7 @@ +2009-06-26 Robert Jordan <robertj@gmx.net> + + * *.cs: Upgrade to new NUnit style. + 2008-11-01 Sebastien Pouliot <sebastien@ximian.com> * EncryptedXmlTest.cs: Add null check test cases for many methods. diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs index 28e5a464bd7..7f7bd03a97d 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DSAKeyValueTest.cs @@ -17,24 +17,24 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class DSAKeyValueTest : Assertion { + public class DSAKeyValueTest { [Test] public void GenerateKey () { DSAKeyValue dsa1 = new DSAKeyValue (); - AssertNotNull ("Key", dsa1.Key); + Assert.IsNotNull (dsa1.Key, "Key"); XmlElement xmlkey = dsa1.GetXml (); DSAKeyValue dsa2 = new DSAKeyValue (); dsa2.LoadXml (xmlkey); - Assert ("dsa1==dsa2", (dsa1.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml)); + Assert.IsTrue ((dsa1.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml), "dsa1==dsa2"); DSA key = dsa1.Key; DSAKeyValue dsa3 = new DSAKeyValue (key); - Assert ("dsa3==dsa1", (dsa3.GetXml ().OuterXml) == (dsa1.GetXml ().OuterXml)); - Assert ("dsa3==dsa2", (dsa3.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml)); + Assert.IsTrue ((dsa3.GetXml ().OuterXml) == (dsa1.GetXml ().OuterXml), "dsa3==dsa1"); + Assert.IsTrue ((dsa3.GetXml ().OuterXml) == (dsa2.GetXml ().OuterXml), "dsa3==dsa2"); } [Test] @@ -48,7 +48,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { dsa1.LoadXml (doc.DocumentElement); string s = (dsa1.GetXml ().OuterXml); - AssertEquals ("DSA Key", dsaKey, s); + Assert.AreEqual (dsaKey, s, "DSA Key"); } [Test] diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs index 27c1cd7b84c..e1bd2cebbd4 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/DataObjectTest.cs @@ -19,7 +19,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class DataObjectTest : Assertion { + public class DataObjectTest { [Test] public void NewDataObject () @@ -29,25 +29,25 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (test); DataObject obj1 = new DataObject (); - Assert ("Data.Count==0", (obj1.Data.Count == 0)); - AssertEquals ("Just constructed", "<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (obj1.GetXml ().OuterXml)); + Assert.IsTrue ((obj1.Data.Count == 0), "Data.Count==0"); + Assert.AreEqual ("<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (obj1.GetXml ().OuterXml), "Just constructed"); obj1.Id = "id"; obj1.MimeType = "mime"; obj1.Encoding = "encoding"; - AssertEquals ("Only attributes", "<Object Id=\"id\" MimeType=\"mime\" Encoding=\"encoding\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (obj1.GetXml ().OuterXml)); + Assert.AreEqual ("<Object Id=\"id\" MimeType=\"mime\" Encoding=\"encoding\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (obj1.GetXml ().OuterXml), "Only attributes"); obj1.Data = doc.ChildNodes; - Assert ("Data.Count==1", (obj1.Data.Count == 1)); + Assert.IsTrue ((obj1.Data.Count == 1), "Data.Count==1"); XmlElement xel = obj1.GetXml (); DataObject obj2 = new DataObject (); obj2.LoadXml (xel); - AssertEquals ("obj1==obj2", (obj1.GetXml ().OuterXml), (obj2.GetXml ().OuterXml)); + Assert.AreEqual ((obj1.GetXml ().OuterXml), (obj2.GetXml ().OuterXml), "obj1==obj2"); DataObject obj3 = new DataObject (obj1.Id, obj1.MimeType, obj1.Encoding, doc.DocumentElement); - AssertEquals ("obj2==obj3", (obj2.GetXml ().OuterXml), (obj3.GetXml ().OuterXml)); + Assert.AreEqual ((obj2.GetXml ().OuterXml), (obj3.GetXml ().OuterXml), "obj2==obj3"); } [Test] @@ -59,10 +59,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { DataObject obj1 = new DataObject (); obj1.LoadXml (doc.DocumentElement); - Assert ("Data.Count==2", (obj1.Data.Count == 2)); + Assert.IsTrue ((obj1.Data.Count == 2), "Data.Count==2"); string s = (obj1.GetXml ().OuterXml); - AssertEquals ("DataObject 1", value1, s); + Assert.AreEqual (value1, s, "DataObject 1"); string value2 = "<Object xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>"; doc = new XmlDocument (); @@ -72,7 +72,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj2.LoadXml (doc.DocumentElement); s = (obj2.GetXml ().OuterXml); - AssertEquals ("DataObject 2", value2, s); + Assert.AreEqual (value2, s, "DataObject 2"); string value3 = "<Object Id=\"id\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>"; doc = new XmlDocument (); @@ -82,7 +82,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj3.LoadXml (doc.DocumentElement); s = (obj3.GetXml ().OuterXml); - AssertEquals ("DataObject 3", value3, s); + Assert.AreEqual (value3, s, "DataObject 3"); string value4 = "<Object MimeType=\"mime\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\" /></Object>"; doc = new XmlDocument (); @@ -92,7 +92,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj4.LoadXml (doc.DocumentElement); s = (obj4.GetXml ().OuterXml); - AssertEquals ("DataObject 4", value4, s); + Assert.AreEqual (value4, s, "DataObject 4"); } [Test] @@ -122,7 +122,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (value); obj1.LoadXml (doc.DocumentElement); string s = (obj1.GetXml ().OuterXml); - AssertEquals ("DataObject Bad", value, s); + Assert.AreEqual (value, s, "DataObject Bad"); } [Test] @@ -135,7 +135,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj.LoadXml (doc.DocumentElement); // obj.Id = "hogehoge"; XmlElement el2 = obj.GetXml (); - AssertEquals ("Document is kept unless setting properties", doc, el2.OwnerDocument); + Assert.AreEqual (doc, el2.OwnerDocument, "Document is kept unless setting properties"); } [Test] @@ -148,7 +148,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj.LoadXml (doc.DocumentElement); obj.Id = "hogehoge"; XmlElement el2 = obj.GetXml (); - Assert ("Document is not kept when properties are set", doc != el2.OwnerDocument); + Assert.IsTrue (doc != el2.OwnerDocument, "Document is not kept when properties are set"); } [Test] @@ -162,11 +162,11 @@ namespace MonoTests.System.Security.Cryptography.Xml { obj.MimeType = "application/octet-stream"; obj.Encoding = "euc-kr"; XmlElement el1 = obj.GetXml (); - AssertEquals ("<Object Id=\"hoge\" MimeType=\"application/octet-stream\" Encoding=\"euc-kr\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\">test</Object>", el1.OuterXml); + Assert.AreEqual ("<Object Id=\"hoge\" MimeType=\"application/octet-stream\" Encoding=\"euc-kr\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\">test</Object>", el1.OuterXml); /* looks curious? but the element does not look to be appended to the document. Just commented out since it is not fixed. - AssertEquals (String.Empty, el1.OwnerDocument.OuterXml); + Assert.AreEqual (String.Empty, el1.OwnerDocument.OuterXml); */ } @@ -177,7 +177,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlElement el = new XmlDocument ().CreateElement ("foo"); d.Id = "id:1"; d.Data = el.SelectNodes ("."); - AssertEquals ("id:1", d.Id); + Assert.AreEqual ("id:1", d.Id); } [Test] @@ -186,7 +186,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlElement el = new XmlDocument ().CreateElement ("foo"); DataObject d = new DataObject ("id:1", null, null, el); d.MimeType = "text/html"; - AssertEquals ("id:1", d.Id); + Assert.AreEqual ("id:1", d.Id); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs index 17ab583e10c..1c6bf09108c 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNameTest.cs @@ -17,7 +17,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class KeyInfoNameTest : Assertion { + public class KeyInfoNameTest { [Test] public void NewKeyValue () @@ -30,8 +30,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoName name2 = new KeyInfoName (); name2.LoadXml (xel); - AssertEquals ("newKeyValue==value", newKeyValue, name1.Value); - AssertEquals ("name1==name2", (name1.GetXml ().OuterXml), (name2.GetXml ().OuterXml)); + Assert.AreEqual (newKeyValue, name1.Value, "newKeyValue==value"); + Assert.AreEqual ((name1.GetXml ().OuterXml), (name2.GetXml ().OuterXml), "name1==name2"); } [Test] @@ -43,8 +43,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoName name = new KeyInfoName (); name.LoadXml (doc.DocumentElement); - AssertEquals ("import.Name", "Mono::", name.Value); - AssertEquals ("import.GetXml", value, name.GetXml ().OuterXml); + Assert.AreEqual ("Mono::", name.Value, "import.Name"); + Assert.AreEqual (value, name.GetXml ().OuterXml, "import.GetXml"); } [Test] @@ -68,8 +68,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoName name = new KeyInfoName (); name.LoadXml (doc.DocumentElement); - AssertEquals ("invalid.Name", "", name.Value); - AssertEquals ("invalid.GetXml", "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\"></KeyName>", (name.GetXml ().OuterXml)); + Assert.AreEqual ("", name.Value, "invalid.Name"); + Assert.AreEqual ("<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\"></KeyName>", (name.GetXml ().OuterXml), "invalid.GetXml"); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs index 5f27cf1fd2c..f0886c90d5f 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoNodeTest.cs @@ -17,7 +17,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class KeyInfoNodeTest : Assertion { + public class KeyInfoNodeTest { [Test] public void NewKeyNode () @@ -33,7 +33,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoNode node2 = new KeyInfoNode (node1.Value); node2.LoadXml (xel); - AssertEquals ("node1==node2", (node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml)); + Assert.AreEqual ((node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml), "node1==node2"); } [Test] @@ -48,7 +48,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { node1.LoadXml (doc.DocumentElement); string s = (node1.GetXml ().OuterXml); - AssertEquals ("Node", value, s); + Assert.AreEqual (value, s, "Node"); } // well there's no invalid value - unless you read the doc ;-) @@ -62,7 +62,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoNode node1 = new KeyInfoNode (); // LAMESPEC: No ArgumentNullException is thrown if value == null node1.LoadXml (null); - AssertNull ("Value==null", node1.Value); + Assert.IsNull (node1.Value, "Value==null"); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs index cdef016e07b..589cdbc5204 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoRetrievalMethodTest.cs @@ -18,16 +18,16 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class KeyInfoRetrievalMethodTest : Assertion { + public class KeyInfoRetrievalMethodTest { [Test] public void TestNewEmptyKeyNode () { KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod (); #if NET_1_0 - AssertEquals ("Empty", "<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml)); + Assert.AreEqual ("<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "Empty"); #else - AssertEquals ("Empty", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml)); + Assert.AreEqual ("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "Empty"); #endif } @@ -42,8 +42,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri); uri2.LoadXml (xel); - AssertEquals ("uri1==uri2", (uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml)); - AssertEquals ("uri==Uri", uri, uri1.Uri); + Assert.AreEqual ((uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml), "uri1==uri2"); + Assert.AreEqual (uri, uri1.Uri, "uri==Uri"); } [Test] @@ -62,10 +62,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { // verify that proper XML is generated (equals to original) string s = (uri1.GetXml ().OuterXml); - AssertEquals ("Xml", value, s); + Assert.AreEqual (value, s, "Xml"); // verify that property is parsed correctly - AssertEquals ("Uri", "http://www.go-mono.com/", uri1.Uri); + Assert.AreEqual ("http://www.go-mono.com/", uri1.Uri, "Uri"); } [Test] @@ -90,10 +90,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { AssertCrypto.AssertXmlEquals ("invalid", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml)); #elif NET_1_1 // note that URI="" is present (unlike a empty Uri) - AssertEquals("invalid", "<RetrievalMethod URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml)); + Assert.AreEqual ("<RetrievalMethod URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "invalid"); #else // Fx 1.0 misnamed the tag name - AssertEquals("invalid", "<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml)); + Assert.AreEqual ("<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "invalid"); #endif } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs index 96a3e31f118..dba7a39ae9b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/KeyInfoTest.cs @@ -19,7 +19,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class KeyInfoTest : Assertion { + public class KeyInfoTest { private KeyInfo info; @@ -32,8 +32,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void EmptyKeyInfo () { - AssertEquals ("empty", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml)); - AssertEquals ("empty count", 0, info.Count); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml), "empty"); + Assert.AreEqual (0, info.Count, "empty count"); } [Test] @@ -42,8 +42,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoName name = new KeyInfoName (); name.Value = "Mono::"; info.AddClause (name); - AssertEquals ("name", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>Mono::</KeyName></KeyInfo>", (info.GetXml ().OuterXml)); - AssertEquals ("name count", 1, info.Count); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyName>Mono::</KeyName></KeyInfo>", (info.GetXml ().OuterXml), "name"); + Assert.AreEqual (1, info.Count, "name count"); } [Test] @@ -55,8 +55,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoNode node = new KeyInfoNode (doc.DocumentElement); info.AddClause (node); - AssertEquals ("node", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\">KeyInfoNode</Test></KeyInfo>", (info.GetXml ().OuterXml)); - AssertEquals ("node count", 1, info.Count); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><Test xmlns=\"\">KeyInfoNode</Test></KeyInfo>", (info.GetXml ().OuterXml), "node"); + Assert.AreEqual (1, info.Count, "node count"); } string xmlDSA = "<DSAKeyValue><P>rjxsMU368YOCTQejWkiuO9e/vUVwkLtq1jKiU3TtJ53hBJqjFRuTa228vZe+BH2su9RPn/vYFWfQDv6zgBYe3eNdu4Afw+Ny0FatX6dl3E77Ra6Tsd3MmLXBiGSQ1mMNd5G2XQGpbt9zsGlUaexXekeMLxIufgfZLwYp67M+2WM=</P><Q>tf0K9rMyvUrU4cIkwbCrDRhQAJk=</Q><G>S8Z+1pGCed00w6DtVcqZLKjfqlCJ7JsugEFIgSy/Vxtu9YGCMclV4ijGEbPo/jU8YOSMuD7E9M7UaopMRcmKQjoKZzoJjkgVFP48Ohxl1f08lERnButsxanx3+OstFwUGQ8XNaGg3KrIoZt1FUnfxN3RHHTvVhjzNSHxMGULGaU=</G><Y>LnrxxRGLYeV2XLtK3SYz8RQHlHFZYrtznDZyMotuRfO5uC5YODhSFyLXvb1qB3WeGtF4h3Eo4KzHgMgfN2ZMlffxFRhJgTtH3ctbL8lfQoDkjeiPPnYGhspdJxr0tyZmiy0gkjJG3vwHYrLnvZWx9Wm/unqiOlGBPNuxJ+hOeP8=</Y><J>9RhE5TycDtdEIXxS3HfxFyXYgpy81zY5lVjwD6E9JP37MWEi80BlX6ab1YPm6xYSEoqReMPP9RgGiW6DuACpgI7+8vgCr4i/7VhzModJAA56PwvTu6UMt9xxKU/fT672v8ucREkMWoc7lEey</J><Seed>HxW3N4RHWVgqDQKuGg7iJTUTiCs=</Seed><PgenCounter>Asw=</PgenCounter></DSAKeyValue>"; @@ -69,7 +69,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { DSAKeyValue dsa = new DSAKeyValue (key); info.AddClause (dsa); AssertCrypto.AssertXmlEquals ("dsa", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlDSA + "</KeyValue></KeyInfo>", (info.GetXml ().OuterXml)); - AssertEquals ("dsa count", 1, info.Count); + Assert.AreEqual (1, info.Count, "dsa count"); } static string xmlRSA = "<RSAKeyValue><Modulus>9DC4XNdQJwMRnz5pP2a6U51MHCODRilaIoVXqUPhCUb0lJdGroeqVYT84ZyIVrcarzD7Tqs3aEOIa3rKox0N1bxQpZPqayVQeLAkjLLtzJW/ScRJx3uEDJdgT1JnM1FH0GZTinmEdCUXdLc7+Y/c/qqIkTfbwHbRZjW0bBJyExM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"; @@ -82,7 +82,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { RSAKeyValue rsa = new RSAKeyValue (key); info.AddClause (rsa); AssertCrypto.AssertXmlEquals ("rsa", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + xmlRSA + "</KeyValue></KeyInfo>", (info.GetXml ().OuterXml)); - AssertEquals ("rsa count", 1, info.Count); + Assert.AreEqual (1, info.Count, "rsa count"); } [Test] @@ -92,11 +92,11 @@ namespace MonoTests.System.Security.Cryptography.Xml { retrieval.Uri = "http://www.go-mono.org/"; info.AddClause (retrieval); #if NET_1_0 - AssertEquals ("RetrievalMethod", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalElement URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml ().OuterXml)); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalElement URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml ().OuterXml), "RetrievalMethod"); #else - AssertEquals ("RetrievalMethod", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalMethod URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml ().OuterXml)); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RetrievalMethod URI=\"http://www.go-mono.org/\" /></KeyInfo>", (info.GetXml ().OuterXml), "RetrievalMethod"); #endif - AssertEquals ("RetrievalMethod count", 1, info.Count); + Assert.AreEqual (1, info.Count, "RetrievalMethod count"); } static byte[] cert = { 0x30,0x82,0x02,0x1D,0x30,0x82,0x01,0x86,0x02,0x01,0x14,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x58,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x43,0x41,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x03,0x13,0x16,0x4B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73,0x73,0x20,0x43,0x61,0x6E,0x61,0x64,0x61,0x20,0x49,0x6E,0x63,0x2E,0x31,0x28,0x30,0x26,0x06,0x0A,0x2B,0x06,0x01,0x04,0x01,0x2A,0x02,0x0B,0x02,0x01,0x13,0x18,0x6B,0x65,0x79,0x77,0x69,0x74,0x6E,0x65,0x73, @@ -113,7 +113,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { KeyInfoX509Data x509data = new KeyInfoX509Data (x509); info.AddClause (x509data); AssertCrypto.AssertXmlEquals ("X509Data", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>", (info.GetXml ().OuterXml)); - AssertEquals ("X509Data count", 1, info.Count); + Assert.AreEqual (1, info.Count, "X509Data count"); } [Test] @@ -151,7 +151,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { s += "<X509Data xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"; s += "<X509Certificate>MIICHTCCAYYCARQwDQYJKoZIhvcNAQEEBQAwWDELMAkGA1UEBhMCQ0ExHzAdBgNVBAMTFktleXdpdG5lc3MgQ2FuYWRhIEluYy4xKDAmBgorBgEEASoCCwIBExhrZXl3aXRuZXNzQGtleXdpdG5lc3MuY2EwHhcNOTYwNTA3MDAwMDAwWhcNOTkwNTA3MDAwMDAwWjBYMQswCQYDVQQGEwJDQTEfMB0GA1UEAxMWS2V5d2l0bmVzcyBDYW5hZGEgSW5jLjEoMCYGCisGAQQBKgILAgETGGtleXdpdG5lc3NAa2V5d2l0bmVzcy5jYTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgYcCgYEAzSP6KuHtmPTp0JM+13qAAkzMwQKvXLYff/pXQm8w0SDFtSEHQCyphsLzZISuPYUu7YW9VLAYKO9q+BvnCxYfkyVPx/iOw7nKmIQOVdAv73h3xXIoX2C/GSvRcqK32D/glzRaAb0EnMh4Rc2TjRXydhARq7hbLp5S3YE+nGTIKZMCAQMwDQYJKoZIhvcNAQEEBQADgYEAMho1ur9DJ9a01Lh25eObTWzAhsl3NbprFi0TRkqwMlOhW1rpmeIMhogXTg3+gqxOR+/7/zms7jXI+lI3CkmtWa3iiqkcxl8f+G9zfs2gMegMvvVN2bKrihK2MHhoEXwN8UlNo/2y6f8d8JH6VIX/M5Dowb+km6RiRr1hElmYQYk=</X509Certificate></X509Data></KeyInfo>"; AssertCrypto.AssertXmlEquals ("Complex", s, (info.GetXml ().OuterXml)); - AssertEquals ("RetrievalMethod count", 5, info.Count); + Assert.AreEqual (5, info.Count, "RetrievalMethod count"); } [Test] @@ -165,17 +165,17 @@ namespace MonoTests.System.Security.Cryptography.Xml { info.LoadXml (doc.DocumentElement); AssertCrypto.AssertXmlEquals ("Import", value, (info.GetXml ().OuterXml)); - AssertEquals ("Import count", 5, info.Count); + Assert.AreEqual (5, info.Count, "Import count"); } [Test] [ExpectedException (typeof (NullReferenceException))] public void NullClause () { - AssertEquals ("empty count", 0, info.Count); + Assert.AreEqual (0, info.Count, "empty count"); // null is accepted... info.AddClause (null); - AssertEquals ("null count", 1, info.Count); + Assert.AreEqual (1, info.Count, "null count"); // but can't get XML out if it! XmlElement xel = info.GetXml (); } @@ -195,8 +195,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (bad); info.LoadXml (doc.DocumentElement); // LAMESPEC: no expection but Xml isn't loaded - AssertEquals ("invalid", "<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml)); - AssertEquals ("invalid count", 0, info.Count); + Assert.AreEqual ("<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (info.GetXml ().OuterXml), "invalid"); + Assert.AreEqual (0, info.Count, "invalid count"); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs index 340da0d6092..4a8cdf8e133 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/RSAKeyValueTest.cs @@ -17,24 +17,24 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class RSAKeyValueTest : Assertion { + public class RSAKeyValueTest { [Test] public void GeneratedKey () { RSAKeyValue rsa1 = new RSAKeyValue (); - AssertNotNull ("Key", rsa1.Key); + Assert.IsNotNull (rsa1.Key, "Key"); XmlElement xmlkey = rsa1.GetXml (); RSAKeyValue rsa2 = new RSAKeyValue (); rsa2.LoadXml (xmlkey); - Assert ("rsa1==rsa2", (rsa1.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml)); + Assert.IsTrue ((rsa1.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml), "rsa1==rsa2"); RSA key = rsa1.Key; RSAKeyValue rsa3 = new RSAKeyValue (key); - Assert ("rsa3==rsa1", (rsa3.GetXml ().OuterXml) == (rsa1.GetXml ().OuterXml)); - Assert ("rsa3==rsa2", (rsa3.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml)); + Assert.IsTrue ((rsa3.GetXml ().OuterXml) == (rsa1.GetXml ().OuterXml), "rsa3==rsa1"); + Assert.IsTrue ((rsa3.GetXml ().OuterXml) == (rsa2.GetXml ().OuterXml), "rsa3==rsa2"); } [Test] @@ -48,7 +48,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { rsa1.LoadXml (doc.DocumentElement); string s = (rsa1.GetXml ().OuterXml); - AssertEquals ("RSA Key", rsaKey, s); + Assert.AreEqual (rsaKey, s, "RSA Key"); } [Test] diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs index 01f36abc658..a776b19274f 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/ReferenceTest.cs @@ -18,7 +18,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class ReferenceTest : Assertion { + public class ReferenceTest { protected Reference reference; @@ -31,17 +31,17 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void Properties () { - AssertNull ("Uri (null)", reference.Uri); - AssertNotNull ("TransformChain", reference.TransformChain); - AssertEquals ("ToString()", "System.Security.Cryptography.Xml.Reference", reference.ToString ()); + Assert.IsNull (reference.Uri, "Uri (null)"); + Assert.IsNotNull (reference.TransformChain, "TransformChain"); + Assert.AreEqual ("System.Security.Cryptography.Xml.Reference", reference.ToString (), "ToString()"); // test uri constructor string uri = "uri"; reference = new Reference (uri); - AssertEquals ("DigestMethod", "http://www.w3.org/2000/09/xmldsig#sha1", reference.DigestMethod); - AssertNull ("DigestValue", reference.DigestValue); - AssertNull ("Id", reference.Id); - AssertNull ("Type", reference.Type); - AssertEquals ("Uri", uri, reference.Uri); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#sha1", reference.DigestMethod, "DigestMethod"); + Assert.IsNull (reference.DigestValue, "DigestValue"); + Assert.IsNull (reference.Id, "Id"); + Assert.IsNull (reference.Type, "Type"); + Assert.AreEqual (uri, reference.Uri, "Uri"); } [Test] @@ -51,11 +51,11 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); - AssertEquals ("Load-Xml", test, (reference.GetXml().OuterXml)); - AssertEquals ("Load-URI", "#MyObjectId", reference.Uri); + Assert.AreEqual (test, (reference.GetXml().OuterXml), "Load-Xml"); + Assert.AreEqual ("#MyObjectId", reference.Uri, "Load-URI"); byte[] hash = { 0xFD, 0x5B, 0xEA, 0xEA, 0xC5, 0xC4, 0x55, 0xBB, 0x59, 0x0B, 0xC1, 0xB0, 0x36, 0xD2, 0xD0, 0x9C, 0x63, 0xB2, 0xFD, 0x52 }; AssertCrypto.AssertEquals("Load-Digest", hash, reference.DigestValue); - AssertEquals ("Load-#Transform", 0, reference.TransformChain.Count); + Assert.AreEqual (0, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -65,8 +65,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); - AssertEquals ("Load-Base64", test, (reference.GetXml().OuterXml)); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.AreEqual (test, (reference.GetXml().OuterXml), "Load-Base64"); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -76,8 +76,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); - AssertEquals ("Load-C14N", test, (reference.GetXml().OuterXml)); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.AreEqual (test, (reference.GetXml().OuterXml), "Load-C14N"); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -87,8 +87,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); - AssertEquals ("Load-C14NWithComments", test, (reference.GetXml().OuterXml)); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.AreEqual (test, (reference.GetXml().OuterXml), "Load-C14NWithComments"); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -98,8 +98,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); - AssertEquals ("Load-Enveloped", test, (reference.GetXml().OuterXml)); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.AreEqual (test, (reference.GetXml().OuterXml), "Load-Enveloped"); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -112,8 +112,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (test1); reference.LoadXml (doc.DocumentElement); string result = (reference.GetXml().OuterXml); - Assert (result, ((test1 == result) || (test2 == result))); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.IsTrue (((test1 == result) || (test2 == result)), result); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -132,8 +132,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (test); reference.LoadXml (doc.DocumentElement); string result = reference.GetXml().OuterXml; - AssertEquals (result, test, result); - AssertEquals ("Load-#Transform", 1, reference.TransformChain.Count); + Assert.AreEqual (test, result, result); + Assert.AreEqual (1, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -153,8 +153,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml (test1); reference.LoadXml (doc.DocumentElement); string result = reference.GetXml().OuterXml; - Assert (result, ((result == test1) || (result == test2))); - AssertEquals ("Load-#Transform", 6, reference.TransformChain.Count); + Assert.IsTrue (((result == test1) || (result == test2)), result); + Assert.AreEqual (6, reference.TransformChain.Count, "Load-#Transform"); } [Test] @@ -170,7 +170,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { reference.DigestValue = hash; XmlElement xel = reference.GetXml (); // this is the minimal Reference (DigestValue)! - AssertNotNull ("GetXml", xel); + Assert.IsNotNull (xel, "GetXml"); reference.AddTransform (new XmlDsigBase64Transform ()); reference.AddTransform (new XmlDsigC14NTransform ()); @@ -184,7 +184,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { // Mono's result (xml is equivalent but not identical) string test2 = test1.Replace ("<XPath></XPath>", "<XPath xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />"); string result = reference.GetXml().OuterXml; - Assert (result, ((result == test1) || (result == test2))); + Assert.IsTrue (((result == test1) || (result == test2)), result); // however this value cannot be loaded as it's missing some transform (xslt) parameters // can we add them again ? @@ -196,7 +196,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { reference.AddTransform (new XmlDsigXsltTransform ()); // seems so ;-) - AssertEquals ("# Transforms", 12, reference.TransformChain.Count); + Assert.AreEqual (12, reference.TransformChain.Count, "# Transforms"); } [Test] @@ -204,7 +204,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { { // null DigestMethod -> "" DigestMethod !!! reference.DigestMethod = null; - AssertNull ("DigestMethod null", reference.DigestMethod); + Assert.IsNull (reference.DigestMethod, "DigestMethod null"); } [Test] @@ -244,9 +244,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { Reference r = new Reference (); r.LoadXml (org); XmlElement el = r.GetXml (); - AssertEquals (doc, el.OwnerDocument); - AssertEquals (org, el); - AssertEquals (result, el.OuterXml); + Assert.AreEqual (doc, el.OwnerDocument); + Assert.AreEqual (org, el); + Assert.AreEqual (result, el.OuterXml); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs index ff34814c9c6..021caf05a9c 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignatureTest.cs @@ -18,7 +18,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class SignatureTest : Assertion { + public class SignatureTest { protected Signature signature; diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs index f673a95b89d..217c154bc53 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedInfoTest.cs @@ -18,7 +18,7 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class SignedInfoTest : Assertion { + public class SignedInfoTest { protected SignedInfo info; @@ -31,13 +31,13 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void Empty () { - AssertEquals ("CanonicalizationMethod", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod); - AssertNull ("Id", info.Id); - AssertNotNull ("References", info.References); - AssertEquals ("References.Count", 0, info.References.Count); - AssertNull ("SignatureLength", info.SignatureLength); - AssertNull ("SignatureMethod", info.SignatureMethod); - AssertEquals ("ToString()", "System.Security.Cryptography.Xml.SignedInfo", info.ToString ()); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod, "CanonicalizationMethod"); + Assert.IsNull (info.Id, "Id"); + Assert.IsNotNull (info.References, "References"); + Assert.AreEqual (0, info.References.Count, "References.Count"); + Assert.IsNull (info.SignatureLength, "SignatureLength"); + Assert.IsNull (info.SignatureMethod, "SignatureMethod"); + Assert.AreEqual ("System.Security.Cryptography.Xml.SignedInfo", info.ToString (), "ToString()"); } [Test] @@ -51,9 +51,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void Properties () { info.CanonicalizationMethod = "http://www.go-mono.com/"; - AssertEquals ("CanonicalizationMethod", "http://www.go-mono.com/", info.CanonicalizationMethod); + Assert.AreEqual ("http://www.go-mono.com/", info.CanonicalizationMethod, "CanonicalizationMethod"); info.Id = "Mono::"; - AssertEquals ("Id", "Mono::", info.Id); + Assert.AreEqual ("Mono::", info.Id, "Id"); } [Test] @@ -63,12 +63,12 @@ namespace MonoTests.System.Security.Cryptography.Xml { r1.Uri = "http://www.go-mono.com/"; r1.AddTransform (new XmlDsigBase64Transform ()); info.AddReference (r1); - AssertEquals ("References.Count 1", 1, info.References.Count); + Assert.AreEqual (1, info.References.Count, "References.Count 1"); Reference r2 = new Reference ("http://www.motus.com/"); r2.AddTransform (new XmlDsigBase64Transform ()); info.AddReference (r2); - AssertEquals ("References.Count 2", 2, info.References.Count); + Assert.AreEqual (2, info.References.Count, "References.Count 2"); info.SignatureMethod = "http://www.w3.org/2000/09/xmldsig#dsa-sha1"; } @@ -80,10 +80,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.LoadXml (xml); info.LoadXml (doc.DocumentElement); - AssertEquals ("LoadXml", xml, (info.GetXml ().OuterXml)); - AssertEquals ("LoadXml-C14N", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod); - AssertEquals ("LoadXml-Algo", "http://www.w3.org/2000/09/xmldsig#rsa-sha1", info.SignatureMethod); - AssertEquals ("LoadXml-Ref1", 1, info.References.Count); + Assert.AreEqual (xml, (info.GetXml ().OuterXml), "LoadXml"); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", info.CanonicalizationMethod, "LoadXml-C14N"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", info.SignatureMethod, "LoadXml-Algo"); + Assert.AreEqual (1, info.References.Count, "LoadXml-Ref1"); } // there are many (documented) not supported methods in SignedInfo @@ -142,8 +142,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedInfo sig = new SignedInfo (); sig.LoadXml ((XmlElement) doc.SelectSingleNode ("//*[local-name()='SignedInfo']")); XmlElement el = sig.GetXml (); - AssertEquals ("#GetXmlWOSetProperty.document", doc, el.OwnerDocument); - AssertEquals ("#GetXmlWOSetProperty.outerxml", result, el.OuterXml); + Assert.AreEqual (doc, el.OwnerDocument, "#GetXmlWOSetProperty.document"); + Assert.AreEqual (result, el.OuterXml, "#GetXmlWOSetProperty.outerxml"); } [Test] @@ -160,7 +160,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { sig.LoadXml ((XmlElement) doc.SelectSingleNode ("//*[local-name()='SignedInfo']")); sig.CanonicalizationMethod = "urn:foo"; XmlElement el = sig.GetXml (); - Assert ("#GetXmlWithSetProperty.document", doc != el.OwnerDocument); + Assert.IsTrue (doc != el.OwnerDocument, "#GetXmlWithSetProperty.document"); } [Test] // never fails diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs index 40b89969512..f952470513b 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/SignedXmlTest.cs @@ -31,21 +31,21 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class SignedXmlTest : Assertion { + public class SignedXmlTest { private const string signature = "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" /><Reference URI=\"#MyObjectId\"><DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" /><DigestValue>CTnnhjxUQHJmD+t1MjVXrOW+MCA=</DigestValue></Reference></SignedInfo><SignatureValue>dbFt6Zw3vR+Xh7LbM/vuifyFA7gPh/NlDM2Glz/SJBsveISieuTBpZlk/zavAeuXR/Nu0Ztt4OP4tCOg09a2RNlrTP0dhkeEfL1jTzpnVaLHuQbCiwOWCgbRif7Xt7N12FuiHYb3BltP/YyXS4E12NxlGlqnDiFA1v/mkK5+C1o=</SignatureValue><KeyInfo><KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><RSAKeyValue><Modulus>hEfTJNa2idz2u+fSYDDG4Lx/xuk4aBbvOPVNqgc1l9Y8t7Pt+ZyF+kkF3uUl8Y0700BFGAsprnhwrWENK+PGdtvM5796ZKxCCa0ooKkofiT4355HqK26hpV8dvj38vq/rkJe1jHZgkTKa+c/0vjcYZOI/RT/IZv9JfXxVWLuLxk=</Modulus><Exponent>EQ==</Exponent></RSAKeyValue></KeyValue></KeyInfo><Object Id=\"MyObjectId\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><ObjectListTag xmlns=\"\" /></Object></Signature>"; [Test] public void StaticValues () { - AssertEquals ("XmlDsigCanonicalizationUrl", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", SignedXml.XmlDsigCanonicalizationUrl); - AssertEquals ("XmlDsigCanonicalizationWithCommentsUrl", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", SignedXml.XmlDsigCanonicalizationWithCommentsUrl); - AssertEquals ("XmlDsigDSAUrl", "http://www.w3.org/2000/09/xmldsig#dsa-sha1", SignedXml.XmlDsigDSAUrl); - AssertEquals ("XmlDsigHMACSHA1Url", "http://www.w3.org/2000/09/xmldsig#hmac-sha1", SignedXml.XmlDsigHMACSHA1Url); - AssertEquals ("XmlDsigMinimalCanonicalizationUrl", "http://www.w3.org/2000/09/xmldsig#minimal", SignedXml.XmlDsigMinimalCanonicalizationUrl); - AssertEquals ("XmlDsigNamespaceUrl", "http://www.w3.org/2000/09/xmldsig#", SignedXml.XmlDsigNamespaceUrl); - AssertEquals ("XmlDsigRSASHA1Url", "http://www.w3.org/2000/09/xmldsig#rsa-sha1", SignedXml.XmlDsigRSASHA1Url); - AssertEquals ("XmlDsigSHA1Url", "http://www.w3.org/2000/09/xmldsig#sha1", SignedXml.XmlDsigSHA1Url); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", SignedXml.XmlDsigCanonicalizationUrl, "XmlDsigCanonicalizationUrl"); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", SignedXml.XmlDsigCanonicalizationWithCommentsUrl, "XmlDsigCanonicalizationWithCommentsUrl"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#dsa-sha1", SignedXml.XmlDsigDSAUrl, "XmlDsigDSAUrl"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#hmac-sha1", SignedXml.XmlDsigHMACSHA1Url, "XmlDsigHMACSHA1Url"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#minimal", SignedXml.XmlDsigMinimalCanonicalizationUrl, "XmlDsigMinimalCanonicalizationUrl"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#", SignedXml.XmlDsigNamespaceUrl, "XmlDsigNamespaceUrl"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", SignedXml.XmlDsigRSASHA1Url, "XmlDsigRSASHA1Url"); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#sha1", SignedXml.XmlDsigSHA1Url, "XmlDsigSHA1Url"); } [Test] @@ -58,7 +58,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml sx = new SignedXml (doc); sx.LoadXml (xel); - Assert ("CheckSignature", sx.CheckSignature ()); + Assert.IsTrue (sx.CheckSignature (), "CheckSignature"); } [Test] @@ -71,7 +71,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml sx = new SignedXml (doc); sx.LoadXml (doc.DocumentElement); - Assert ("CheckSignature", sx.CheckSignature ()); + Assert.IsTrue (sx.CheckSignature (), "CheckSignature"); } [Test] @@ -96,7 +96,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml sx = new SignedXml (doc.DocumentElement); sx.LoadXml (xel); - Assert ("CheckSignature", sx.CheckSignature ()); + Assert.IsTrue (sx.CheckSignature (), "CheckSignature"); } [Test] @@ -111,7 +111,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlElement xel = (XmlElement) xnl [0]; SignedXml sx = new SignedXml (doc.DocumentElement); - Assert ("!CheckSignature", !sx.CheckSignature ()); + Assert.IsTrue (!sx.CheckSignature (), "!CheckSignature"); // SignedXml (XmlElement) != SignedXml () + LoadXml (XmlElement) } @@ -169,7 +169,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { keyInfo.AddClause (new RSAKeyValue (key)); signedXml.KeyInfo = keyInfo; - AssertNotNull ("SignatureMethod", signedXml.SignatureMethod); + Assert.IsNotNull (signedXml.SignatureMethod, "SignatureMethod"); // Compute the signature - causes unsupported algorithm by the key. signedXml.ComputeSignature (); } @@ -187,19 +187,19 @@ namespace MonoTests.System.Security.Cryptography.Xml { keyInfo.AddClause (new RSAKeyValue (key)); signedXml.KeyInfo = keyInfo; - AssertEquals ("KeyInfo", 1, signedXml.KeyInfo.Count); - AssertNull ("SignatureLength", signedXml.SignatureLength); - AssertNull ("SignatureMethod", signedXml.SignatureMethod); - AssertNull ("SignatureValue", signedXml.SignatureValue); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.AreEqual (1, signedXml.KeyInfo.Count, "KeyInfo"); + Assert.IsNull (signedXml.SignatureLength, "SignatureLength"); + Assert.IsNull (signedXml.SignatureMethod, "SignatureMethod"); + Assert.IsNull (signedXml.SignatureValue, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); // Compute the signature. signedXml.ComputeSignature (); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); - AssertEquals ("SignatureMethod", SignedXml.XmlDsigRSASHA1Url, signedXml.SignatureMethod); - AssertEquals ("SignatureValue", 128, signedXml.SignatureValue.Length); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); + Assert.AreEqual (SignedXml.XmlDsigRSASHA1Url, signedXml.SignatureMethod, "SignatureMethod"); + Assert.AreEqual (128, signedXml.SignatureValue.Length, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml (); @@ -210,7 +210,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { vrfy.LoadXml (xmlSignature); // assert that we can verify our own signature - Assert ("RSA-Compute/Verify", vrfy.CheckSignature ()); + Assert.IsTrue (vrfy.CheckSignature (), "RSA-Compute/Verify"); } [Test] @@ -226,19 +226,19 @@ namespace MonoTests.System.Security.Cryptography.Xml { keyInfo.AddClause (new DSAKeyValue (key)); signedXml.KeyInfo = keyInfo; - AssertEquals ("KeyInfo", 1, signedXml.KeyInfo.Count); - AssertNull ("SignatureLength", signedXml.SignatureLength); - AssertNull ("SignatureMethod", signedXml.SignatureMethod); - AssertNull ("SignatureValue", signedXml.SignatureValue); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.AreEqual (1, signedXml.KeyInfo.Count, "KeyInfo"); + Assert.IsNull (signedXml.SignatureLength, "SignatureLength"); + Assert.IsNull (signedXml.SignatureMethod, "SignatureMethod"); + Assert.IsNull (signedXml.SignatureValue, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); // Compute the signature. signedXml.ComputeSignature (); - AssertNull ("SignatureLength", signedXml.SignatureLength); - AssertEquals ("SignatureMethod", SignedXml.XmlDsigDSAUrl, signedXml.SignatureMethod); - AssertEquals ("SignatureValue", 40, signedXml.SignatureValue.Length); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.IsNull (signedXml.SignatureLength, "SignatureLength"); + Assert.AreEqual (SignedXml.XmlDsigDSAUrl, signedXml.SignatureMethod, "SignatureMethod"); + Assert.AreEqual (40, signedXml.SignatureValue.Length, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml (); @@ -249,7 +249,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { vrfy.LoadXml (xmlSignature); // assert that we can verify our own signature - Assert ("DSA-Compute/Verify", vrfy.CheckSignature ()); + Assert.IsTrue (vrfy.CheckSignature (), "DSA-Compute/Verify"); } [Test] @@ -261,26 +261,26 @@ namespace MonoTests.System.Security.Cryptography.Xml { byte[] secretkey = Encoding.Default.GetBytes ("password"); HMACSHA1 hmac = new HMACSHA1 (secretkey); #if NET_2_0 - AssertEquals ("KeyInfo", 0, signedXml.KeyInfo.Count); + Assert.AreEqual (0, signedXml.KeyInfo.Count, "KeyInfo"); #else - AssertNull ("KeyInfo", signedXml.KeyInfo); + Assert.IsNull (signedXml.KeyInfo, "KeyInfo"); #endif - AssertNull ("SignatureLength", signedXml.SignatureLength); - AssertNull ("SignatureMethod", signedXml.SignatureMethod); - AssertNull ("SignatureValue", signedXml.SignatureValue); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.IsNull (signedXml.SignatureLength, "SignatureLength"); + Assert.IsNull (signedXml.SignatureMethod, "SignatureMethod"); + Assert.IsNull (signedXml.SignatureValue, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); signedXml.ComputeSignature (hmac); #if NET_2_0 - AssertEquals ("KeyInfo", 0, signedXml.KeyInfo.Count); + Assert.AreEqual (0, signedXml.KeyInfo.Count, "KeyInfo"); #else - AssertNull ("KeyInfo", signedXml.KeyInfo); + Assert.IsNull (signedXml.KeyInfo, "KeyInfo"); #endif - AssertNull ("SignatureLength", signedXml.SignatureLength); - AssertEquals ("SignatureMethod", SignedXml.XmlDsigHMACSHA1Url, signedXml.SignatureMethod); - AssertEquals ("SignatureValue", 20, signedXml.SignatureValue.Length); - AssertNull ("SigningKeyName", signedXml.SigningKeyName); + Assert.IsNull (signedXml.SignatureLength, "SignatureLength"); + Assert.AreEqual (SignedXml.XmlDsigHMACSHA1Url, signedXml.SignatureMethod, "SignatureMethod"); + Assert.AreEqual (20, signedXml.SignatureValue.Length, "SignatureValue"); + Assert.IsNull (signedXml.SigningKeyName, "SigningKeyName"); // Get the XML representation of the signature. XmlElement xmlSignature = signedXml.GetXml (); @@ -291,7 +291,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { vrfy.LoadXml (xmlSignature); // assert that we can verify our own signature - Assert ("HMACSHA1-Compute/Verify", vrfy.CheckSignature (hmac)); + Assert.IsTrue (vrfy.CheckSignature (hmac), "HMACSHA1-Compute/Verify"); } [Test] @@ -316,17 +316,17 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml v1 = new SignedXml (); v1.LoadXml (doc.DocumentElement); - Assert ("RSA-CheckSignature()", v1.CheckSignature ()); + Assert.IsTrue (v1.CheckSignature (), "RSA-CheckSignature()"); SignedXml v2 = new SignedXml (); v2.LoadXml (doc.DocumentElement); AsymmetricAlgorithm key = null; bool vrfy = v2.CheckSignatureReturningKey (out key); - Assert ("RSA-CheckSignatureReturningKey()", vrfy); + Assert.IsTrue (vrfy, "RSA-CheckSignatureReturningKey()"); SignedXml v3 = new SignedXml (); v3.LoadXml (doc.DocumentElement); - Assert ("RSA-CheckSignature(key)", v3.CheckSignature (key)); + Assert.IsTrue (v3.CheckSignature (key), "RSA-CheckSignature(key)"); } // Using empty constructor @@ -340,17 +340,17 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml v1 = new SignedXml (); v1.LoadXml (doc.DocumentElement); - Assert ("DSA-CheckSignature()", v1.CheckSignature ()); + Assert.IsTrue (v1.CheckSignature (), "DSA-CheckSignature()"); SignedXml v2 = new SignedXml (); v2.LoadXml (doc.DocumentElement); AsymmetricAlgorithm key = null; bool vrfy = v2.CheckSignatureReturningKey (out key); - Assert ("DSA-CheckSignatureReturningKey()", vrfy); + Assert.IsTrue (vrfy, "DSA-CheckSignatureReturningKey()"); SignedXml v3 = new SignedXml (); v3.LoadXml (doc.DocumentElement); - Assert ("DSA-CheckSignature(key)", v3.CheckSignature (key)); + Assert.IsTrue (v3.CheckSignature (key), "DSA-CheckSignature(key)"); } [Test] @@ -366,7 +366,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { byte[] secretkey = Encoding.Default.GetBytes ("password"); HMACSHA1 hmac = new HMACSHA1 (secretkey); - Assert ("HMACSHA1-CheckSignature(key)", v1.CheckSignature (hmac)); + Assert.IsTrue (v1.CheckSignature (hmac), "HMACSHA1-CheckSignature(key)"); } [Test] @@ -378,10 +378,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml v1 = new SignedXml (); v1.LoadXml (doc.DocumentElement); - Assert ("CheckSignature", v1.CheckSignature ()); + Assert.IsTrue (v1.CheckSignature (), "CheckSignature"); XmlElement xel = v1.GetIdElement (doc, "MyObjectId"); - Assert ("GetIdElement", xel.InnerXml.StartsWith ("<ObjectListTag")); + Assert.IsTrue (xel.InnerXml.StartsWith ("<ObjectListTag"), "GetIdElement"); } [Test] @@ -394,10 +394,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { sxe.LoadXml (doc.DocumentElement); AsymmetricAlgorithm aa1 = sxe.PublicGetPublicKey (); - Assert ("First Public Key is RSA", (aa1 is RSA)); + Assert.IsTrue ((aa1 is RSA), "First Public Key is RSA"); AsymmetricAlgorithm aa2 = sxe.PublicGetPublicKey (); - AssertNull ("Second Public Key is null", aa2); + Assert.IsNull (aa2, "Second Public Key is null"); } #if NET_2_0 [Test] @@ -446,9 +446,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void SigningKeyName () { SignedXmlEx sxe = new SignedXmlEx (); - AssertNull ("SigningKeyName", sxe.SigningKeyName); + Assert.IsNull (sxe.SigningKeyName, "SigningKeyName"); sxe.SigningKeyName = "mono"; - AssertEquals ("SigningKeyName", "mono", sxe.SigningKeyName); + Assert.AreEqual ("mono", sxe.SigningKeyName, "SigningKeyName"); } [Test] @@ -461,14 +461,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { // empty keyinfo passes... sx = new SignedXml (); sx.KeyInfo = new KeyInfo (); - Assert (!sx.CheckSignature ()); + Assert.IsTrue (!sx.CheckSignature ()); // with empty KeyInfoName kic = new KeyInfoName (); ki = new KeyInfo (); ki.AddClause (kic); sx.KeyInfo = ki; - Assert (!sx.CheckSignature ()); + Assert.IsTrue (!sx.CheckSignature ()); } [Test] @@ -478,7 +478,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void CheckSignatureEmpty () { SignedXml sx = new SignedXml (); - Assert (!sx.CheckSignature ()); + Assert.IsTrue (!sx.CheckSignature ()); } [Test] @@ -547,9 +547,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { byte [] key = Convert.FromBase64String ( "1W5EigVnbnRjGLbg99ElieOmuUgYO+KcwMJtE35SAGI="); Transform t = new XmlDsigC14NTransform (); - AssertEquals ("#1", expected, SignWithHMACSHA1 (input, key, t)); + Assert.AreEqual (expected, SignWithHMACSHA1 (input, key, t), "#1"); // The second result should be still identical. - AssertEquals ("#2", expected, SignWithHMACSHA1 (input, key, t)); + Assert.AreEqual (expected, SignWithHMACSHA1 (input, key, t), "#2"); } [Test] @@ -560,7 +560,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { byte [] key = Convert.FromBase64String ( "1W5EigVnbnRjGLbg99ElieOmuUgYO+KcwMJtE35SAGI="); - AssertEquals (expected, SignWithHMACSHA1 (input, key)); + Assert.AreEqual (SignWithHMACSHA1 (input, key), expected); } string SignWithHMACSHA1 (string input, byte [] key) @@ -596,8 +596,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void GetIdElement_Null () { SignedXml sign = new SignedXml (); - AssertNull (sign.GetIdElement (null, "value")); - AssertNull (sign.GetIdElement (new XmlDocument (), null)); + Assert.IsNull (sign.GetIdElement (null, "value")); + Assert.IsNull (sign.GetIdElement (new XmlDocument (), null)); } #if NET_2_0 @@ -610,13 +610,13 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("#1", "<person>
\n <birthplace>Brussels</birthplace>
\n</person>", output); + Assert.AreEqual ("<person>
\n <birthplace>Brussels</birthplace>
\n</person>", output, "#1"); s.Position = 0; HashAlgorithm hash = HashAlgorithm.Create ("System.Security.Cryptography.SHA1CryptoServiceProvider"); byte[] digest = hash.ComputeHash (s); - AssertEquals ("#2", "IKbfdK2/DMfXyezCf5QggVCXfk8=", Convert.ToBase64String (digest)); + Assert.AreEqual ("IKbfdK2/DMfXyezCf5QggVCXfk8=", Convert.ToBase64String (digest), "#2"); X509Certificate2 cert = new X509Certificate2 (_pkcs12, "mono"); SignedXml signedXml = new SignedXml (doc); @@ -640,9 +640,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { signedXml.ComputeSignature (); digest = reference.DigestValue; - AssertEquals ("#3", "e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest)); + Assert.AreEqual ("e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest), "#3"); - AssertEquals ("#4", "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + Assert.AreEqual ("<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + "<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />" + "<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" />" + "<Reference URI=\"\">" @@ -652,7 +652,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { + "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" />" + "<DigestValue>e3dsi1xK8FAx1vsug7J203JbEAU=</DigestValue>" + "</Reference>" - + "</SignedInfo>", signedXml.SignedInfo.GetXml ().OuterXml); + + "</SignedInfo>", signedXml.SignedInfo.GetXml ().OuterXml, "#4"); } [Test] @@ -663,13 +663,13 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("#1", "<person>\n <birthplace>Brussels</birthplace>\n</person>", output); + Assert.AreEqual ("<person>\n <birthplace>Brussels</birthplace>\n</person>", output, "#1"); s.Position = 0; HashAlgorithm hash = HashAlgorithm.Create ("System.Security.Cryptography.SHA1CryptoServiceProvider"); byte[] digest = hash.ComputeHash (s); - AssertEquals ("#2", "e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest)); + Assert.AreEqual ("e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest), "#2"); X509Certificate2 cert = new X509Certificate2 (_pkcs12, "mono"); SignedXml signedXml = new SignedXml (doc); @@ -693,9 +693,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { signedXml.ComputeSignature (); digest = reference.DigestValue; - AssertEquals ("#3", "e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest)); + Assert.AreEqual ("e3dsi1xK8FAx1vsug7J203JbEAU=", Convert.ToBase64String (digest), "#3"); - AssertEquals ("#4", "<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + Assert.AreEqual ("<SignedInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + "<CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\" />" + "<SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\" />" + "<Reference URI=\"\">" @@ -705,7 +705,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { + "<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" />" + "<DigestValue>e3dsi1xK8FAx1vsug7J203JbEAU=</DigestValue>" + "</Reference>" - + "</SignedInfo>", signedXml.SignedInfo.GetXml ().OuterXml); + + "</SignedInfo>", signedXml.SignedInfo.GetXml ().OuterXml, "#4"); } [Test] @@ -769,7 +769,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { SignedXml signedXml = new SignedXml (doc); XmlNodeList nodeList = doc.GetElementsByTagName ("Signature"); signedXml.LoadXml ((XmlElement) nodeList [0]); - Assert ("#2", !signedXml.CheckSignature ()); + Assert.IsTrue (!signedXml.CheckSignature (), "#2"); } [Test] @@ -779,8 +779,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { X509Certificate2 cert = new X509Certificate2 (_pkcs12, "mono"); XmlDocument doc = CreateSignedXml (cert, SignedXml.XmlDsigExcC14NTransformUrl, "\r\n"); - AssertEquals ("#1", string.Format (CultureInfo.InvariantCulture, - "<person>{0}" + + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, "<person>{0}" + " <birthplace>Brussels</birthplace>{0}" + "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + "<SignedInfo>" + @@ -828,7 +827,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { "</X509Data>" + "</KeyInfo>" + "</Signature>" + - "</person>", "\r\n"), doc.OuterXml); + "</person>", "\r\n"), doc.OuterXml, "#1"); } [Test] @@ -838,8 +837,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { X509Certificate2 cert = new X509Certificate2 (_pkcs12, "mono"); XmlDocument doc = CreateSignedXml (cert, SignedXml.XmlDsigExcC14NTransformUrl, "\n"); - AssertEquals ("#1", string.Format (CultureInfo.InvariantCulture, - "<person>{0}" + + Assert.AreEqual (string.Format (CultureInfo.InvariantCulture, "<person>{0}" + " <birthplace>Brussels</birthplace>{0}" + "<Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\">" + "<SignedInfo>" + @@ -887,7 +885,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { "</X509Data>" + "</KeyInfo>" + "</Signature>" + - "</person>", "\n"), doc.OuterXml); + "</person>", "\n"), doc.OuterXml, "#1"); } [Test] // part of bug #79454 @@ -897,16 +895,16 @@ namespace MonoTests.System.Security.Cryptography.Xml { X509Certificate2 cert = new X509Certificate2 (_pkcs12, "mono"); doc = CreateSignedXml (cert, SignedXml.XmlDsigExcC14NTransformUrl, "\n"); - Assert ("#1", VerifySignedXml (doc)); + Assert.IsTrue (VerifySignedXml (doc), "#1"); doc = CreateSignedXml (cert, SignedXml.XmlDsigExcC14NWithCommentsTransformUrl, "\n"); - Assert ("#2", VerifySignedXml (doc)); + Assert.IsTrue (VerifySignedXml (doc), "#2"); doc = CreateSignedXml (cert, SignedXml.XmlDsigCanonicalizationUrl, "\n"); - Assert ("#3", VerifySignedXml (doc)); + Assert.IsTrue (VerifySignedXml (doc), "#3"); doc = CreateSignedXml (cert, SignedXml.XmlDsigCanonicalizationWithCommentsUrl, "\n"); - Assert ("#4", VerifySignedXml (doc)); + Assert.IsTrue (VerifySignedXml (doc), "#4"); } // creates a signed XML document with two certificates in the X509Data @@ -1168,7 +1166,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { // doc.Save (System.Console.Out); sig.LoadXml (doc.DocumentElement ["Signature"]); - AssertEquals ("CheckSignature", ok, sig.CheckSignature (mac)); + Assert.AreEqual (ok, sig.CheckSignature (mac), "CheckSignature"); return sig; } @@ -1182,14 +1180,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void SignHMAC_SHA256 () { SignedXml sign = SignHMAC (EncryptedXml.XmlEncSHA256Url, new HMACSHA256 (hmackey), true); - AssertEquals ("SignatureMethod", more256, sign.SignatureMethod); + Assert.AreEqual (more256, sign.SignatureMethod, "SignatureMethod"); } [Test] public void SignHMAC_SHA256_Bad () { SignedXml sign = SignHMAC (more256, new HMACSHA256 (hmackey), false); - AssertEquals ("SignatureMethod", more256, sign.SignatureMethod); + Assert.AreEqual (more256, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1203,21 +1201,21 @@ namespace MonoTests.System.Security.Cryptography.Xml { sign.LoadXml (doc.DocumentElement ["Signature"]); // verify MS-generated signature - Assert (sign.CheckSignature (new HMACSHA256 (hmackey))); + Assert.IsTrue (sign.CheckSignature (new HMACSHA256 (hmackey))); } [Test] public void SignHMAC_SHA512 () { SignedXml sign = SignHMAC (EncryptedXml.XmlEncSHA512Url, new HMACSHA512 (hmackey), true); - AssertEquals ("SignatureMethod", more512, sign.SignatureMethod); + Assert.AreEqual (more512, sign.SignatureMethod, "SignatureMethod"); } [Test] public void SignHMAC_SHA512_Bad () { SignedXml sign = SignHMAC (more512, new HMACSHA512 (hmackey), false); - AssertEquals ("SignatureMethod", more512, sign.SignatureMethod); + Assert.AreEqual (more512, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1231,7 +1229,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { sign.LoadXml (doc.DocumentElement ["Signature"]); // verify MS-generated signature - Assert (sign.CheckSignature (new HMACSHA512 (hmackey))); + Assert.IsTrue (sign.CheckSignature (new HMACSHA512 (hmackey))); } [Test] @@ -1240,7 +1238,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { // works as long as the string can be used by CryptoConfig to create // an instance of the required hash algorithm SignedXml sign = SignHMAC ("SHA384", new HMACSHA384 (hmackey), true); - AssertEquals ("SignatureMethod", more384, sign.SignatureMethod); + Assert.AreEqual (more384, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1248,7 +1246,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { { // we can't verity the signature if the URI is used SignedXml sign = SignHMAC (more384, new HMACSHA384 (hmackey), false); - AssertEquals ("SignatureMethod", more384, sign.SignatureMethod); + Assert.AreEqual (more384, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1262,7 +1260,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { sign.LoadXml (doc.DocumentElement ["Signature"]); // verify MS-generated signature - Assert (sign.CheckSignature (new HMACSHA384 (hmackey))); + Assert.IsTrue (sign.CheckSignature (new HMACSHA384 (hmackey))); } [Test] @@ -1271,7 +1269,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { // works as long as the string can be used by CryptoConfig to create // an instance of the required hash algorithm SignedXml sign = SignHMAC ("RIPEMD160", new HMACRIPEMD160 (hmackey), true); - AssertEquals ("SignatureMethod", moreripe, sign.SignatureMethod); + Assert.AreEqual (moreripe, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1279,7 +1277,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { { // we can't verity the signature if the URI is used SignedXml sign = SignHMAC (moreripe, new HMACRIPEMD160 (hmackey), false); - AssertEquals ("SignatureMethod", moreripe, sign.SignatureMethod); + Assert.AreEqual (moreripe, sign.SignatureMethod, "SignatureMethod"); } [Test] @@ -1293,7 +1291,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { sign.LoadXml (doc.DocumentElement ["Signature"]); // verify MS-generated signature - Assert (sign.CheckSignature (new HMACRIPEMD160 (hmackey))); + Assert.IsTrue (sign.CheckSignature (new HMACRIPEMD160 (hmackey))); } #endif } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs index 1fc613cd52f..5f9684470e6 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/TransformChainTest.cs @@ -17,15 +17,15 @@ using NUnit.Framework; namespace MonoTests.System.Security.Cryptography.Xml { [TestFixture] - public class TransformChainTest : Assertion { + public class TransformChainTest { [Test] public void EmptyChain () { TransformChain chain = new TransformChain (); - AssertEquals ("empty count", 0, chain.Count); - AssertNotNull ("IEnumerator", chain.GetEnumerator ()); - AssertEquals ("ToString()", "System.Security.Cryptography.Xml.TransformChain", chain.ToString ()); + Assert.AreEqual (0, chain.Count, "empty count"); + Assert.IsNotNull (chain.GetEnumerator (), "IEnumerator"); + Assert.AreEqual ("System.Security.Cryptography.Xml.TransformChain", chain.ToString (), "ToString()"); } [Test] @@ -35,33 +35,33 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDsigBase64Transform base64 = new XmlDsigBase64Transform (); chain.Add (base64); - AssertEquals ("XmlDsigBase64Transform", base64, chain[0]); - AssertEquals ("count 1", 1, chain.Count); + Assert.AreEqual (base64, chain[0], "XmlDsigBase64Transform"); + Assert.AreEqual (1, chain.Count, "count 1"); XmlDsigC14NTransform c14n = new XmlDsigC14NTransform (); chain.Add (c14n); - AssertEquals ("XmlDsigC14NTransform", c14n, chain[1]); - AssertEquals ("count 2", 2, chain.Count); + Assert.AreEqual (c14n, chain[1], "XmlDsigC14NTransform"); + Assert.AreEqual (2, chain.Count, "count 2"); XmlDsigC14NWithCommentsTransform c14nc = new XmlDsigC14NWithCommentsTransform (); chain.Add (c14nc); - AssertEquals ("XmlDsigC14NWithCommentsTransform", c14nc, chain[2]); - AssertEquals ("count 3", 3, chain.Count); + Assert.AreEqual (c14nc, chain[2], "XmlDsigC14NWithCommentsTransform"); + Assert.AreEqual (3, chain.Count, "count 3"); XmlDsigEnvelopedSignatureTransform esign = new XmlDsigEnvelopedSignatureTransform (); chain.Add (esign); - AssertEquals ("XmlDsigEnvelopedSignatureTransform", esign, chain[3]); - AssertEquals ("count 4", 4, chain.Count); + Assert.AreEqual (esign, chain[3], "XmlDsigEnvelopedSignatureTransform"); + Assert.AreEqual (4, chain.Count, "count 4"); XmlDsigXPathTransform xpath = new XmlDsigXPathTransform (); chain.Add (xpath); - AssertEquals ("XmlDsigXPathTransform", xpath, chain[4]); - AssertEquals ("count 5", 5, chain.Count); + Assert.AreEqual (xpath, chain[4], "XmlDsigXPathTransform"); + Assert.AreEqual (5, chain.Count, "count 5"); XmlDsigXsltTransform xslt = new XmlDsigXsltTransform (); chain.Add (xslt); - AssertEquals ("XmlDsigXsltTransform", xslt, chain[5]); - AssertEquals ("count 6", 6, chain.Count); + Assert.AreEqual (xslt, chain[5], "XmlDsigXsltTransform"); + Assert.AreEqual (6, chain.Count, "count 6"); } } } diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs index f553a44d920..e1a847ae549 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigBase64TransformTest.cs @@ -29,7 +29,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigBase64TransformTest : Assertion { + public class XmlDsigBase64TransformTest { protected UnprotectedXmlDsigBase64Transform transform; @@ -43,10 +43,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void Properties () { - AssertEquals ("Algorithm", "http://www.w3.org/2000/09/xmldsig#base64", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/2000/09/xmldsig#base64", transform.Algorithm, "Algorithm"); Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -59,19 +59,19 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool ostream = false; foreach (Type t in input) { if (t.ToString () == "System.IO.Stream") ostream = true; } - Assert ("Output Stream", ostream); + Assert.IsTrue (ostream, "Output Stream"); } [Test] @@ -83,12 +83,12 @@ namespace MonoTests.System.Security.Cryptography.Xml { input [2] = null; // property does not return a clone foreach (Type t in transform.InputTypes) { - AssertNull (t); + Assert.IsNull (t); } // it's not a static array XmlDsigBase64Transform t2 = new XmlDsigBase64Transform (); foreach (Type t in t2.InputTypes) { - AssertNotNull (t); + Assert.IsNotNull (t); } } @@ -96,7 +96,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertNull ("Default InnerXml", xnl); + Assert.IsNull (xnl, "Default InnerXml"); } private string Stream2String (Stream s) @@ -123,7 +123,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals("XmlDocument", base64, output); + Assert.AreEqual (base64, output, "XmlDocument"); } [Test] @@ -131,11 +131,11 @@ namespace MonoTests.System.Security.Cryptography.Xml { { XmlDocument doc = GetDoc (); XmlNodeList xpath = doc.SelectNodes ("//."); - AssertEquals("XPathNodeList.Count", 3, xpath.Count); + Assert.AreEqual (3, xpath.Count, "XPathNodeList.Count"); transform.LoadInput (xpath); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("XPathNodeList", base64, output); + Assert.AreEqual (base64, output, "XPathNodeList"); } [Test] @@ -146,7 +146,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); // Note that ChildNodes does not contain the text node. - AssertEquals ("XmlChildNodes", String.Empty, output); + Assert.AreEqual (String.Empty, output, "XmlChildNodes"); } [Test] @@ -159,7 +159,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (ms); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("MemoryStream", base64, output); + Assert.AreEqual (base64, output, "MemoryStream"); } [Test] 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 99c4480534b..8ddba56c7e1 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 @@ -38,7 +38,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigC14NTransformTest : Assertion { + public class XmlDsigC14NTransformTest { protected UnprotectedXmlDsigC14NTransform transform; @@ -63,7 +63,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] // ctor () public void Constructor1 () { - AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm, "Algorithm"); CheckProperties (transform); } @@ -71,18 +71,18 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void Constructor2 () { transform = new UnprotectedXmlDsigC14NTransform (true); - AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", transform.Algorithm, "Algorithm"); CheckProperties (transform); transform = new UnprotectedXmlDsigC14NTransform (false); - AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", transform.Algorithm, "Algorithm"); CheckProperties (transform); } void CheckProperties (XmlDsigC14NTransform transform) { Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -95,26 +95,26 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool ostream = false; foreach (Type t in output) { if (t.ToString () == "System.IO.Stream") ostream = true; } - Assert ("Output Stream", ostream); + Assert.IsTrue (ostream, "Output Stream"); } [Test] public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertNull ("Default InnerXml", xnl); + Assert.IsNull (xnl, "Default InnerXml"); } private string Stream2String (Stream s) @@ -154,10 +154,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); #if NET_1_1 - AssertEquals("XmlDocument", c14xml3, output); + Assert.AreEqual (c14xml3, output, "XmlDocument"); #else // .NET 1.0 keeps the \r\n (0x0D, 0x0A) - bug - AssertEquals("XmlDocument", c14xml1, output); + Assert.AreEqual (c14xml1, output, "XmlDocument"); #endif } @@ -173,7 +173,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc.ChildNodes); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("XmlChildNodes", "<Test></Test>", output); + Assert.AreEqual ("<Test></Test>", output, "XmlChildNodes"); } [Test] @@ -188,7 +188,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); string expected = @"<Test><Toto></Toto></Test>"; - AssertEquals ("XmlChildNodes", expected, output); + Assert.AreEqual (expected, output, "XmlChildNodes"); } [Test] @@ -201,7 +201,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (ms); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("MemoryStream", c14xml2, output); + Assert.AreEqual (c14xml2, output, "MemoryStream"); } [Test] @@ -232,24 +232,21 @@ namespace MonoTests.System.Security.Cryptography.Xml { sw.Close (); } string res = ExecuteXmlDSigC14NTransform (C14NSpecExample1Input); - AssertEquals ("Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (without comments)", - C14NSpecExample1Output, res); + Assert.AreEqual (C14NSpecExample1Output, res, "Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (without comments)"); } [Test] public void C14NSpecExample2 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample2Input); - AssertEquals ("Example 2 from c14n spec - Whitespace in Document Content (without comments)", - C14NSpecExample2Output, res); + Assert.AreEqual (C14NSpecExample2Output, res, "Example 2 from c14n spec - Whitespace in Document Content (without comments)"); } [Test] public void C14NSpecExample3 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample3Input); - AssertEquals ("Example 3 from c14n spec - Start and End Tags (without comments)", - C14NSpecExample3Output, res); + Assert.AreEqual (C14NSpecExample3Output, res, "Example 3 from c14n spec - Start and End Tags (without comments)"); } [Test] @@ -257,8 +254,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void C14NSpecExample4 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample4Input); - AssertEquals ("Example 4 from c14n spec - Character Modifications and Character References (without comments)", - C14NSpecExample4Output, res); + Assert.AreEqual (C14NSpecExample4Output, res, "Example 4 from c14n spec - Character Modifications and Character References (without comments)"); } [Test] @@ -269,16 +265,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { sw.Close (); } string res = ExecuteXmlDSigC14NTransform (C14NSpecExample5Input); - AssertEquals ("Example 5 from c14n spec - Entity References (without comments)", - C14NSpecExample5Output, res); + Assert.AreEqual (C14NSpecExample5Output, res, "Example 5 from c14n spec - Entity References (without comments)"); } [Test] public void C14NSpecExample6 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample6Input); - AssertEquals ("Example 6 from c14n spec - UTF-8 Encoding (without comments)", - C14NSpecExample6Output, res); + Assert.AreEqual (C14NSpecExample6Output, res, "Example 6 from c14n spec - UTF-8 Encoding (without comments)"); } private string ExecuteXmlDSigC14NTransform (string InputXml) @@ -508,7 +502,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDsigC14NTransform t = new XmlDsigC14NTransform (); t.LoadInput (doc); Stream s = t.GetOutput () as Stream; - AssertEquals (expected, new StreamReader (s, Encoding.UTF8).ReadToEnd ()); + Assert.AreEqual (new StreamReader (s, Encoding.UTF8).ReadToEnd (), expected); } #if NET_2_0 @@ -518,12 +512,12 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.AppendChild (doc.CreateElement ("foo", "urn:foo")); doc.DocumentElement.AppendChild (doc.CreateElement ("bar", "urn:bar")); - AssertEquals ("#1", String.Empty, doc.DocumentElement.GetAttribute ("xmlns")); + Assert.AreEqual (String.Empty, doc.DocumentElement.GetAttribute ("xmlns"), "#1"); XmlDsigC14NTransform t = new XmlDsigC14NTransform (); t.LoadInput (doc); Stream s = t.GetOutput () as Stream; - AssertEquals ("<foo xmlns=\"urn:foo\"><bar xmlns=\"urn:bar\"></bar></foo>", new StreamReader (s, Encoding.UTF8).ReadToEnd ()); - AssertEquals ("#2", "urn:foo", doc.DocumentElement.GetAttribute ("xmlns")); + Assert.AreEqual (new StreamReader (s, Encoding.UTF8).ReadToEnd (), "<foo xmlns=\"urn:foo\"><bar xmlns=\"urn:bar\"></bar></foo>"); + Assert.AreEqual ("urn:foo", doc.DocumentElement.GetAttribute ("xmlns"), "#2"); } [Test] @@ -533,14 +527,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = new XmlDocument (); doc.AppendChild (doc.CreateElement ("foo", "urn:foo")); doc.DocumentElement.AppendChild (doc.CreateElement ("bar", "urn:bar")); - AssertEquals ("#1", String.Empty, doc.DocumentElement.GetAttribute ("xmlns:f")); + Assert.AreEqual (String.Empty, doc.DocumentElement.GetAttribute ("xmlns:f"), "#1"); XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform (); t.LoadInput (doc); t.PropagatedNamespaces.Add ("f", "urn:foo"); t.PropagatedNamespaces.Add ("b", "urn:bar"); Stream s = t.GetOutput () as Stream; - AssertEquals ("<f:foo xmlns:f=\"urn:foo\"><b:bar xmlns:b=\"urn:bar\"></b:bar></f:foo>", new StreamReader (s, Encoding.UTF8).ReadToEnd ()); - AssertEquals ("#2", "urn:foo", doc.DocumentElement.GetAttribute ("xmlns:f")); + Assert.AreEqual (new StreamReader (s, Encoding.UTF8).ReadToEnd (), "<f:foo xmlns:f=\"urn:foo\"><b:bar xmlns:b=\"urn:bar\"></b:bar></f:foo>"); + Assert.AreEqual ("urn:foo", doc.DocumentElement.GetAttribute ("xmlns:f"), "#2"); } [Test] diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs index 0a15c196568..a97701123cf 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransformTest.cs @@ -30,7 +30,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigC14NWithCommentsTransformTest : Assertion { + public class XmlDsigC14NWithCommentsTransformTest { protected UnprotectedXmlDsigC14NWithCommentsTransform transform; @@ -59,10 +59,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void Properties () { - AssertEquals ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", transform.Algorithm, "Algorithm"); Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -75,26 +75,26 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool ostream = false; foreach (Type t in output) { if (t.ToString () == "System.IO.Stream") ostream = true; } - Assert ("Output Stream", ostream); + Assert.IsTrue (ostream, "Output Stream"); } [Test] public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertEquals ("Default InnerXml", null, xnl); + Assert.AreEqual (null, xnl, "Default InnerXml"); } #if NET_2_0 @@ -125,8 +125,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { sw.Close (); } string res = ExecuteXmlDSigC14NTransform (C14NSpecExample1Input, true); - AssertEquals ("Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (with comments)", - C14NSpecExample1Output, res); + Assert.AreEqual (C14NSpecExample1Output, res, "Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (with comments)"); } [Test] @@ -144,32 +143,28 @@ namespace MonoTests.System.Security.Cryptography.Xml { NUnit.Framework.Assert.Ignore ("SecurityManager isn't enabled."); #endif string res = ExecuteXmlDSigC14NTransform (C14NSpecExample1Input, false); - AssertEquals ("Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (with comments)", - C14NSpecExample1Output, res); + Assert.AreEqual (C14NSpecExample1Output, res, "Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (with comments)"); } [Test] public void C14NSpecExample2 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample2Input, false); - AssertEquals ("Example 2 from c14n spec - Whitespace in Document Content (with comments)", - C14NSpecExample2Output, res); + Assert.AreEqual (C14NSpecExample2Output, res, "Example 2 from c14n spec - Whitespace in Document Content (with comments)"); } [Test] public void C14NSpecExample3 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample3Input, false); - AssertEquals ("Example 3 from c14n spec - Start and End Tags (with comments)", - C14NSpecExample3Output, res); + Assert.AreEqual (C14NSpecExample3Output, res, "Example 3 from c14n spec - Start and End Tags (with comments)"); } [Test] public void C14NSpecExample4 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample4Input, false); - AssertEquals ("Example 4 from c14n spec - Character Modifications and Character References (with comments)", - C14NSpecExample4Output, res); + Assert.AreEqual (C14NSpecExample4Output, res, "Example 4 from c14n spec - Character Modifications and Character References (with comments)"); } [Test] @@ -182,16 +177,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { } } string res = ExecuteXmlDSigC14NTransform (C14NSpecExample5Input, false); - AssertEquals ("Example 5 from c14n spec - Entity References (with comments)", - C14NSpecExample5Output, res); + Assert.AreEqual (C14NSpecExample5Output, res, "Example 5 from c14n spec - Entity References (with comments)"); } [Test] public void C14NSpecExample6 () { string res = ExecuteXmlDSigC14NTransform (C14NSpecExample6Input, false); - AssertEquals ("Example 6 from c14n spec - UTF-8 Encoding (with comments)", - C14NSpecExample6Output, res); + Assert.AreEqual (C14NSpecExample6Output, res, "Example 6 from c14n spec - UTF-8 Encoding (with comments)"); } private string ExecuteXmlDSigC14NTransform (string InputXml, bool resolver) 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 118caa48fbb..bd70d9b2b60 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 @@ -59,7 +59,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigExcC14NTransformTest : Assertion { + public class XmlDsigExcC14NTransformTest { protected UnprotectedXmlDsigExcC14NTransform transform; @@ -84,8 +84,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] // ctor () public void Constructor1 () { - AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); - AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "InclusiveNamespacesPrefixList"); CheckProperties (transform); } @@ -93,13 +93,13 @@ namespace MonoTests.System.Security.Cryptography.Xml { 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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "InclusiveNamespacesPrefixList"); CheckProperties (transform); transform = new UnprotectedXmlDsigExcC14NTransform (false); - AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); - AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "InclusiveNamespacesPrefixList"); CheckProperties (transform); } @@ -107,18 +107,18 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void Constructor3 () { transform = new UnprotectedXmlDsigExcC14NTransform (null); - AssertEquals ("Algorithm", "http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm); - AssertNull ("InclusiveNamespacesPrefixList", transform.InclusiveNamespacesPrefixList); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.AreEqual (string.Empty, transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.AreEqual ("#default xsd", transform.InclusiveNamespacesPrefixList, "InclusiveNamespacesPrefixList"); CheckProperties (transform); } @@ -126,40 +126,40 @@ namespace MonoTests.System.Security.Cryptography.Xml { 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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm, "Algorithm"); + Assert.AreEqual (string.Empty, transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#WithComments", transform.Algorithm, "Algorithm"); + Assert.AreEqual ("#default xsd", transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.IsNull (transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.AreEqual (string.Empty, transform.InclusiveNamespacesPrefixList, "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); + Assert.AreEqual ("http://www.w3.org/2001/10/xml-exc-c14n#", transform.Algorithm, "Algorithm"); + Assert.AreEqual ("#default xsd", transform.InclusiveNamespacesPrefixList, "InclusiveNamespacesPrefixList"); CheckProperties (transform); } void CheckProperties (XmlDsigExcC14NTransform transform) { Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -172,19 +172,19 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool ostream = false; foreach (Type t in output) { if (t.ToString () == "System.IO.Stream") ostream = true; } - Assert ("Output Stream", ostream); + Assert.IsTrue (ostream, "Output Stream"); } [Test] @@ -196,12 +196,12 @@ namespace MonoTests.System.Security.Cryptography.Xml { input [2] = null; // property does not return a clone foreach (Type t in transform.InputTypes) { - AssertNull (t); + Assert.IsNull (t); } // it's not a static array XmlDsigExcC14NTransform t2 = new XmlDsigExcC14NTransform (); foreach (Type t in t2.InputTypes) { - AssertNotNull (t); + Assert.IsNotNull (t); } } @@ -209,7 +209,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertNull ("Default InnerXml", xnl); + Assert.IsNull (xnl, "Default InnerXml"); } private string Stream2String (Stream s) @@ -249,10 +249,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); #if NET_1_1 - AssertEquals("XmlDocument", c14xml3, output); + Assert.AreEqual (c14xml3, output, "XmlDocument"); #else // .NET 1.0 keeps the \r\n (0x0D, 0x0A) - bug - AssertEquals("XmlDocument", c14xml1, output); + Assert.AreEqual (c14xml1, output, "XmlDocument"); #endif } @@ -268,7 +268,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc.ChildNodes); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("XmlChildNodes", "<Test></Test>", output); + Assert.AreEqual ("<Test></Test>", output, "XmlChildNodes"); } [Test] @@ -283,7 +283,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); string expected = @"<Test><Toto></Toto></Test>"; - AssertEquals ("XmlChildNodes", expected, output); + Assert.AreEqual (expected, output, "XmlChildNodes"); } [Test] @@ -296,7 +296,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (ms); Stream s = (Stream) transform.GetOutput (); string output = Stream2String (s); - AssertEquals ("MemoryStream", c14xml2, output); + Assert.AreEqual (c14xml2, output, "MemoryStream"); } [Test] @@ -323,24 +323,21 @@ namespace MonoTests.System.Security.Cryptography.Xml { sw.Close (); } string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample1Input); - AssertEquals ("Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (without comments)", - ExcC14NSpecExample1Output, res); + Assert.AreEqual (ExcC14NSpecExample1Output, res, "Example 1 from c14n spec - PIs, Comments, and Outside of Document Element (without comments)"); } [Test] public void ExcC14NSpecExample2 () { string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample2Input); - AssertEquals ("Example 2 from c14n spec - Whitespace in Document Content (without comments)", - ExcC14NSpecExample2Output, res); + Assert.AreEqual (ExcC14NSpecExample2Output, res, "Example 2 from c14n spec - Whitespace in Document Content (without comments)"); } [Test] public void ExcC14NSpecExample3 () { string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample3Input); - AssertEquals ("Example 3 from c14n spec - Start and End Tags (without comments)", - ExcC14NSpecExample3Output, res); + Assert.AreEqual (ExcC14NSpecExample3Output, res, "Example 3 from c14n spec - Start and End Tags (without comments)"); } [Test] @@ -348,8 +345,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void ExcC14NSpecExample4 () { string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample4Input); - AssertEquals ("Example 4 from c14n spec - Character Modifications and Character References (without comments)", - ExcC14NSpecExample4Output, res); + Assert.AreEqual (ExcC14NSpecExample4Output, res, "Example 4 from c14n spec - Character Modifications and Character References (without comments)"); } [Test] @@ -360,16 +356,14 @@ namespace MonoTests.System.Security.Cryptography.Xml { sw.Close (); } string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample5Input); - AssertEquals ("Example 5 from c14n spec - Entity References (without comments)", - ExcC14NSpecExample5Output, res); + Assert.AreEqual (ExcC14NSpecExample5Output, res, "Example 5 from c14n spec - Entity References (without comments)"); } [Test] public void ExcC14NSpecExample6 () { string res = ExecuteXmlDSigExcC14NTransform (ExcC14NSpecExample6Input); - AssertEquals ("Example 6 from c14n spec - UTF-8 Encoding (without comments)", - ExcC14NSpecExample6Output, res); + Assert.AreEqual (ExcC14NSpecExample6Output, res, "Example 6 from c14n spec - UTF-8 Encoding (without comments)"); } private string ExecuteXmlDSigExcC14NTransform (string InputXml) @@ -599,7 +593,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDsigExcC14NTransform t = new XmlDsigExcC14NTransform (); t.LoadInput (doc); Stream s = t.GetOutput () as Stream; - AssertEquals (expected, new StreamReader (s, Encoding.UTF8).ReadToEnd ()); + Assert.AreEqual (new StreamReader (s, Encoding.UTF8).ReadToEnd (), expected); } [Test] diff --git a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs index 26cdfaab395..a3fa4215609 100644 --- a/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs +++ b/mcs/class/System.Security/Test/System.Security.Cryptography.Xml/XmlDsigXPathTransformTest.cs @@ -32,7 +32,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigXPathTransformTest : Assertion { + public class XmlDsigXPathTransformTest { protected UnprotectedXmlDsigXPathTransform transform; @@ -45,10 +45,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { [Test] public void Properties () { - AssertEquals ("Algorithm", "http://www.w3.org/TR/1999/REC-xpath-19991116", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/1999/REC-xpath-19991116", transform.Algorithm, "Algorithm"); Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -61,28 +61,28 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool oxmlnl = false; foreach (Type t in output) { if (t.ToString () == "System.Xml.XmlNodeList") oxmlnl = true; } - Assert ("Output XmlNodeList", oxmlnl); + Assert.IsTrue (oxmlnl, "Output XmlNodeList"); } - protected void AssertEquals (string msg, XmlNodeList expected, XmlNodeList actual) + protected void AreEqual (string msg, XmlNodeList expected, XmlNodeList actual) { 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); } - AssertEquals (expected.Count, actual.Count); + Assert.AreEqual (expected.Count, actual.Count); } [Test] @@ -92,8 +92,8 @@ namespace MonoTests.System.Security.Cryptography.Xml { public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertEquals ("Default InnerXml.Count", 1, xnl.Count); - AssertEquals ("Default InnerXml.OuterXml", "<XPath xmlns=\"http://www.w3.org/2000/09/xmldsig#\"></XPath>", xnl [0].OuterXml); + Assert.AreEqual (1, xnl.Count, "Default InnerXml.Count"); + Assert.AreEqual ("<XPath xmlns=\"http://www.w3.org/2000/09/xmldsig#\"></XPath>", xnl [0].OuterXml, "Default InnerXml.OuterXml"); } [Test] @@ -106,7 +106,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInnerXml (inner); XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); #if NET_2_0 - AssertEquals ("Count", 0, xnl.Count); + Assert.AreEqual (0, xnl.Count, "Count"); #endif } @@ -143,9 +143,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInnerXml (inner); XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); #if NET_2_0 - AssertEquals (73, xnl.Count); + Assert.AreEqual (73, xnl.Count); #else - AssertEquals (47, xnl.Count); + Assert.AreEqual (47, xnl.Count); #endif } @@ -156,7 +156,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc); // empty means no LoadInnerXml XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); - AssertEquals ("Empy Result", 0, xnl.Count); + Assert.AreEqual (0, xnl.Count, "Empy Result"); } [Test] @@ -168,7 +168,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlNodeList inner = InnerXml ("//*/title"); transform.LoadInnerXml (inner); XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); - AssertEquals (1, xnl.Count); + Assert.AreEqual (1, xnl.Count); } [Test] @@ -178,7 +178,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (doc.ChildNodes); // empty means no LoadInnerXml XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); - AssertEquals ("Empy Result", 0, xnl.Count); + Assert.AreEqual (0, xnl.Count, "Empy Result"); } [Test] @@ -197,9 +197,9 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInnerXml (inner); XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); #if NET_2_0 - AssertEquals (73, xnl.Count); + Assert.AreEqual (73, xnl.Count); #else - AssertEquals (47, xnl.Count); + Assert.AreEqual (47, xnl.Count); #endif } @@ -213,7 +213,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { transform.LoadInput (ms); // empty means no LoadInnerXml XmlNodeList xnl = (XmlNodeList) transform.GetOutput (); - AssertEquals ("Empy Result", 0, xnl.Count); + Assert.AreEqual (0, xnl.Count, "Empy Result"); } [Test] @@ -222,7 +222,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlNodeList inner = InnerXml ("//*"); transform.LoadInnerXml (inner); XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertEquals ("LoadInnerXml", inner, xnl); + Assert.AreEqual (inner, xnl, "LoadInnerXml"); } [Test] @@ -254,18 +254,18 @@ namespace MonoTests.System.Security.Cryptography.Xml { doc.LoadXml ("<element xmlns='urn:foo'><foo><bar>test</bar></foo></element>"); t.LoadInput (doc); XmlNodeList nl = (XmlNodeList) t.GetOutput (); - AssertEquals (XmlNodeType.Document, nl [0].NodeType); - AssertEquals (XmlNodeType.Element, nl [1].NodeType); - AssertEquals ("element", nl [1].LocalName); - AssertEquals (XmlNodeType.Element, nl [2].NodeType); - AssertEquals ("foo", nl [2].LocalName); - AssertEquals (XmlNodeType.Element, nl [3].NodeType); - AssertEquals ("bar", nl [3].LocalName); + Assert.AreEqual (XmlNodeType.Document, nl [0].NodeType); + Assert.AreEqual (XmlNodeType.Element, nl [1].NodeType); + Assert.AreEqual ("element", nl [1].LocalName); + Assert.AreEqual (XmlNodeType.Element, nl [2].NodeType); + Assert.AreEqual ("foo", nl [2].LocalName); + Assert.AreEqual (XmlNodeType.Element, nl [3].NodeType); + Assert.AreEqual ("bar", nl [3].LocalName); // MS.NET bug - ms.net returns ns node even when the // current node is ns node (it is like returning // attribute from attribute nodes). -// AssertEquals (XmlNodeType.Attribute, nl [4].NodeType); -// AssertEquals ("xmlns", nl [4].LocalName); +// Assert.AreEqual (XmlNodeType.Attribute, nl [4].NodeType); +// Assert.AreEqual ("xmlns", nl [4].LocalName); } [Test] @@ -286,43 +286,43 @@ namespace MonoTests.System.Security.Cryptography.Xml { t.LoadInput (doc); XmlNodeList nl = (XmlNodeList) t.GetOutput (); - AssertEquals ("0", 0, nl.Count); + Assert.AreEqual (0, nl.Count, "0"); doc.LoadXml ("<element xmlns='urn:foo'><foo><bar>test</bar></foo></element>"); t.LoadInput (doc); nl = (XmlNodeList) t.GetOutput (); #if NET_2_0 - AssertEquals ("1", 0, nl.Count); + Assert.AreEqual (0, nl.Count, "1"); #else - AssertEquals ("1", 1, nl.Count); + Assert.AreEqual (1, nl.Count, "1"); #endif doc.LoadXml ("<element xmlns='urn:foo'><foo xmlns='urn:bar'><bar>test</bar></foo></element>"); t.LoadInput (doc); nl = (XmlNodeList) t.GetOutput (); #if NET_2_0 - AssertEquals ("2", 0, nl.Count); + Assert.AreEqual (0, nl.Count, "2"); #else - AssertEquals ("2", 2, nl.Count); + Assert.AreEqual (2, nl.Count, "2"); #endif doc.LoadXml ("<element xmlns='urn:foo' xmlns:x='urn:x'><foo xmlns='urn:bar'><bar>test</bar></foo></element>"); t.LoadInput (doc); nl = (XmlNodeList) t.GetOutput (); #if NET_2_0 - AssertEquals ("3", 0, nl.Count); + Assert.AreEqual (0, nl.Count, "3"); #else - AssertEquals ("3", 3, nl.Count); + Assert.AreEqual (3, nl.Count, "3"); #endif doc.LoadXml ("<envelope><Signature xmlns='http://www.w3.org/2000/09/xmldsig#'><XPath>blah</XPath></Signature></envelope>"); t.LoadInput (doc); nl = (XmlNodeList) t.GetOutput (); #if NET_2_0 - AssertEquals ("4", 0, nl.Count); + Assert.AreEqual (0, nl.Count, "4"); #else - AssertEquals ("4", 1, nl.Count); - AssertEquals ("NodeType", XmlNodeType.Attribute, nl [0].NodeType); + Assert.AreEqual (1, nl.Count, "4"); + Assert.AreEqual (XmlNodeType.Attribute, nl [0].NodeType, "NodeType"); #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 568023c8ac1..2074c79333b 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 @@ -39,7 +39,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { } [TestFixture] - public class XmlDsigXsltTransformTest : Assertion { + public class XmlDsigXsltTransformTest { protected UnprotectedXmlDsigXsltTransform transform; @@ -66,10 +66,10 @@ namespace MonoTests.System.Security.Cryptography.Xml { void CheckProperties (XmlDsigXsltTransform transform) { - AssertEquals ("Algorithm", "http://www.w3.org/TR/1999/REC-xslt-19991116", transform.Algorithm); + Assert.AreEqual ("http://www.w3.org/TR/1999/REC-xslt-19991116", transform.Algorithm, "Algorithm"); Type[] input = transform.InputTypes; - Assert ("Input #", (input.Length == 3)); + Assert.IsTrue ((input.Length == 3), "Input #"); // check presence of every supported input types bool istream = false; bool ixmldoc = false; @@ -82,26 +82,26 @@ namespace MonoTests.System.Security.Cryptography.Xml { if (t.ToString () == "System.Xml.XmlNodeList") ixmlnl = true; } - Assert ("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; - Assert ("Output #", (output.Length == 1)); + Assert.IsTrue ((output.Length == 1), "Output #"); // check presence of every supported output types bool ostream = false; foreach (Type t in output) { if (t.ToString () == "System.IO.Stream") ostream = true; } - Assert ("Output Stream", ostream); + Assert.IsTrue (ostream, "Output Stream"); } [Test] public void GetInnerXml () { XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertNull ("Default InnerXml", xnl); + Assert.IsNull (xnl, "Default InnerXml"); } private string Stream2Array (Stream s) @@ -169,7 +169,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { #endif } finally { - Assert ("Exception not thrown", result); + Assert.IsTrue (result, "Exception not thrown"); } } @@ -242,11 +242,11 @@ namespace MonoTests.System.Security.Cryptography.Xml { string output = Stream2Array (s); } - protected void AssertEquals (string msg, XmlNodeList expected, XmlNodeList actual) + protected void AreEqual (string msg, XmlNodeList expected, XmlNodeList actual) { 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); } } @@ -256,7 +256,7 @@ namespace MonoTests.System.Security.Cryptography.Xml { XmlDocument doc = GetXslDoc (); transform.LoadInnerXml (doc.DocumentElement.ChildNodes); XmlNodeList xnl = transform.UnprotectedGetInnerXml (); - AssertEquals ("LoadInnerXml", doc.DocumentElement.ChildNodes, xnl); + Assert.AreEqual (doc.DocumentElement.ChildNodes, xnl, "LoadInnerXml"); } [Test] |