diff options
author | Alexander Kyte <alexmkyte@fastmail.com> | 2016-06-02 04:15:27 +0300 |
---|---|---|
committer | Alexander Kyte <alexmkyte@fastmail.com> | 2016-06-07 21:56:51 +0300 |
commit | ac19ad8a47d9c92f3fa726eb2bfb43f82aa63917 (patch) | |
tree | 20dd9e2ce0393f6bda897a50ced30902482fbdde | |
parent | 27e164695941b9ec554dc9b890edaab5663abfe2 (diff) |
[mobile_static] Remove uses of deprecated Assertion.cs nunit helper.
31 files changed, 676 insertions, 672 deletions
diff --git a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD2Test.cs b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD2Test.cs index a6a92f06430..65b46010fc3 100644 --- a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD2Test.cs +++ b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD2Test.cs @@ -31,9 +31,9 @@ public class MD2Test { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Assertion.Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Assertion.Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -48,7 +48,7 @@ public class MD2Test { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assertion.Assert (msg, a); + Assert.IsTrue (a, msg); } // MD2 ("") = 8350e5a3e24c153df2275c9f80692773 @@ -208,7 +208,7 @@ public class MD2Test { for (int i=0; i < input.Length - 1; i++) hash.TransformBlock (input, i, 1, copy, i); byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1); - Assertion.AssertEquals (testName + ".e.1", input [input.Length - 1], output [0]); + Assert.AreEqual (input [input.Length - 1], output [0], testName + ".e.1"); AssertEquals (testName + ".e.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); @@ -218,9 +218,9 @@ public class MD2Test { public virtual void StaticInfo () { string className = hash.ToString (); - Assertion.AssertEquals (className + ".HashSize", 128, hash.HashSize); - Assertion.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize); - Assertion.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize); + Assert.AreEqual (128, hash.HashSize, className + ".HashSize",); + Assert.AreEqual (1, hash.InputBlockSize, className + ".InputBlockSize"); + Assert.AreEqual (1, hash.OutputBlockSize, className + ".OutputBlockSize"); } } diff --git a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD4Test.cs b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD4Test.cs index 308b689b91c..111035eb5ac 100644 --- a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD4Test.cs +++ b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD4Test.cs @@ -31,9 +31,9 @@ public class MD4Test { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Assertion.Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Assertion.Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -48,7 +48,7 @@ public class MD4Test { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assertion.Assert (msg, a); + Assert.IsTrue (a, msg); } // MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0 @@ -208,7 +208,7 @@ public class MD4Test { for (int i=0; i < input.Length - 1; i++) hash.TransformBlock (input, i, 1, copy, i); byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1); - Assertion.AssertEquals (testName + ".e.1", input [input.Length - 1], output [0]); + Assert.AreEqual (input [input.Length - 1], output [0], testName + ".e.1"); AssertEquals (testName + ".e.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); @@ -218,9 +218,9 @@ public class MD4Test { public virtual void StaticInfo () { string className = hash.ToString (); - Assertion.AssertEquals (className + ".HashSize", 128, hash.HashSize); - Assertion.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize); - Assertion.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize); + Assert.AreEqual (128, hash.HashSize, className + ".HashSize"); + Assert.AreEqual (1, hash.InputBlockSize, className + ".InputBlockSize"); + Assert.AreEqual (1, hash.OutputBlockSize, className + ".OutputBlockSize"); } } diff --git a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD5Test.cs b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD5Test.cs index 1eb70789380..a5796e910d7 100644 --- a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD5Test.cs +++ b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/MD5Test.cs @@ -33,9 +33,9 @@ public class MD5Test { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Assertion.Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Assertion.Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -50,7 +50,7 @@ public class MD5Test { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assertion.Assert (msg, a); + Assert.IsTrue (a, msg); } // MD5 ("") = d41d8cd98f00b204e9800998ecf8427e @@ -210,7 +210,7 @@ public class MD5Test { for (int i=0; i < input.Length - 1; i++) hash.TransformBlock (input, i, 1, copy, i); byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1); - Assertion.AssertEquals (testName + ".e.1", input [input.Length - 1], output [0]); + Assert.AreEqual (input [input.Length - 1], output [0], testName + ".e.1"); AssertEquals (testName + ".e.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); @@ -220,9 +220,9 @@ public class MD5Test { public virtual void StaticInfo () { string className = hash.ToString (); - Assertion.AssertEquals (className + ".HashSize", 128, hash.HashSize); - Assertion.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize); - Assertion.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize); + Assert.AreEqual (128, hash.HashSize, className + ".HashSize"); + Assert.AreEqual (1, hash.InputBlockSize, className + ".InputBlockSize"); + Assert.AreEqual (1, hash.OutputBlockSize, className + ".OutputBlockSize"); } } diff --git a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/SHA1Test.cs b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/SHA1Test.cs index 0ef2206f50b..358beca8d06 100644 --- a/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/SHA1Test.cs +++ b/mcs/class/Mono.Security.Win32/Test/Mono.Security.Cryptography/SHA1Test.cs @@ -33,9 +33,9 @@ public class SHA1Test { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Assertion.Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Assertion.Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -48,7 +48,7 @@ public class SHA1Test { } msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); - Assertion.Assert (msg, a); + Assert.IsTrue (a, msg); } [SetUp] @@ -63,12 +63,12 @@ public class SHA1Test { { // test all values static for SHA1 string className = hash.ToString (); - Assertion.AssertEquals (className + ".HashSize", 160, hash.HashSize); - Assertion.AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize); - Assertion.AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize); - Assertion.AssertEquals (className + ".CanReuseTransform", true, hash.CanReuseTransform); - Assertion.AssertEquals (className + ".CanTransformMultipleBlocks", true, hash.CanTransformMultipleBlocks); - Assertion.AssertEquals (className + ".ToString()", "Mono.Security.Cryptography.SHA1CryptoServiceProvider", className); + Assert.AreEqual (className + ".HashSize", 160, hash.HashSize); + Assert.AreEqual (className + ".InputBlockSize", 1, hash.InputBlockSize); + Assert.AreEqual (className + ".OutputBlockSize", 1, hash.OutputBlockSize); + Assert.AreEqual (className + ".CanReuseTransform", true, hash.CanReuseTransform); + Assert.AreEqual (className + ".CanTransformMultipleBlocks", true, hash.CanTransformMultipleBlocks); + Assert.AreEqual (className + ".ToString()", "Mono.Security.Cryptography.SHA1CryptoServiceProvider", className); } // First test, we hash the string "abc" diff --git a/mcs/class/Mono.Security/Test/Mono.Math/BigIntegerSetTest.cs b/mcs/class/Mono.Security/Test/Mono.Math/BigIntegerSetTest.cs index 989adb7697a..56cec328adb 100644 --- a/mcs/class/Mono.Security/Test/Mono.Math/BigIntegerSetTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Math/BigIntegerSetTest.cs @@ -22,7 +22,7 @@ namespace MonoTests.Mono.Math { protected void Expect (BigInteger actual, BigInteger expected) { - Assertion.AssertEquals (Name, expected, actual); + Assert.AreEqual (expected, actual, Name); } } } diff --git a/mcs/class/Mono.Security/Test/Mono.Math/PrimeTestingTest.cs b/mcs/class/Mono.Security/Test/Mono.Math/PrimeTestingTest.cs index 4cf969f69d0..2abf162a89c 100644 --- a/mcs/class/Mono.Security/Test/Mono.Math/PrimeTestingTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Math/PrimeTestingTest.cs @@ -81,12 +81,12 @@ namespace MonoTests.Mono.Math { private void ExpectComposite (BigInteger bi) { - Assertion.AssertEquals (false, bi.IsProbablePrime ()); + Assert.AreEqual (false, bi.IsProbablePrime ()); } private void ExpectPrime (BigInteger bi) { - Assertion.AssertEquals (true, bi.IsProbablePrime ()); + Assert.AreEqual (true, bi.IsProbablePrime ()); } } @@ -195,7 +195,7 @@ namespace MonoTests.Mono.Math { // Adapted from http://lists.ximian.com/archives/public/mono-devel-list/2003-November/003026.html // Note: these primes are taken from RFC 2412 [http://www.faqs.org/rfcs/rfc2412.html] [TestFixture] - public class Rfc2412WellTestedPrimes : Assertion { + public class Rfc2412WellTestedPrimes { // E.1. Well-Known Group 1: A 768 bit prime [Test] @@ -203,8 +203,8 @@ namespace MonoTests.Mono.Math { { string prime = "1552518092300708935130918131258481755631334049434514313202351194902966239949102107258669453876591642442910007680288864229150803718918046342632727613031282983744380820890196288509170691316593175367469551763119843371637221007210577919"; BigInteger bi = BigInteger.Parse (prime); - Assert ("isProbablePrime-768", bi.IsProbablePrime ()); - AssertEquals ("ToString()", prime, bi.ToString ()); + Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-768"); + Assert.AreEqual (prime, bi.ToString (), "ToString()"); } // E.2. Well-Known Group 2: A 1024 bit prime @@ -213,8 +213,8 @@ namespace MonoTests.Mono.Math { { string prime = "179769313486231590770839156793787453197860296048756011706444423684197180216158519368947833795864925541502180565485980503646440548199239100050792877003355816639229553136239076508735759914822574862575007425302077447712589550957937778424442426617334727629299387668709205606050270810842907692932019128194467627007"; BigInteger bi = BigInteger.Parse (prime); - Assert ("isProbablePrime-1024", bi.IsProbablePrime ()); - AssertEquals ("ToString()", prime, bi.ToString ()); + Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-1024"); + Assert.AreEqual (prime, bi.ToString (), "ToString()"); } // Note: E.3 and E.4 are for Elliptic Curve Groups @@ -225,8 +225,8 @@ namespace MonoTests.Mono.Math { { string prime = "2410312426921032588552076022197566074856950548502459942654116941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919"; BigInteger bi = BigInteger.Parse (prime); - Assert ("isProbablePrime-1536", bi.IsProbablePrime ()); - AssertEquals ("ToString()", prime, bi.ToString ()); + Assert.IsTrue (bi.IsProbablePrime (), "isProbablePrime-1536"); + Assert.AreEqual (prime, bi.ToString (), "ToString()"); } } diff --git a/mcs/class/Mono.Security/Test/Mono.Math/SearchGeneratorTest.cs b/mcs/class/Mono.Security/Test/Mono.Math/SearchGeneratorTest.cs index 80434f9983c..e77246dc956 100644 --- a/mcs/class/Mono.Security/Test/Mono.Math/SearchGeneratorTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Math/SearchGeneratorTest.cs @@ -34,7 +34,7 @@ namespace MonoTests.Mono.Math { ContextData ctx = (ContextData)Context; - Assertion.AssertEquals (ctx.bits, bits); + Assert.AreEqual (ctx.bits, bits); uint d = ctx.testData; for (uint i = (uint)bits - 2; d > 0; i--, d >>= 1) @@ -65,7 +65,7 @@ namespace MonoTests.Mono.Math { Assert.IsTrue (p.TestBit (1)); uint d = ctx.testData; for (uint j = 128 - 2; d > 0; j--, d >>= 1) - Assertion.AssertEquals ((d&1) == 1, p.TestBit (j)); + Assert.AreEqual ((d&1) == 1, p.TestBit (j)); } } } diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Authenticode/PrivateKeyTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Authenticode/PrivateKeyTest.cs index 0f529496e11..8696657715e 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Authenticode/PrivateKeyTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Authenticode/PrivateKeyTest.cs @@ -68,7 +68,7 @@ namespace MonoTests.Mono.Security.Authenticode { // makecert -n "CN=PVK1" -sv 1.pvk 1.cer [TestFixture] -public class PrivateKeyTest : Assertion { +public class PrivateKeyTest { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -76,9 +76,9 @@ public class PrivateKeyTest : Assertion { 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) { @@ -93,7 +93,7 @@ public class PrivateKeyTest : Assertion { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assert (msg, a); + Assert.IsTrue (a, msg); } string testfile; @@ -152,10 +152,10 @@ public class PrivateKeyTest : Assertion { { WriteBuffer (nopwd); PrivateKey pvk = PrivateKey.CreateFromFile (testfile); - AssertNotNull ("msnopwd.RSA", pvk.RSA); - Assert ("msnopwd.Encrypted", !pvk.Encrypted); - Assert ("msnopwd.Weak", pvk.Weak); - AssertEquals ("msnopwd.KeyType", 2, pvk.KeyType); + Assert.IsNotNull (pvk.RSA, "msnopwd.RSA"); + Assert.IsTrue (!pvk.Encrypted, "msnopwd.Encrypted"); + Assert.IsTrue (pvk.Weak, "msnopwd.Weak"); + Assert.AreEqual (2, pvk.KeyType, "msnopwd.KeyType"); } // this will convert a PVK file without a password to a PVK file @@ -168,11 +168,11 @@ public class PrivateKeyTest : Assertion { string rsa1 = pvk.RSA.ToXmlString (true); pvk.Save (testfile, "password"); pvk = PrivateKey.CreateFromFile (testfile, "password"); - AssertNotNull ("topwd.RSA", pvk.RSA); + Assert.IsNotNull (pvk.RSA, "topwd.RSA"); string rsa2 = pvk.RSA.ToXmlString (true); - AssertEquals ("topwd.RSA identical", rsa1, rsa2); - Assert ("topwd.Encrypted", pvk.Encrypted); - Assert ("topwd.Weak", pvk.Weak); + Assert.AreEqual (rsa1, rsa2, "topwd.RSA identical"); + Assert.IsTrue (pvk.Encrypted, "topwd.Encrypted"); + Assert.IsTrue (pvk.Weak, "topwd.Weak"); } // this will convert a PVK file without a password to a PVK file @@ -186,11 +186,11 @@ public class PrivateKeyTest : Assertion { pvk.Weak = false; // we want strong crypto pvk.Save (testfile, "password"); pvk = PrivateKey.CreateFromFile (testfile, "password"); - AssertNotNull ("topwd.RSA", pvk.RSA); + Assert.IsNotNull (pvk.RSA, "topwd.RSA"); string rsa2 = pvk.RSA.ToXmlString (true); - AssertEquals ("topwd.RSA identical", rsa1, rsa2); - Assert ("topwd.Encrypted", pvk.Encrypted); - Assert ("topwd.Weak", !pvk.Weak); + Assert.AreEqual (rsa1, rsa2, "topwd.RSA identical"); + Assert.IsTrue (pvk.Encrypted, "topwd.Encrypted"); + Assert.IsTrue (!pvk.Weak, "topwd.Weak"); } static byte[] pwd = { @@ -229,9 +229,9 @@ public class PrivateKeyTest : Assertion { { WriteBuffer (pwd); PrivateKey pvk = PrivateKey.CreateFromFile (testfile, "password"); - AssertNotNull ("mspwd.RSA", pvk.RSA); - Assert ("mspwd.Encrypted", pvk.Encrypted); - Assert ("mspwd.Weak", pvk.Weak); + Assert.IsNotNull (pvk.RSA, "mspwd.RSA"); + Assert.IsTrue (pvk.Encrypted, "mspwd.Encrypted"); + Assert.IsTrue (pvk.Weak, "mspwd.Weak"); } // this will convert a PVK file with a password to a PVK file @@ -244,11 +244,11 @@ public class PrivateKeyTest : Assertion { string rsa1 = pvk.RSA.ToXmlString (true); pvk.Save (testfile); pvk = PrivateKey.CreateFromFile (testfile); - AssertNotNull ("nomorepwd.RSA", pvk.RSA); + Assert.IsNotNull (pvk.RSA, "nomorepwd.RSA"); string rsa2 = pvk.RSA.ToXmlString (true); - AssertEquals ("nomorepwd.RSA identical", rsa1, rsa2); - Assert ("nomorepwd.Encrypted", !pvk.Encrypted); - Assert ("nomorepwd.Weak", pvk.Weak); + Assert.AreEqual (rsa1, rsa2, "nomorepwd.RSA identical"); + Assert.IsTrue (!pvk.Encrypted, "nomorepwd.Encrypted"); + Assert.IsTrue (pvk.Weak, "nomorepwd.Weak"); } [Test] @@ -261,11 +261,11 @@ public class PrivateKeyTest : Assertion { pvk.Save (testfile, "mono"); pvk = PrivateKey.CreateFromFile (testfile, "mono"); - AssertNotNull ("new.RSA", pvk.RSA); + Assert.IsNotNull (pvk.RSA, "new.RSA"); string rsa2 = pvk.RSA.ToXmlString (true); - AssertEquals ("new.RSA identical", rsa1, rsa2); - Assert ("new.Encrypted", pvk.Encrypted); - Assert ("new.Weak", !pvk.Weak); + Assert.AreEqual (rsa1, rsa2, "new.RSA identical"); + Assert.IsTrue (pvk.Encrypted, "new.Encrypted"); + Assert.IsTrue (!pvk.Weak, "new.Weak"); } [Test] diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs index 38ecbc3b235..a527208839a 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/CryptoConvertTest.cs @@ -15,7 +15,7 @@ using Mono.Security.Cryptography; namespace MonoTests.Mono.Security.Cryptography { [TestFixture] - public class CryptoConvertTest : Assertion { + public class CryptoConvertTest { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -23,9 +23,9 @@ namespace MonoTests.Mono.Security.Cryptography { 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.Mono.Security.Cryptography { } msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); - Assert (msg, a); + Assert.IsTrue (a, msg); } // strongname generated using "sn -k unit.snk" @@ -163,16 +163,16 @@ namespace MonoTests.Mono.Security.Cryptography { { // keypair RSA rsa = CryptoConvert.FromCapiKeyBlob (strongName, 0); - AssertEquals ("KeyPair", strongNameString, rsa.ToXmlString (true)); - AssertEquals ("PublicKey-1", strongNamePublicKeyString, rsa.ToXmlString (false)); + Assert.AreEqual (strongNameString, rsa.ToXmlString (true), "KeyPair"); + Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-1"); // public key (direct) rsa = CryptoConvert.FromCapiKeyBlob (strongNamePublicKey, 12); - AssertEquals ("PublicKey-2", strongNamePublicKeyString, rsa.ToXmlString (false)); + Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-2"); // public key (indirect - inside header) rsa = CryptoConvert.FromCapiKeyBlob (strongNamePublicKey, 0); - AssertEquals ("PublicKey-3", strongNamePublicKeyString, rsa.ToXmlString (false)); + Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey-3"); } [Test] @@ -201,7 +201,7 @@ namespace MonoTests.Mono.Security.Cryptography { public void FromCapiPrivateKeyBlob () { RSA rsa = CryptoConvert.FromCapiPrivateKeyBlob (strongName, 0); - AssertEquals ("KeyPair", strongNameString, rsa.ToXmlString (true)); + Assert.AreEqual (strongNameString, rsa.ToXmlString (true), "KeyPair"); } [Test] @@ -229,7 +229,7 @@ namespace MonoTests.Mono.Security.Cryptography { public void FromCapiPublicKeyBlob () { RSA rsa = CryptoConvert.FromCapiPublicKeyBlob (strongNamePublicKey, 12); - AssertEquals ("PublicKey", strongNamePublicKeyString, rsa.ToXmlString (false)); + Assert.AreEqual (strongNamePublicKeyString, rsa.ToXmlString (false), "PublicKey"); } [Test] @@ -262,12 +262,12 @@ namespace MonoTests.Mono.Security.Cryptography { AssertEquals ("RSA-KeyPair", strongName, keypair); byte[] publicKey = CryptoConvert.ToCapiKeyBlob (rsa, false); - AssertEquals ("RSA-PublicKey", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey)); + Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "RSA-PublicKey"); AsymmetricAlgorithm dsa = DSA.Create (); dsa.FromXmlString (dsaKeyPairString); AssertEquals ("DSA-KeyPair", dsaPrivBlob, CryptoConvert.ToCapiKeyBlob (dsa, true)); - AssertEquals ("DSA-PublicKey", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (CryptoConvert.ToCapiKeyBlob (dsa, false))); + Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (CryptoConvert.ToCapiKeyBlob (dsa, false)), "DSA-PublicKey"); } [Test] @@ -279,7 +279,7 @@ namespace MonoTests.Mono.Security.Cryptography { AssertEquals ("KeyPair", strongName, keypair); byte[] publicKey = CryptoConvert.ToCapiKeyBlob (rsa, false); - AssertEquals ("PublicKey", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey)); + Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey"); } [Test] @@ -323,11 +323,11 @@ namespace MonoTests.Mono.Security.Cryptography { // full keypair rsa.FromXmlString (strongNameString); byte[] publicKey = CryptoConvert.ToCapiPublicKeyBlob (rsa); - AssertEquals ("PublicKey-1", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey)); + Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey-1"); // public key only rsa.FromXmlString (strongNamePublicKeyString); publicKey = CryptoConvert.ToCapiPublicKeyBlob (rsa); - AssertEquals ("PublicKey-2", BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey)); + Assert.AreEqual (BitConverter.ToString (strongNamePublicKey, 12), BitConverter.ToString (publicKey), "PublicKey-2"); } /* DSA key tests */ @@ -419,8 +419,8 @@ namespace MonoTests.Mono.Security.Cryptography { public void FromCapiKeyBlobDSA () { DSA dsa = CryptoConvert.FromCapiKeyBlobDSA (dsaPrivBlob); - AssertEquals ("KeyPair", dsaKeyPairString, dsa.ToXmlString (true)); - AssertEquals ("PublicKey", dsaPubKeyString, dsa.ToXmlString (false)); + Assert.AreEqual (dsaKeyPairString, dsa.ToXmlString (true), "KeyPair"); + Assert.AreEqual (dsaPubKeyString, dsa.ToXmlString (false), "PublicKey"); } [Test] @@ -449,7 +449,7 @@ namespace MonoTests.Mono.Security.Cryptography { public void FromCapiPrivateKeyBlobDSA () { DSA dsa = CryptoConvert.FromCapiPrivateKeyBlobDSA (dsaPrivBlob, 0); - AssertEquals ("KeyPair", dsaKeyPairString, dsa.ToXmlString (true)); + Assert.AreEqual (dsaKeyPairString, dsa.ToXmlString (true), "KeyPair"); } [Test] @@ -478,7 +478,7 @@ namespace MonoTests.Mono.Security.Cryptography { public void FromCapiPublicKeyBlobDSA () { DSA dsa = CryptoConvert.FromCapiPublicKeyBlobDSA (dsaPubBlob, 0); - AssertEquals ("PublicKey", dsaPubKeyString, dsa.ToXmlString (false)); + Assert.AreEqual (dsaPubKeyString, dsa.ToXmlString (false), "PublicKey"); } [Test] @@ -512,7 +512,7 @@ namespace MonoTests.Mono.Security.Cryptography { AssertEquals ("KeyPair", dsaPrivBlob, keypair); byte[] pubkey = CryptoConvert.ToCapiKeyBlob (dsa, false); - AssertEquals ("PublicKey", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey)); + Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey"); } [Test] @@ -548,20 +548,20 @@ namespace MonoTests.Mono.Security.Cryptography { // full keypair dsa.FromXmlString (dsaKeyPairString); byte[] pubkey = CryptoConvert.ToCapiPublicKeyBlob (dsa); - AssertEquals ("PublicKey-1", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey)); + Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey-1"); // public key only dsa.FromXmlString (dsaPubKeyString); pubkey = CryptoConvert.ToCapiPublicKeyBlob (dsa); - AssertEquals ("PublicKey-2", BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey)); + Assert.AreEqual (BitConverter.ToString (dsaPubBlob), BitConverter.ToString (pubkey), "PublicKey-2"); } [Test] public void FromHex () { - AssertNull ("FromHex(null)", CryptoConvert.FromHex (null)); + Assert.IsNull (CryptoConvert.FromHex (null), "FromHex(null)"); string result = BitConverter.ToString (CryptoConvert.FromHex ("0123456789aBcDeF")); - AssertEquals ("0123456789abcdef", "01-23-45-67-89-AB-CD-EF", result); + Assert.AreEqual ("01-23-45-67-89-AB-CD-EF", result, "0123456789abcdef"); } [Test] @@ -581,9 +581,9 @@ namespace MonoTests.Mono.Security.Cryptography { [Test] public void ToHex () { - AssertNull ("FromHex(null)", CryptoConvert.FromHex (null)); + Assert.IsNull (CryptoConvert.FromHex (null), "FromHex(null)"); byte[] data = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; - AssertEquals ("0123456789abcdef", "0123456789ABCDEF", CryptoConvert.ToHex (data)); + Assert.AreEqual ("0123456789ABCDEF", CryptoConvert.ToHex (data), "0123456789abcdef"); } [Test] @@ -595,8 +595,8 @@ namespace MonoTests.Mono.Security.Cryptography { RSA rsa = CryptoConvert.FromCapiKeyBlob (strongNameNUnit, 0); // note the bad D parameters !!! // this only works because CRT is being used - AssertEquals ("KeyPair", "<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent><P>2d4pGForvc792ztFxhNuzxIihDnXp+qK9F8t/NduhRBdu+JXK4d8a9EGwzpMxLUPlHjCZfXRraZiSQszkH+nzQ==</P><Q>yj9BeGmOrucOUCNZYTtXI0ykzz+1g+cVMSxi+6xzoLEOqmdE4gjcWaxak4MF1+pIR6UycnNa/jg1LBl7MKxpCw==</Q><DP>cMkAjznG4Sjx4/dIRKU0vP/PXJIxIR1bN+y5+uVvsnTpgWVH6SHneE0qahCZQ0/UM/Fb+bqLBJFY2iVxWUGslQ==</DP><DQ>gz6TXPGbLzMv3Z9i5C8e+ABHv1pHj6ZI4VU9kraxfmkH7FsBn3FClUq8qJdRFnGpoBy65Pyo4upUzx5mDAsGSw==</DQ><InverseQ>x+UShV+0d9cicoiB9fkSLqpLDyF4dYzVu0uqX0eCcoGJpk19jtSaMI3Eo8VN6MJAW1zrRy+MA1Fqb9qeThLqZQ==</InverseQ><D>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</D></RSAKeyValue>", rsa.ToXmlString (true)); - AssertEquals ("PublicKey", "<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", rsa.ToXmlString (false)); + Assert.AreEqual ("<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent><P>2d4pGForvc792ztFxhNuzxIihDnXp+qK9F8t/NduhRBdu+JXK4d8a9EGwzpMxLUPlHjCZfXRraZiSQszkH+nzQ==</P><Q>yj9BeGmOrucOUCNZYTtXI0ykzz+1g+cVMSxi+6xzoLEOqmdE4gjcWaxak4MF1+pIR6UycnNa/jg1LBl7MKxpCw==</Q><DP>cMkAjznG4Sjx4/dIRKU0vP/PXJIxIR1bN+y5+uVvsnTpgWVH6SHneE0qahCZQ0/UM/Fb+bqLBJFY2iVxWUGslQ==</DP><DQ>gz6TXPGbLzMv3Z9i5C8e+ABHv1pHj6ZI4VU9kraxfmkH7FsBn3FClUq8qJdRFnGpoBy65Pyo4upUzx5mDAsGSw==</DQ><InverseQ>x+UShV+0d9cicoiB9fkSLqpLDyF4dYzVu0uqX0eCcoGJpk19jtSaMI3Eo8VN6MJAW1zrRy+MA1Fqb9qeThLqZQ==</InverseQ><D>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</D></RSAKeyValue>", rsa.ToXmlString (true), "KeyPair"); + Assert.AreEqual ("<RSAKeyValue><Modulus>rB8h0TaMs8fWA+5WMdcjOjejCZwhYwuFHUZPS0cC9TOG6FJtvlHPpZLQAg0xfLr2SivPRol1Xw9SqhuaYQNJA7sAaOb8Rvgmx93XbmcNotY9ob4TGaesk+M8VsdexsIJ3WlyLbmRlf0EjT52nboyauEL3UC85zkMjW1LNb8LSs8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", rsa.ToXmlString (false), "PublicKey"); } } } diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/DiffieHellmanManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/DiffieHellmanManagedTest.cs index 2a38eb819dc..a0d3caf1f7d 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/DiffieHellmanManagedTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/DiffieHellmanManagedTest.cs @@ -24,7 +24,7 @@ namespace MonoTests.Mono.Security.Cryptography { // http://www.ietf.org/rfc/rfc2631.txt [TestFixture] - public class DiffieHellmanManagedTest : Assertion { + public class DiffieHellmanManagedTest { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -32,9 +32,9 @@ namespace MonoTests.Mono.Security.Cryptography { if ((array1 == null) && (array2 == null)) return; if (array1 == null) - Assertion.Fail (msg + " -> First array is NULL"); + Assert.Fail (msg + " -> First array is NULL"); if (array2 == null) - Assertion.Fail (msg + " -> Second array is NULL"); + Assert.Fail (msg + " -> Second array is NULL"); bool a = (array1.Length == array2.Length); if (a) { @@ -49,7 +49,7 @@ namespace MonoTests.Mono.Security.Cryptography { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assertion.Assert (msg, a); + Assert.IsTrue (a, msg); } [Test] @@ -70,7 +70,7 @@ namespace MonoTests.Mono.Security.Cryptography { // let the second DH instance compute the shared secret using the first DH public key byte[] dh2k = dh2.DecryptKeyExchange (ke1); // both shared secrets are the same - AssertEquals ("Shared Secret", dh1k, dh2k); + Assert.AreEqual (dh1k, dh2k, "Shared Secret"); } // TODO: More is needed ! diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs index 42f7584e1c9..8ec9779b2db 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/PKCS8Test.cs @@ -19,7 +19,7 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Cryptography { [TestFixture] - public class PKCS8Test : Assertion { + public class PKCS8Test { static public byte[] pkcs8_der = { 0x30, 0x82, 0x02, 0xB2, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30, 0x0E, 0x04, 0x08, 0x86, 0x2A, 0xA9, 0x71, 0x6D, 0xA4, 0xB8, 0x2D, 0x02, 0x02, 0x07, 0xD0, 0x04, 0x82, 0x02, 0x90, 0x90, 0x14, 0xB5, 0xF0, 0xB6, 0x86, 0x56, 0xCB, 0xFA, 0x63, 0xAD, 0x9F, 0x5A, 0x59, 0x6C, 0xAD, 0x00, 0x3C, 0x37, 0x8A, 0xC3, 0x88, 0x58, 0x8B, 0xD7, 0x48, 0x53, 0x7A, 0xC8, 0x5B, 0x0D, 0x98, 0xDD, 0x8B, 0xB3, 0xEC, 0x4C, 0xAC, 0x61, 0x18, 0xE3, 0x5E, 0x47, 0xAD, 0xC7, 0x92, 0xBC, 0xD3, 0x00, 0x07, 0xFF, 0x1A, 0x68, 0x74, 0x45, 0x8E, 0xD8, 0x7C, 0x9F, 0x18, 0x7B, 0xD7, 0xC8, 0x47, 0xBA, 0x6B, 0x19, 0xF2, 0xBF, 0x7E, 0x51, 0x0B, 0x4B, 0x43, 0xE8, 0xB9, 0x56, 0x7E, 0xD0, 0x74, 0xC7, 0xDE, 0x76, 0xDB, 0xFF, 0x5C, 0x6B, 0x53, 0xBE, 0x31, 0x06, 0xAE, 0x6C, 0x8F, 0xDC, 0x49, 0x04, 0x71, 0x74, 0xEE, 0xB8, 0x06, 0xCB, 0xAD, 0x86, 0xB4, 0x4E, 0xB9, 0x46, 0xA1, 0x03, 0x5E, 0x0E, 0xA7, 0xC7, 0x37, 0x6B, 0xB0, 0x8D, 0x2D, 0x81, 0x1F, 0xE3, 0xC2, 0x05, 0xDE, 0xEF, 0x51, 0x07, 0x70, 0x6E, 0x35, 0x9A, 0xAD, 0x19, 0x5E, 0xAF, 0xEB, 0x7F, 0xEF, 0xE4, 0xAB, 0x07, 0xF3, 0xF6, 0xEA, 0xFA, 0x0E, 0x83, 0x65, 0x06, 0x3C, 0xF3, 0xBD, 0x96, 0x08, 0x14, 0xC5, 0x34, 0x26, 0xED, 0xC0, 0x10, @@ -32,13 +32,13 @@ namespace MonoTests.Mono.Security.Cryptography { [Test] public void EncryptedPrivateKey_Farscape () { - AssertEquals ("PKCS8.GetType", PKCS8.KeyInfo.EncryptedPrivateKey, PKCS8.GetType (pkcs8_der)); + Assert.AreEqual (PKCS8.KeyInfo.EncryptedPrivateKey, PKCS8.GetType (pkcs8_der), "PKCS8.GetType"); PKCS8.EncryptedPrivateKeyInfo p8 = new PKCS8.EncryptedPrivateKeyInfo (pkcs8_der); - AssertEquals ("Algorithm", "1.2.840.113549.1.12.1.3", p8.Algorithm); - AssertEquals ("EncryptedData", "90-14-B5-F0-B6-86-56-CB-FA-63-AD-9F-5A-59-6C-AD-00-3C-37-8A-C3-88-58-8B-D7-48-53-7A-C8-5B-0D-98-DD-8B-B3-EC-4C-AC-61-18-E3-5E-47-AD-C7-92-BC-D3-00-07-FF-1A-68-74-45-8E-D8-7C-9F-18-7B-D7-C8-47-BA-6B-19-F2-BF-7E-51-0B-4B-43-E8-B9-56-7E-D0-74-C7-DE-76-DB-FF-5C-6B-53-BE-31-06-AE-6C-8F-DC-49-04-71-74-EE-B8-06-CB-AD-86-B4-4E-B9-46-A1-03-5E-0E-A7-C7-37-6B-B0-8D-2D-81-1F-E3-C2-05-DE-EF-51-07-70-6E-35-9A-AD-19-5E-AF-EB-7F-EF-E4-AB-07-F3-F6-EA-FA-0E-83-65-06-3C-F3-BD-96-08-14-C5-34-26-ED-C0-10-CC-AE-2D-8F-BE-ED-98-0D-88-1B-1E-C7-37-F0-FC-DB-3C-E3-1B-66-52-45-6E-05-A6-D9-12-23-05-5F-E3-9F-7D-21-9B-2E-3E-9E-3C-EE-D1-9B-55-DE-57-60-A5-24-2D-C7-94-EC-FC-B1-6A-65-BD-85-02-5C-58-AA-5A-6A-F3-AC-6B-DD-0E-63-B2-4B-5B-67-3D-C3-BF-E4-C8-EF-3F-89-5A-CD-6D-EF-05-22-2B-72-FF-80-7A-DD-F1-59-A7-6F-00-B1-BD-4D-88-D6-E4-8A-DD-A9-FC-D9-01-0A-65-8E-52-F9-7E-20-72-67-0D-5B-EE-67-5B-46-4A-15-A2-6F-15-2B-5B-9A-93-12-4F-F4-AD-49-D0-11-F1-7E-40-DE-32-96-2E-B3-E8-71-60-27-6E-A2-71-83-C7-FE-0E-8B-31-06-64-E1-19-02-B9-44-25-0C-94-64-7E-5F-89-4D-7E-99-0B-91-B8-22-A5-33-92-D3-49-07-1D-C6-25-4A-D7-6D-E2-94-3F-FA-10-72-59-62-F5-C6-D4-3A-EE-8F-BC-9C-BC-FC-C7-37-BF-7C-A0-67-B0-FF-0F-29-A0-A2-71-6B-21-00-F4-54-D9-3D-1B-CE-F4-FE-6F-F5-21-CB-47-58-17-F6-45-2F-A0-3B-8B-D9-B8-8A-33-3F-16-E0-C7-8A-B8-11-2F-A8-7E-7D-A7-7B-65-27-89-3C-67-4D-D5-70-28-76-60-96-68-BF-FB-CD-49-E0-8A-7C-6F-76-06-48-6D-63-67-8A-47-82-5E-7F-0E-AC-46-B6-BC-0A-6D-E2-1A-3A-20-A5-C7-81-71-6E-2B-16-97-D4-FA-C0-DD-72-5B-9F-A3-43-F4-85-B1-C6-A8-E0-62-81-5D-A5-07-29-6A-6A-2D-E1-1D-BE-12-6D-42-58-6F-4E-30-3D-BF-32-11-38-BC-36-76-60-FC-57-2F-D3-9E-C4-1A-92-EA-DE-85-FD-E7-AA-30-A6-97-2C-36-3B-3B-0E-92-52-FF-42-D7-62-6C-C1-3A-E7-1B-4E-13-8C-95-B3-4B-A7-9E-42-75-A8-CA-63-76-C4-45-74-96-43-D8-86-82-BE-37-FF-9B-EB-B7-18-A1-2F-E3-6C-08-E8-11-96-8C-5E-9E-2B-E7-DB-7D-54-E1-DB-1E-D3-8F-B5-19-4B-B2-16-DB-CF-EC-88-0B-6C-3C-E4-F2-C4-FF-4D-3E-53-52-3A-81-0B-6E-AC-95-EA-5A-6E-4D-83-23-82-C9-90-02-74-10-2A-6C-FB-97-4F-5F-70-8E-F0-B9", - BitConverter.ToString (p8.EncryptedData)); - AssertEquals ("Salt", "86-2A-A9-71-6D-A4-B8-2D", BitConverter.ToString (p8.Salt)); - AssertEquals ("IterationCount", 2000, p8.IterationCount); + Assert.AreEqual ("1.2.840.113549.1.12.1.3", p8.Algorithm, "Algorithm"); + Assert.AreEqual ("90-14-B5-F0-B6-86-56-CB-FA-63-AD-9F-5A-59-6C-AD-00-3C-37-8A-C3-88-58-8B-D7-48-53-7A-C8-5B-0D-98-DD-8B-B3-EC-4C-AC-61-18-E3-5E-47-AD-C7-92-BC-D3-00-07-FF-1A-68-74-45-8E-D8-7C-9F-18-7B-D7-C8-47-BA-6B-19-F2-BF-7E-51-0B-4B-43-E8-B9-56-7E-D0-74-C7-DE-76-DB-FF-5C-6B-53-BE-31-06-AE-6C-8F-DC-49-04-71-74-EE-B8-06-CB-AD-86-B4-4E-B9-46-A1-03-5E-0E-A7-C7-37-6B-B0-8D-2D-81-1F-E3-C2-05-DE-EF-51-07-70-6E-35-9A-AD-19-5E-AF-EB-7F-EF-E4-AB-07-F3-F6-EA-FA-0E-83-65-06-3C-F3-BD-96-08-14-C5-34-26-ED-C0-10-CC-AE-2D-8F-BE-ED-98-0D-88-1B-1E-C7-37-F0-FC-DB-3C-E3-1B-66-52-45-6E-05-A6-D9-12-23-05-5F-E3-9F-7D-21-9B-2E-3E-9E-3C-EE-D1-9B-55-DE-57-60-A5-24-2D-C7-94-EC-FC-B1-6A-65-BD-85-02-5C-58-AA-5A-6A-F3-AC-6B-DD-0E-63-B2-4B-5B-67-3D-C3-BF-E4-C8-EF-3F-89-5A-CD-6D-EF-05-22-2B-72-FF-80-7A-DD-F1-59-A7-6F-00-B1-BD-4D-88-D6-E4-8A-DD-A9-FC-D9-01-0A-65-8E-52-F9-7E-20-72-67-0D-5B-EE-67-5B-46-4A-15-A2-6F-15-2B-5B-9A-93-12-4F-F4-AD-49-D0-11-F1-7E-40-DE-32-96-2E-B3-E8-71-60-27-6E-A2-71-83-C7-FE-0E-8B-31-06-64-E1-19-02-B9-44-25-0C-94-64-7E-5F-89-4D-7E-99-0B-91-B8-22-A5-33-92-D3-49-07-1D-C6-25-4A-D7-6D-E2-94-3F-FA-10-72-59-62-F5-C6-D4-3A-EE-8F-BC-9C-BC-FC-C7-37-BF-7C-A0-67-B0-FF-0F-29-A0-A2-71-6B-21-00-F4-54-D9-3D-1B-CE-F4-FE-6F-F5-21-CB-47-58-17-F6-45-2F-A0-3B-8B-D9-B8-8A-33-3F-16-E0-C7-8A-B8-11-2F-A8-7E-7D-A7-7B-65-27-89-3C-67-4D-D5-70-28-76-60-96-68-BF-FB-CD-49-E0-8A-7C-6F-76-06-48-6D-63-67-8A-47-82-5E-7F-0E-AC-46-B6-BC-0A-6D-E2-1A-3A-20-A5-C7-81-71-6E-2B-16-97-D4-FA-C0-DD-72-5B-9F-A3-43-F4-85-B1-C6-A8-E0-62-81-5D-A5-07-29-6A-6A-2D-E1-1D-BE-12-6D-42-58-6F-4E-30-3D-BF-32-11-38-BC-36-76-60-FC-57-2F-D3-9E-C4-1A-92-EA-DE-85-FD-E7-AA-30-A6-97-2C-36-3B-3B-0E-92-52-FF-42-D7-62-6C-C1-3A-E7-1B-4E-13-8C-95-B3-4B-A7-9E-42-75-A8-CA-63-76-C4-45-74-96-43-D8-86-82-BE-37-FF-9B-EB-B7-18-A1-2F-E3-6C-08-E8-11-96-8C-5E-9E-2B-E7-DB-7D-54-E1-DB-1E-D3-8F-B5-19-4B-B2-16-DB-CF-EC-88-0B-6C-3C-E4-F2-C4-FF-4D-3E-53-52-3A-81-0B-6E-AC-95-EA-5A-6E-4D-83-23-82-C9-90-02-74-10-2A-6C-FB-97-4F-5F-70-8E-F0-B9", BitConverter.ToString (p8.EncryptedData), + "EncryptedData"); + Assert.AreEqual ("86-2A-A9-71-6D-A4-B8-2D", BitConverter.ToString (p8.Salt), "Salt"); + Assert.AreEqual (2000, p8.IterationCount, "IterationCount"); } static public byte[] End_Certificate_CP_01_01_crtx = { 0x30, 0x82, 0x02, 0x78, 0x02, 0x01, 0x00, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, 0x02, 0x62, 0x30, 0x82, 0x02, 0x5E, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xC6, 0x34, 0xEC, 0x6F, 0x0C, 0xE0, 0x59, 0x0E, 0xBC, 0x5F, 0xBA, 0x2E, 0x93, 0xBB, 0x04, 0xA7, 0x03, 0xB9, 0x70, 0x8A, 0xB9, 0xD7, 0xE5, 0xD7, 0xE6, 0xCA, 0x4A, 0x8C, 0x23, 0xD8, 0x60, 0xB3, 0x6B, 0xCB, 0x88, 0x88, 0xC7, 0xD8, 0x48, 0x7E, 0x64, 0xF9, 0xF6, 0x1B, 0xE3, 0x79, 0x46, 0x41, 0xE4, 0x61, 0xF7, 0x25, 0x47, 0x71, 0xF3, 0x50, 0x94, 0x4E, 0xF2, 0x7C, 0x6A, 0x37, 0xB6, 0x0C, @@ -68,25 +68,25 @@ namespace MonoTests.Mono.Security.Cryptography { [Test] public void PrivateKeyInfo_End_Certificate_CP_01_01 () { - AssertEquals ("PKCS8.GetType", PKCS8.KeyInfo.PrivateKey, PKCS8.GetType (End_Certificate_CP_01_01_crtx)); + Assert.AreEqual (PKCS8.KeyInfo.PrivateKey, PKCS8.GetType (End_Certificate_CP_01_01_crtx), "PKCS8.GetType"); PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_01_crtx); - AssertEquals ("Algorithm", "1.2.840.113549.1.1.1", p8.Algorithm); - AssertEquals ("Attributes", 0, p8.Attributes.Count); - AssertEquals ("PrivateKey", BitConverter.ToString (End_Certificate_CP_01_01_pki), BitConverter.ToString (p8.PrivateKey)); - AssertEquals ("Version", 0, p8.Version); + Assert.AreEqual ("1.2.840.113549.1.1.1", p8.Algorithm, "Algorithm"); + Assert.AreEqual (0, p8.Attributes.Count, "Attributes"); + Assert.AreEqual (BitConverter.ToString (End_Certificate_CP_01_01_pki), BitConverter.ToString (p8.PrivateKey), "PrivateKey"); + Assert.AreEqual (0, p8.Version, "Version"); } [Test] public void PrivateKeyInfo_End_Certificate_CP_01_02 () { PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (End_Certificate_CP_01_02_crtx); - AssertEquals ("Algorithm", "1.2.840.113549.1.1.1", p8.Algorithm); - AssertEquals ("Attributes", 0, p8.Attributes.Count); - AssertEquals ("PrivateKey", "30-82-02-5B-02-01-00-02-81-81-00-D6-39-9E-21-93-E2-BA-35-7F-E5-F8-E8-87-0B-8A-5F-28-25-85-B7-E5-CC-DA-7F-D3-C7-09-2A-63-E9-AD-8F-D0-A8-EF-BA-CF-3C-FB-55-03-B9-83-29-4E-0E-89-84-FB-E2-62-16-1F-9D-87-40-16-6B-F8-F4-66-38-58-74-67-D4-B5-A1-3A-4B-6F-13-4B-08-37-3A-3A-64-0A-06-8E-A2-7B-14-88-B7-F8-CE-6A-D1-45-9B-39-93-67-BF-0A-AB-DB-37-9D-FA-CE-54-0F-37-82-09-8F-0D-33-E4-B8-6E-46-C1-CC-4F-80-5A-B4-BD-19-80-27-40-84-49-02-03-01-00-01-02-81-80-14-95-5A-AD-4D-41-56-B4-F7-42-08-85-87-1C-43-C2-5A-E0-28-16-00-5D-8B-8D-06-B3-34-1D-3F-96-5F-57-D7-2B-B4-45-15-CE-7D-33-B0-F4-ED-36-55-CA-AD-C9-FA-4D-C9-30-E8-FE-C0-D5-16-92-6F-4C-44-5A-1B-9D-7E-AE-B8-01-6D-38-9D-DC-93-68-AB-93-D6-C0-8A-8A-63-B4-D6-DA-21-C1-A0-28-8C-24-C4-27-E1-4B-30-D2-2D-87-62-F9-17-75-21-5E-E1-3C-E2-2D-92-03-C6-A1-8D-1D-E9-67-F4-CE-FF-AC-52-86-D2-F5-0F-EB-03-01-02-41-00-ED-6A-AE-A7-33-B0-B8-86-36-91-BA-E7-D2-DD-15-3A-97-A2-66-31-98-24-A6-0D-E7-09-E3-BD-36-79-91-F2-5E-23-AA-21-C9-71-43-24-10-FA-F0-E6-FC-E4-C6-1F-08-45-E8-91-74-13-69-63-A5-40-8F-38-44-2B-54-69-02-41-00-E6-FE-39-8B-6F-DB-44-CA-E7-72-D3-CA-09-5B-3D-B1-53-85-29-36-FC-F1-B9-D8-1F-64-02-D4-F7-F5-71-E5-9F-17-D7-F3-9F-5A-3A-A6-A3-62-46-F6-93-3D-D3-CD-18-F2-12-BD-68-02-AA-91-55-DA-64-26-D7-16-34-E1-02-40-60-3F-F4-C8-72-4B-3D-B3-A3-A1-D6-FD-2E-DE-54-41-E9-C1-7B-DE-B5-48-7E-4D-7A-91-E6-D3-09-A7-A5-84-75-A7-CD-CC-5E-C7-5D-29-DC-FC-6E-F7-A6-24-F5-31-15-80-89-F5-95-F2-5C-B2-7A-07-3F-48-D7-52-1D-A9-02-40-40-1B-FC-C2-9B-57-E2-DE-E1-9F-B7-F2-11-E8-B5-D5-9A-55-91-DB-C6-16-1C-BB-43-F3-10-EA-24-AB-85-61-F2-66-BE-B3-C9-DD-53-FB-DD-CA-AF-E1-4D-7A-52-67-50-EE-16-8F-64-E7-A0-89-57-A7-96-36-45-69-CF-61-02-40-3D-9E-E3-29-D6-BD-59-FF-A5-C3-AC-57-CB-74-FE-B0-C3-67-34-A8-40-EB-04-88-C3-C2-74-4F-69-77-13-48-8A-97-3C-C2-4B-CD-E8-E0-97-98-A2-3F-B6-E2-71-D3-65-9F-5A-C6-C8-AE-FE-BA-B1-ED-DA-08-8A-5B-7B-12", BitConverter.ToString (p8.PrivateKey)); - AssertEquals ("Version", 0, p8.Version); + Assert.AreEqual ("1.2.840.113549.1.1.1", p8.Algorithm, "Algorithm"); + Assert.AreEqual (0, p8.Attributes.Count, "Attributes"); + Assert.AreEqual ("30-82-02-5B-02-01-00-02-81-81-00-D6-39-9E-21-93-E2-BA-35-7F-E5-F8-E8-87-0B-8A-5F-28-25-85-B7-E5-CC-DA-7F-D3-C7-09-2A-63-E9-AD-8F-D0-A8-EF-BA-CF-3C-FB-55-03-B9-83-29-4E-0E-89-84-FB-E2-62-16-1F-9D-87-40-16-6B-F8-F4-66-38-58-74-67-D4-B5-A1-3A-4B-6F-13-4B-08-37-3A-3A-64-0A-06-8E-A2-7B-14-88-B7-F8-CE-6A-D1-45-9B-39-93-67-BF-0A-AB-DB-37-9D-FA-CE-54-0F-37-82-09-8F-0D-33-E4-B8-6E-46-C1-CC-4F-80-5A-B4-BD-19-80-27-40-84-49-02-03-01-00-01-02-81-80-14-95-5A-AD-4D-41-56-B4-F7-42-08-85-87-1C-43-C2-5A-E0-28-16-00-5D-8B-8D-06-B3-34-1D-3F-96-5F-57-D7-2B-B4-45-15-CE-7D-33-B0-F4-ED-36-55-CA-AD-C9-FA-4D-C9-30-E8-FE-C0-D5-16-92-6F-4C-44-5A-1B-9D-7E-AE-B8-01-6D-38-9D-DC-93-68-AB-93-D6-C0-8A-8A-63-B4-D6-DA-21-C1-A0-28-8C-24-C4-27-E1-4B-30-D2-2D-87-62-F9-17-75-21-5E-E1-3C-E2-2D-92-03-C6-A1-8D-1D-E9-67-F4-CE-FF-AC-52-86-D2-F5-0F-EB-03-01-02-41-00-ED-6A-AE-A7-33-B0-B8-86-36-91-BA-E7-D2-DD-15-3A-97-A2-66-31-98-24-A6-0D-E7-09-E3-BD-36-79-91-F2-5E-23-AA-21-C9-71-43-24-10-FA-F0-E6-FC-E4-C6-1F-08-45-E8-91-74-13-69-63-A5-40-8F-38-44-2B-54-69-02-41-00-E6-FE-39-8B-6F-DB-44-CA-E7-72-D3-CA-09-5B-3D-B1-53-85-29-36-FC-F1-B9-D8-1F-64-02-D4-F7-F5-71-E5-9F-17-D7-F3-9F-5A-3A-A6-A3-62-46-F6-93-3D-D3-CD-18-F2-12-BD-68-02-AA-91-55-DA-64-26-D7-16-34-E1-02-40-60-3F-F4-C8-72-4B-3D-B3-A3-A1-D6-FD-2E-DE-54-41-E9-C1-7B-DE-B5-48-7E-4D-7A-91-E6-D3-09-A7-A5-84-75-A7-CD-CC-5E-C7-5D-29-DC-FC-6E-F7-A6-24-F5-31-15-80-89-F5-95-F2-5C-B2-7A-07-3F-48-D7-52-1D-A9-02-40-40-1B-FC-C2-9B-57-E2-DE-E1-9F-B7-F2-11-E8-B5-D5-9A-55-91-DB-C6-16-1C-BB-43-F3-10-EA-24-AB-85-61-F2-66-BE-B3-C9-DD-53-FB-DD-CA-AF-E1-4D-7A-52-67-50-EE-16-8F-64-E7-A0-89-57-A7-96-36-45-69-CF-61-02-40-3D-9E-E3-29-D6-BD-59-FF-A5-C3-AC-57-CB-74-FE-B0-C3-67-34-A8-40-EB-04-88-C3-C2-74-4F-69-77-13-48-8A-97-3C-C2-4B-CD-E8-E0-97-98-A2-3F-B6-E2-71-D3-65-9F-5A-C6-C8-AE-FE-BA-B1-ED-DA-08-8A-5B-7B-12", BitConverter.ToString (p8.PrivateKey), "PrivateKey"); + Assert.AreEqual (0, p8.Version, "Version"); // static RSA rsa = PKCS8.PrivateKeyInfo.DecodeRSA (p8.PrivateKey); - AssertEquals ("DecodeRSA", "<RSAKeyValue><Modulus>1jmeIZPiujV/5fjohwuKXyglhbflzNp/08cJKmPprY/QqO+6zzz7VQO5gylODomE++JiFh+dh0AWa/j0ZjhYdGfUtaE6S28TSwg3OjpkCgaOonsUiLf4zmrRRZs5k2e/CqvbN536zlQPN4IJjw0z5LhuRsHMT4BatL0ZgCdAhEk=</Modulus><Exponent>AQAB</Exponent><P>7WqupzOwuIY2kbrn0t0VOpeiZjGYJKYN5wnjvTZ5kfJeI6ohyXFDJBD68Ob85MYfCEXokXQTaWOlQI84RCtUaQ==</P><Q>5v45i2/bRMrnctPKCVs9sVOFKTb88bnYH2QC1Pf1ceWfF9fzn1o6pqNiRvaTPdPNGPISvWgCqpFV2mQm1xY04Q==</Q><DP>YD/0yHJLPbOjodb9Lt5UQenBe961SH5NepHm0wmnpYR1p83MXsddKdz8bvemJPUxFYCJ9ZXyXLJ6Bz9I11IdqQ==</DP><DQ>QBv8wptX4t7hn7fyEei11ZpVkdvGFhy7Q/MQ6iSrhWHyZr6zyd1T+93Kr+FNelJnUO4Wj2TnoIlXp5Y2RWnPYQ==</DQ><InverseQ>PZ7jKda9Wf+lw6xXy3T+sMNnNKhA6wSIw8J0T2l3E0iKlzzCS83o4JeYoj+24nHTZZ9axsiu/rqx7doIilt7Eg==</InverseQ><D>FJVarU1BVrT3QgiFhxxDwlrgKBYAXYuNBrM0HT+WX1fXK7RFFc59M7D07TZVyq3J+k3JMOj+wNUWkm9MRFobnX6uuAFtOJ3ck2irk9bAiopjtNbaIcGgKIwkxCfhSzDSLYdi+Rd1IV7hPOItkgPGoY0d6Wf0zv+sUobS9Q/rAwE=</D></RSAKeyValue>", rsa.ToXmlString (true)); + Assert.AreEqual ("<RSAKeyValue><Modulus>1jmeIZPiujV/5fjohwuKXyglhbflzNp/08cJKmPprY/QqO+6zzz7VQO5gylODomE++JiFh+dh0AWa/j0ZjhYdGfUtaE6S28TSwg3OjpkCgaOonsUiLf4zmrRRZs5k2e/CqvbN536zlQPN4IJjw0z5LhuRsHMT4BatL0ZgCdAhEk=</Modulus><Exponent>AQAB</Exponent><P>7WqupzOwuIY2kbrn0t0VOpeiZjGYJKYN5wnjvTZ5kfJeI6ohyXFDJBD68Ob85MYfCEXokXQTaWOlQI84RCtUaQ==</P><Q>5v45i2/bRMrnctPKCVs9sVOFKTb88bnYH2QC1Pf1ceWfF9fzn1o6pqNiRvaTPdPNGPISvWgCqpFV2mQm1xY04Q==</Q><DP>YD/0yHJLPbOjodb9Lt5UQenBe961SH5NepHm0wmnpYR1p83MXsddKdz8bvemJPUxFYCJ9ZXyXLJ6Bz9I11IdqQ==</DP><DQ>QBv8wptX4t7hn7fyEei11ZpVkdvGFhy7Q/MQ6iSrhWHyZr6zyd1T+93Kr+FNelJnUO4Wj2TnoIlXp5Y2RWnPYQ==</DQ><InverseQ>PZ7jKda9Wf+lw6xXy3T+sMNnNKhA6wSIw8J0T2l3E0iKlzzCS83o4JeYoj+24nHTZZ9axsiu/rqx7doIilt7Eg==</InverseQ><D>FJVarU1BVrT3QgiFhxxDwlrgKBYAXYuNBrM0HT+WX1fXK7RFFc59M7D07TZVyq3J+k3JMOj+wNUWkm9MRFobnX6uuAFtOJ3ck2irk9bAiopjtNbaIcGgKIwkxCfhSzDSLYdi+Rd1IV7hPOItkgPGoY0d6Wf0zv+sUobS9Q/rAwE=</D></RSAKeyValue>", rsa.ToXmlString (true), "DecodeRSA"); } [Test] @@ -109,31 +109,31 @@ namespace MonoTests.Mono.Security.Cryptography { public void PrivateKeyInfo () { PKCS8.PrivateKeyInfo p8 = new PKCS8.PrivateKeyInfo (); - AssertNull ("Default-Algorithm", p8.Algorithm); - AssertEquals ("Default-Attributes", 0, p8.Attributes.Count); - AssertNull ("Default-PrivateKey", p8.PrivateKey); - AssertEquals ("Default-Version", 0, p8.Version); + Assert.IsNull (p8.Algorithm, "Default-Algorithm"); + Assert.AreEqual (0, p8.Attributes.Count, "Default-Attributes"); + Assert.IsNull (p8.PrivateKey, "Default-PrivateKey"); + Assert.AreEqual (0, p8.Version, "Default-Version"); byte[] key = new byte [8]; p8.Algorithm = "1.2.3.4.5"; p8.Attributes.Add (new ASN1 (0x05)); // NULL p8.PrivateKey = key; p8.Version = 1; - AssertEquals ("Algorithm", "1.2.3.4.5", p8.Algorithm); - AssertEquals ("Attributes", 1, p8.Attributes.Count); - AssertEquals ("PrivateKey", 8, p8.PrivateKey.Length); - AssertEquals ("Version", 1, p8.Version); + Assert.AreEqual ("1.2.3.4.5", p8.Algorithm, "Algorithm"); + Assert.AreEqual (1, p8.Attributes.Count, "Attributes"); + Assert.AreEqual (8, p8.PrivateKey.Length, "PrivateKey"); + Assert.AreEqual (1, p8.Version, "Version"); key [0] = 1; - AssertEquals ("PrivateKey not directly accessible", 0, p8.PrivateKey [0]); + Assert.AreEqual (0, p8.PrivateKey [0], "PrivateKey not directly accessible"); byte[] p8pki = p8.GetBytes (); PKCS8.PrivateKeyInfo decoded = new PKCS8.PrivateKeyInfo (p8pki); - AssertEquals ("Decoded-Algorithm", "1.2.3.4.5", decoded.Algorithm); - AssertEquals ("Decoded-Attributes", 1, decoded.Attributes.Count); - AssertEquals ("Decoded-PrivateKey", 8, decoded.PrivateKey.Length); - AssertEquals ("Decoded-Version", 1, decoded.Version); + Assert.AreEqual ("1.2.3.4.5", decoded.Algorithm, "Decoded-Algorithm"); + Assert.AreEqual (1, decoded.Attributes.Count, "Decoded-Attributes"); + Assert.AreEqual (8, decoded.PrivateKey.Length, "Decoded-PrivateKey"); + Assert.AreEqual (1, decoded.Version, "Decoded-Version"); } [Test] diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs index ba0f403e8a7..ef27bd73630 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/ChallengeResponseTest.cs @@ -17,7 +17,7 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Protocol.Ntlm { [TestFixture] - public class ChallengeResponseTest : Assertion { + public class ChallengeResponseTest { [Test] // Example from http://www.innovation.ch/java/ntlm.html @@ -25,8 +25,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] SrvNonce = Encoding.ASCII.GetBytes ("SrvNonce"); using (ChallengeResponse ntlm = new ChallengeResponse ("Beeblebrox", SrvNonce)) { - AssertEquals ("NT", "E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (ntlm.NT)); - AssertEquals ("LM", "AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (ntlm.LM)); + Assert.AreEqual ("E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (ntlm.NT), "NT"); + Assert.AreEqual ("AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (ntlm.LM), "LM"); } } @@ -36,8 +36,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; using (ChallengeResponse ntlm = new ChallengeResponse ("WELCOME", SrvNonce)) { - AssertEquals ("NT", "7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (ntlm.NT)); - AssertEquals ("LM", "CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM)); + Assert.AreEqual ("7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (ntlm.NT), "NT"); + Assert.AreEqual ("CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM"); } } @@ -46,9 +46,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; using (ChallengeResponse ntlm = new ChallengeResponse (null, SrvNonce)) { - AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT)); + Assert.AreEqual ("4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT), "NT"); // note the last 8 bytes... they are the same as the previous unit test ;-) - AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM)); + Assert.AreEqual ("0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM"); } } @@ -58,8 +58,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { byte[] SrvNonce = new byte [8] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; using (ChallengeResponse ntlm = new ChallengeResponse (String.Empty, SrvNonce)) { // same as the previous one as this is the same (null/empty) password expressed diffently - AssertEquals ("NT", "4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT)); - AssertEquals ("LM", "0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM)); + Assert.AreEqual ("4A-FD-81-EC-01-87-E8-8D-97-77-8D-F7-93-C6-DA-D4-F0-3A-36-63-66-9D-20-1C", BitConverter.ToString (ntlm.NT), "NT"); + Assert.AreEqual ("0A-39-2B-11-CF-05-2B-02-6D-65-CF-F5-68-BD-E4-15-A6-1B-FA-06-71-EA-5F-C8", BitConverter.ToString (ntlm.LM), "LM"); } } @@ -68,8 +68,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]); // no out! - AssertNull ("Password", ntlm.Password); - AssertNull ("Challenge", ntlm.Challenge); + Assert.IsNull (ntlm.Password, "Password"); + Assert.IsNull (ntlm.Challenge, "Challenge"); } [Test] @@ -104,7 +104,7 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]); ntlm.Dispose (); - AssertNotNull ("NT", ntlm.NT); + Assert.IsNotNull (ntlm.NT, "NT"); } [Test] @@ -113,7 +113,7 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { ChallengeResponse ntlm = new ChallengeResponse ("Mono", new byte [8]); ntlm.Dispose (); - AssertNotNull ("LM", ntlm.LM); + Assert.IsNotNull (ntlm.LM, "LM"); } } } diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/MessageBaseTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/MessageBaseTest.cs index 7164640be9b..a02816fadc7 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/MessageBaseTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/MessageBaseTest.cs @@ -15,7 +15,7 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Protocol.Ntlm { [TestFixture] - public class MessageBaseTest : Assertion { + public class MessageBaseTest { // @@ -42,4 +42,4 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { } } -}
\ No newline at end of file +} diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type1MessageTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type1MessageTest.cs index c6dc2394d93..5bd097e1d48 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type1MessageTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type1MessageTest.cs @@ -16,17 +16,17 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Protocol.Ntlm { [TestFixture] - public class Type1MessageTest : Assertion { + public class Type1MessageTest { [Test] // Example from http://www.innovation.ch/java/ntlm.html public void Encode1 () { Type1Message msg = new Type1Message (); - AssertEquals ("Type", 1, msg.Type); + Assert.AreEqual (1, msg.Type, "Type"); msg.Domain = "Ursa-Minor"; msg.Host = "LightCity"; - AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-01-00-00-00-07-B2-00-00-0A-00-0A-00-29-00-00-00-09-00-09-00-20-00-00-00-4C-49-47-48-54-43-49-54-59-55-52-53-41-2D-4D-49-4E-4F-52", BitConverter.ToString (msg.GetBytes ())); + Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-01-00-00-00-07-B2-00-00-0A-00-0A-00-29-00-00-00-09-00-09-00-20-00-00-00-4C-49-47-48-54-43-49-54-59-55-52-53-41-2D-4D-49-4E-4F-52", BitConverter.ToString (msg.GetBytes ()), "GetBytes"); } [Test] @@ -35,10 +35,10 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0xb2, 0x00, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x29, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x20, 0x00, 0x00, 0x00, 0x4c, 0x49, 0x47, 0x48, 0x54, 0x43, 0x49, 0x54, 0x59, 0x55, 0x52, 0x53, 0x41, 0x2d, 0x4d, 0x49, 0x4e, 0x4f, 0x52 }; Type1Message msg = new Type1Message (data); - AssertEquals ("Domain", "URSA-MINOR", msg.Domain); - AssertEquals ("Flags", (NtlmFlags)0xb203, msg.Flags); - AssertEquals ("Host", "LIGHTCITY", msg.Host); - AssertEquals ("Type", 1, msg.Type); + Assert.AreEqual ("URSA-MINOR", msg.Domain, "Domain"); + Assert.AreEqual ((NtlmFlags)0xb203, msg.Flags, "Flags"); + Assert.AreEqual ("LIGHTCITY", msg.Host, "Host"); + Assert.AreEqual (1, msg.Type, "Type"); } [Test] @@ -47,10 +47,10 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x0b, 0x00, 0x20, 0x00, 0x00, 0x00, 0x57, 0x4f, 0x52, 0x4b, 0x53, 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x44, 0x4f, 0x4d, 0x41, 0x49, 0x4e }; Type1Message msg = new Type1Message (data); - AssertEquals ("Domain", "DOMAIN", msg.Domain); - AssertEquals ("Flags", (NtlmFlags)0x3207, msg.Flags); - AssertEquals ("Host", "WORKSTATION", msg.Host); - AssertEquals ("Type", 1, msg.Type); + Assert.AreEqual ("DOMAIN", msg.Domain, "Domain"); + Assert.AreEqual ((NtlmFlags)0x3207, msg.Flags, "Flags"); + Assert.AreEqual ("WORKSTATION", msg.Host, "Host"); + Assert.AreEqual (1, msg.Type, "Type"); } } } diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type2MessageTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type2MessageTest.cs index bd1b38349a3..6233e0fe755 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type2MessageTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type2MessageTest.cs @@ -17,7 +17,7 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Protocol.Ntlm { [TestFixture] - public class Type2MessageTest : Assertion { + public class Type2MessageTest { static byte[] nonce = { 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65 }; @@ -26,9 +26,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { public void Encode1 () { Type2Message msg = new Type2Message (); - AssertEquals ("Type", 2, msg.Type); + Assert.AreEqual (2, msg.Type, "Type"); msg.Nonce = nonce; - AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-02-00-00-00-00-00-00-00-28-00-00-00-01-82-00-00-53-72-76-4E-6F-6E-63-65-00-00-00-00-00-00-00-00", BitConverter.ToString (msg.GetBytes ())); + Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-02-00-00-00-00-00-00-00-28-00-00-00-01-82-00-00-53-72-76-4E-6F-6E-63-65-00-00-00-00-00-00-00-00", BitConverter.ToString (msg.GetBytes ()), "GetBytes"); } [Test] @@ -37,9 +37,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01, 0x82, 0x00, 0x00, 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Type2Message msg = new Type2Message (data); - AssertEquals ("Flags", (NtlmFlags)0x8201, msg.Flags); - AssertEquals ("Nonce", BitConverter.ToString (nonce), BitConverter.ToString (msg.Nonce)); - AssertEquals ("Type", 2, msg.Type); + Assert.AreEqual ((NtlmFlags)0x8201, msg.Flags, "Flags"); + Assert.AreEqual (BitConverter.ToString (nonce), BitConverter.ToString (msg.Nonce), "Nonce"); + Assert.AreEqual (2, msg.Type, "Type"); } [Test] @@ -48,9 +48,9 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { { byte[] data = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x02, 0x81, 0x00, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x62, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x41, 0x00, 0x49, 0x00, 0x4e, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x53, 0x00, 0x45, 0x00, 0x52, 0x00, 0x56, 0x00, 0x45, 0x00, 0x52, 0x00, 0x04, 0x00, 0x14, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x03, 0x00, 0x22, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x2e, 0x00, 0x64, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x61, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x2e, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00 }; Type2Message msg = new Type2Message (data); - AssertEquals ("Flags", (NtlmFlags)0x00810201, msg.Flags); - AssertEquals ("Nonce", "01-23-45-67-89-AB-CD-EF", BitConverter.ToString (msg.Nonce)); - AssertEquals ("Type", 2, msg.Type); + Assert.AreEqual ((NtlmFlags)0x00810201, msg.Flags, "Flags"); + Assert.AreEqual ("01-23-45-67-89-AB-CD-EF", BitConverter.ToString (msg.Nonce), "Nonce"); + Assert.AreEqual (2, msg.Type, "Type"); } [Test] diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type3MessageTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type3MessageTest.cs index febcb797552..e9343cc979f 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type3MessageTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Protocol.Ntlm/Type3MessageTest.cs @@ -17,7 +17,7 @@ using NUnit.Framework; namespace MonoTests.Mono.Security.Protocol.Ntlm { [TestFixture] - public class Type3MessageTest : Assertion { + public class Type3MessageTest { static byte[] nonce = { 0x53, 0x72, 0x76, 0x4e, 0x6f, 0x6e, 0x63, 0x65 }; @@ -40,8 +40,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { msg.Host = "HOST"; msg.Password = "WELCOME"; msg.Username = "username"; - AssertEquals ("Type", 3, msg.Type); - AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-64-00-00-00-18-00-18-00-7C-00-00-00-0C-00-0C-00-40-00-00-00-10-00-10-00-4C-00-00-00-08-00-08-00-5C-00-00-00-00-00-00-00-94-00-00-00-01-B2-00-00-44-00-4F-00-4D-00-41-00-49-00-4E-00-75-00-73-00-65-00-72-00-6E-00-61-00-6D-00-65-00-48-00-4F-00-53-00-54-00-CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8-7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (msg.GetBytes ())); + Assert.AreEqual (3, msg.Type, "Type"); + Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-64-00-00-00-18-00-18-00-7C-00-00-00-0C-00-0C-00-40-00-00-00-10-00-10-00-4C-00-00-00-08-00-08-00-5C-00-00-00-00-00-00-00-94-00-00-00-01-B2-00-00-44-00-4F-00-4D-00-41-00-49-00-4E-00-75-00-73-00-65-00-72-00-6E-00-61-00-6D-00-65-00-48-00-4F-00-53-00-54-00-CA-12-00-72-3C-41-D5-77-AB-18-C7-64-C6-DE-F3-4F-A6-1B-FA-06-71-EA-5F-C8-7A-CE-90-85-AB-CC-37-59-38-0B-1C-68-62-E3-98-C3-C0-EF-9C-FC-22-E8-A2-C2", BitConverter.ToString (msg.GetBytes ()), "GetBytes"); } [Test] @@ -55,8 +55,8 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { msg.Host = "LIGHTCITY"; msg.Password = "Beeblebrox"; msg.Username = "Zaphod"; - AssertEquals ("Type", 3, msg.Type); - AssertEquals ("GetBytes", "4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-72-00-00-00-18-00-18-00-8A-00-00-00-14-00-14-00-40-00-00-00-0C-00-0C-00-54-00-00-00-12-00-12-00-60-00-00-00-00-00-00-00-A2-00-00-00-01-B2-00-00-55-00-52-00-53-00-41-00-2D-00-4D-00-49-00-4E-00-4F-00-52-00-5A-00-61-00-70-00-68-00-6F-00-64-00-4C-00-49-00-47-00-48-00-54-00-43-00-49-00-54-00-59-00-AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97-E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.GetBytes ())); + Assert.AreEqual (3, msg.Type, "Type"); + Assert.AreEqual ("4E-54-4C-4D-53-53-50-00-03-00-00-00-18-00-18-00-72-00-00-00-18-00-18-00-8A-00-00-00-14-00-14-00-40-00-00-00-0C-00-0C-00-54-00-00-00-12-00-12-00-60-00-00-00-00-00-00-00-A2-00-00-00-01-B2-00-00-55-00-52-00-53-00-41-00-2D-00-4D-00-49-00-4E-00-4F-00-52-00-5A-00-61-00-70-00-68-00-6F-00-64-00-4C-00-49-00-47-00-48-00-54-00-43-00-49-00-54-00-59-00-AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97-E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.GetBytes ()), "GetBytes"); } [Test] @@ -64,14 +64,14 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { public void Decode1 () { Type3Message msg = new Type3Message (data1); - AssertEquals ("Domain", "URSA-MINOR", msg.Domain); - AssertEquals ("Host", "LIGHTCITY", msg.Host); - AssertEquals ("Username", "Zaphod", msg.Username); - AssertEquals ("Flags", (NtlmFlags)0x8201, msg.Flags); - AssertEquals ("Type", 3, msg.Type); - AssertNull ("Password", msg.Password); - AssertEquals ("LM", "AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (msg.LM)); - AssertEquals ("NT", "E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.NT)); + Assert.AreEqual ("URSA-MINOR", msg.Domain, "Domain"); + Assert.AreEqual ("LIGHTCITY", msg.Host, "Host"); + Assert.AreEqual ("Zaphod", msg.Username, "Username"); + Assert.AreEqual ((NtlmFlags)0x8201, msg.Flags, "Flags"); + Assert.AreEqual (3, msg.Type, "Type"); + Assert.IsNull (msg.Password, "Password"); + Assert.AreEqual ("AD-87-CA-6D-EF-E3-46-85-B9-C4-3C-47-7A-8C-42-D6-00-66-7D-68-92-E7-E8-97", BitConverter.ToString (msg.LM), "LM"); + Assert.AreEqual ("E0-E0-0D-E3-10-4A-1B-F2-05-3F-07-C7-DD-A8-2D-3C-48-9A-E9-89-E1-B0-00-D3", BitConverter.ToString (msg.NT), "NT"); } [Test] @@ -79,28 +79,28 @@ namespace MonoTests.Mono.Security.Protocol.Ntlm { public void Decode2 () { Type3Message msg = new Type3Message (data2); - AssertEquals ("Domain", "DOMAIN", msg.Domain); - AssertEquals ("Host", "WORKSTATION", msg.Host); - AssertEquals ("Username", "user", msg.Username); - AssertEquals ("Flags", (NtlmFlags)0x201, msg.Flags); - AssertEquals ("Type", 3, msg.Type); - AssertNull ("Password", msg.Password); - AssertEquals ("LM", "C3-37-CD-5C-BD-44-FC-97-82-A6-67-AF-6D-42-7C-6D-E6-7C-20-C2-D3-E7-7C-56", BitConverter.ToString (msg.LM)); - AssertEquals ("NT", "25-A9-8C-1C-31-E8-18-47-46-6B-29-B2-DF-46-80-F3-99-58-FB-8C-21-3A-9C-C6", BitConverter.ToString (msg.NT)); + Assert.AreEqual ("DOMAIN", msg.Domain, "Domain"); + Assert.AreEqual ("WORKSTATION", msg.Host, "Host"); + Assert.AreEqual ("user", msg.Username, "Username"); + Assert.AreEqual ((NtlmFlags)0x201, msg.Flags, "Flags"); + Assert.AreEqual (3, msg.Type, "Type"); + Assert.IsNull (msg.Password, "Password"); + Assert.AreEqual ("C3-37-CD-5C-BD-44-FC-97-82-A6-67-AF-6D-42-7C-6D-E6-7C-20-C2-D3-E7-7C-56", BitConverter.ToString (msg.LM), "LM"); + Assert.AreEqual ("25-A9-8C-1C-31-E8-18-47-46-6B-29-B2-DF-46-80-F3-99-58-FB-8C-21-3A-9C-C6", BitConverter.ToString (msg.NT), "NT"); } [Test] public void Challenge () { Type3Message msg = new Type3Message (); - AssertNull ("Challenge", msg.Challenge); + Assert.IsNull (msg.Challenge, "Challenge"); byte[] c = new byte [8]; msg.Challenge = c; - AssertEquals ("Challenge.Length", 8, msg.Challenge.Length); + Assert.AreEqual (8, msg.Challenge.Length, "Challenge.Length"); c [0] = 1; - AssertEquals ("Challenge not directly accessible", 0, msg.Challenge [0]); + Assert.AreEqual (0, msg.Challenge [0], "Challenge not directly accessible"); } [Test] diff --git a/mcs/class/Mono.Security/Test/Mono.Security/StrongNameTest.cs b/mcs/class/Mono.Security/Test/Mono.Security/StrongNameTest.cs index 05e013cd4aa..fe94f26e01b 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security/StrongNameTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security/StrongNameTest.cs @@ -22,7 +22,7 @@ namespace MonoTests.Mono.Security { // sn -k test.snk [TestFixture] - public class StrongNameTest : Assertion { + public class StrongNameTest { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -30,9 +30,9 @@ namespace MonoTests.Mono.Security { 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) { @@ -47,7 +47,7 @@ namespace MonoTests.Mono.Security { msg += " -> Expected " + BitConverter.ToString (array1, 0); msg += " is different than " + BitConverter.ToString (array2, 0); } - Assert (msg, a); + Assert.IsTrue (a, msg); } static byte[] test = { @@ -112,9 +112,9 @@ namespace MonoTests.Mono.Security { public void FromBuffer () { StrongName sn = new StrongName (test); - AssertEquals ("buffer.RSA", "<RSAKeyValue><Modulus>y6T/+EoARJMHW0ilpCdn+VbTffWxb1xu187/9Q+S2DwPyZ9LTNKrZgwaYmG4FPWEEH1HJxrxwh8AlD6oTz8CCcnPGKxKVFkubpIbEyvQCSTr22gUjVXXKHc2pfcCeOuNXS9kAOjv2tqpsiDbIsu9mnxfYysHWMDBqA4rxghyvT0=</Modulus><Exponent>AQAB</Exponent><P>6qYUEleRY+Wzyk7xN05UwWRna37U2aQnq2Y2VVyJeceDZPU1u1GYdQmFQw5XgvxKwWx9DAfNh1iSyLe0YmrAcw==</P><Q>3iy1IDIkPrRWBFrCAUhpUNn4/ICiVXTT7KjuEXkGr0+1Cx/V+o3eoVIo/9x2Q3IaxMbQDSa8hisIFunz/iuPjw==</Q><DP>2BouIBpfvzX8mBSOGNZePmG+0YRUeUCyfCs9XO5Fek9h1mfynVpvY1JqVbBuria2nl7Q53SEN+M+A/cT/RO9uw==</DP><DQ>pjma1ljNh2CTTrS8nAsaSJSc1gZD7l33RQRrAgWju7yN/qG2DbzhSZ9X7355uSKA5qK8/Gnz+QnvBn3JwGvE/w==</DQ><InverseQ>3U67bp3lPExfGoiTRvRyHhNtyJs6hAq/Uj7wSHKLHNoLG20kwZux8BwZKpPBBA0bQjkLUiRv9PYs18El/45/wA==</InverseQ><D>bPVOg5FMjWRBhmTbQ3ZWGkGLjRR9KEFDiTJXHs6DWjDgnZceWe9KB6KoJ0Vzkbs/Ovdcr56qBZxC2g6gTS5ALvogBYH2PrUftr4flh/z4qgOrAYCQkTecfHAGIGEldEeF1FItMbqmQa6WzVPVp4tn/+q3PAVmZqrs6/X9EARH10=</D></RSAKeyValue>", sn.RSA.ToXmlString (true)); - AssertEquals ("buffer.PublicKey", testPublicKey, sn.PublicKey); - AssertEquals ("buffer.PublicKeyToken", testPublicKeyToken, sn.PublicKeyToken); + Assert.AreEqual ("<RSAKeyValue><Modulus>y6T/+EoARJMHW0ilpCdn+VbTffWxb1xu187/9Q+S2DwPyZ9LTNKrZgwaYmG4FPWEEH1HJxrxwh8AlD6oTz8CCcnPGKxKVFkubpIbEyvQCSTr22gUjVXXKHc2pfcCeOuNXS9kAOjv2tqpsiDbIsu9mnxfYysHWMDBqA4rxghyvT0=</Modulus><Exponent>AQAB</Exponent><P>6qYUEleRY+Wzyk7xN05UwWRna37U2aQnq2Y2VVyJeceDZPU1u1GYdQmFQw5XgvxKwWx9DAfNh1iSyLe0YmrAcw==</P><Q>3iy1IDIkPrRWBFrCAUhpUNn4/ICiVXTT7KjuEXkGr0+1Cx/V+o3eoVIo/9x2Q3IaxMbQDSa8hisIFunz/iuPjw==</Q><DP>2BouIBpfvzX8mBSOGNZePmG+0YRUeUCyfCs9XO5Fek9h1mfynVpvY1JqVbBuria2nl7Q53SEN+M+A/cT/RO9uw==</DP><DQ>pjma1ljNh2CTTrS8nAsaSJSc1gZD7l33RQRrAgWju7yN/qG2DbzhSZ9X7355uSKA5qK8/Gnz+QnvBn3JwGvE/w==</DQ><InverseQ>3U67bp3lPExfGoiTRvRyHhNtyJs6hAq/Uj7wSHKLHNoLG20kwZux8BwZKpPBBA0bQjkLUiRv9PYs18El/45/wA==</InverseQ><D>bPVOg5FMjWRBhmTbQ3ZWGkGLjRR9KEFDiTJXHs6DWjDgnZceWe9KB6KoJ0Vzkbs/Ovdcr56qBZxC2g6gTS5ALvogBYH2PrUftr4flh/z4qgOrAYCQkTecfHAGIGEldEeF1FItMbqmQa6WzVPVp4tn/+q3PAVmZqrs6/X9EARH10=</D></RSAKeyValue>", sn.RSA.ToXmlString (true), "buffer.RSA"); + Assert.AreEqual (testPublicKey, sn.PublicKey, "buffer.PublicKey"); + Assert.AreEqual (testPublicKeyToken, sn.PublicKeyToken, "buffer.PublicKeyToken"); } [Test] @@ -122,9 +122,9 @@ namespace MonoTests.Mono.Security { { StrongName sn1 = new StrongName (test); StrongName sn2 = new StrongName (sn1.RSA); - AssertEquals ("key.RSA", sn1.RSA.ToXmlString (true), sn2.RSA.ToXmlString (true)); - AssertEquals ("key.PublicKey", sn1.PublicKey, sn2.PublicKey); - AssertEquals ("key.PublicKeyToken", sn1.PublicKeyToken, sn2.PublicKeyToken); + Assert.AreEqual (sn1.RSA.ToXmlString (true), sn2.RSA.ToXmlString (true), "key.RSA"); + Assert.AreEqual (sn1.PublicKey, sn2.PublicKey, "key.PublicKey"); + Assert.AreEqual (sn1.PublicKeyToken, sn2.PublicKeyToken, "key.PublicKeyToken"); } string Signed; @@ -820,28 +820,28 @@ namespace MonoTests.Mono.Security { { // compare that both hellosigned and hellodelay are the same file expect for signature byte[] s = sn.Hash (Signed); - AssertNotNull ("Hash/Signed", s); + Assert.IsNotNull (s, "Hash/Signed"); byte[] d = sn.Hash (Delay); - AssertNotNull ("Hash/Delay", d); + Assert.IsNotNull (d, "Hash/Delay"); // are they the same - AssertEquals ("Hash/Compare", s, d); + Assert.AreEqual (s, d, "Hash/Compare"); // are they the same as GetHashFromAssemblyFile byte[] knownHash = { 0x7D, 0xF7, 0x1D, 0xD4, 0x24, 0x22, 0xEA, 0xAB, 0xD2, 0x91, 0xCD, 0xAB, 0x1A, 0x55, 0x6A, 0x42, 0x05, 0xBA, 0x6E, 0x7B }; - AssertEquals ("Hash/GetHashFromAssemblyFile", knownHash, s); + Assert.AreEqual (knownHash, s, "Hash/GetHashFromAssemblyFile"); } [Test] public void VerifyValid () { // verify that hellosigned.exe is valid - Assert ("Verify/Valid", sn.Verify (Signed)); + Assert.IsTrue (sn.Verify (Signed), "Verify/Valid"); } [Test] public void VerifyInvalid () { // verify that hellodelay.exe isn't valid - Assert ("Verify/Invalid", !sn.Verify (Delay)); + Assert.IsTrue (!sn.Verify (Delay), "Verify/Invalid"); } [Test] @@ -849,7 +849,7 @@ namespace MonoTests.Mono.Security { { Stream signed = new MemoryStream (signedData); // verify that hellosigned.exe is valid - Assert ("Verify/Valid", sn.Verify (signed)); + Assert.IsTrue (sn.Verify (signed), "Verify/Valid"); } [Test] @@ -857,25 +857,25 @@ namespace MonoTests.Mono.Security { { Stream delay = new MemoryStream (delayData); // verify that hellodelay.exe isn't valid - Assert ("Verify/Invalid", !sn.Verify (delay)); + Assert.IsTrue (!sn.Verify (delay), "Verify/Invalid"); } [Test] public void Sign () { // sign the (invalid) hellodelay.exe - Assert ("Sign", sn.Sign (Delay)); + Assert.IsTrue (sn.Sign (Delay), "Sign"); // and verify it's now valid - Assert ("Sign/Verify", sn.Verify (Delay)); + Assert.IsTrue (sn.Verify (Delay), "Sign/Verify"); } [Test] public void ReSign () { // resign the (already valid) hellosigned.exe - Assert ("ReSign", sn.Sign (Signed)); + Assert.IsTrue (sn.Sign (Signed), "ReSign"); // and verify it's still valid - Assert ("ReSign/Verify", sn.Verify (Signed)); + Assert.IsTrue (sn.Verify (Signed), "ReSign/Verify"); } [Test] @@ -907,7 +907,7 @@ namespace MonoTests.Mono.Security { { byte[] ecma = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; sn = new StrongName (ecma); - Assert ("CanSign", !sn.CanSign); + Assert.IsTrue (!sn.CanSign, "CanSign"); } [Test] diff --git a/mcs/class/System.Data/Test/System.Data/DataRowTest.cs b/mcs/class/System.Data/Test/System.Data/DataRowTest.cs index 5b2fd8ca9f3..e8487efaf6b 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRowTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRowTest.cs @@ -41,7 +41,7 @@ using System.Data; namespace MonoTests.System.Data { [TestFixture] - public class DataRowTest : Assertion { + public class DataRowTest { private DataTable table; private DataRow row; @@ -101,7 +101,7 @@ namespace MonoTests.System.Data private void GetColumnErrorTest () { // Print the error of a specified column. - AssertEquals ("#A01", "Some error!", row.GetColumnError (1)); + Assert.AreEqual ("Some error!", row.GetColumnError (1), "#A01"); } private void GetAllErrorsTest () @@ -112,7 +112,7 @@ namespace MonoTests.System.Data colArr = row.GetColumnsInError (); for (int i = 0; i < colArr.Length; i++) { - AssertEquals ("#A02", table.Columns [1], colArr [i]); + Assert.AreEqual (table.Columns [1], colArr [i], "#A02"); } row.ClearErrors (); } @@ -135,7 +135,7 @@ namespace MonoTests.System.Data int cnt = 1; for (int i = 1; i < table.Rows.Count; i++) { DataRow r = table.Rows [i]; - AssertEquals ("#A03", "Name " + cnt, r ["fName"]); + Assert.AreEqual ("Name " + cnt, r ["fName"], "#A03"); cnt++; } @@ -146,20 +146,20 @@ namespace MonoTests.System.Data rc [2].Delete (); - AssertEquals ("#A04", "Deleted", rc [0].RowState.ToString ()); - AssertEquals ("#A05", "Deleted", rc [2].RowState.ToString ()); + Assert.AreEqual ("Deleted", rc [0].RowState.ToString (), "#A04"); + Assert.AreEqual ("Deleted", rc [2].RowState.ToString (), "#A05"); // Accept changes table.AcceptChanges (); - AssertEquals ("#A06", "Name 1", (table.Rows [0]) [1]); + Assert.AreEqual ("Name 1", (table.Rows [0]) [1], "#A06"); try { object o = rc [2]; - Fail ("#A07"); + Assert.Fail ("#A07"); } catch (Exception e) { // Never premise English. - //AssertEquals ("#A08", "There is no row at position 2.", e.Message); + //Assert.AreEqual ("#A08", "There is no row at position 2.", e.Message); } } @@ -179,40 +179,40 @@ namespace MonoTests.System.Data // Stage 1 //Initially: After Add (Row) But Before Accept Changes"); - AssertEquals ("#A09", "My FName", row [1, DataRowVersion.Default]); - AssertEquals ("#A10", "LName", row [2, DataRowVersion.Default]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Default], "#A09"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Default], "#A10"); - AssertEquals ("#A11", "My FName", row [1, DataRowVersion.Current]); - AssertEquals ("#A12", "LName", row [2, DataRowVersion.Current]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Current], "#A11"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Current], "#A12"); try { object o = row [1, DataRowVersion.Original]; o = row [1, DataRowVersion.Proposed]; - Fail ("#A13"); + Assert.Fail ("#A13"); } catch (Exception e) { if (e.GetType () != typeof (AssertionException)) { - AssertEquals ("#A14", typeof (VersionNotFoundException), e.GetType ()); + Assert.AreEqual (typeof (VersionNotFoundException), e.GetType (), "#A14"); } } // Stage 2 //After Accept Changes table.AcceptChanges (); - AssertEquals ("#A15", "My FName", row [1, DataRowVersion.Default]); - AssertEquals ("#A16", "LName", row [2, DataRowVersion.Default]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Default], "#A15"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Default], "#A16"); - AssertEquals ("#A17", "My FName", row [1, DataRowVersion.Current]); - AssertEquals ("#A18", "LName", row [2, DataRowVersion.Current]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Current], "#A17"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Current], "#A18"); try { object o = row [1, DataRowVersion.Proposed]; - Fail ("#A19"); + Assert.Fail ("#A19"); } catch (Exception e) { if (e.GetType () != typeof (AssertionException)) { - AssertEquals ("#A20", typeof (VersionNotFoundException), e.GetType ()); + Assert.AreEqual (typeof (VersionNotFoundException), e.GetType (), "#A20"); } } @@ -221,63 +221,64 @@ namespace MonoTests.System.Data table.Rows [0].BeginEdit (); table.Rows [0] ["LName"] = "My LName"; - AssertEquals ("#A21", "My FName", row [1, DataRowVersion.Default]); - AssertEquals ("#A22", "My LName", row [2, DataRowVersion.Default]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Default], "#A21"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Default], "#A22"); - AssertEquals ("#A23", "My FName", row [1, DataRowVersion.Current]); - AssertEquals ("#A24", "LName", row [2, DataRowVersion.Current]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Current], "#A23"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Current], "#A24"); - AssertEquals ("#A25", "My FName", row [1, DataRowVersion.Original]); AssertEquals ("#A26", "LName", row [2, DataRowVersion.Original]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Original], "#A25"); + Assert.AreEqual ("LName", row [2, DataRowVersion.Original], "#A26"); - AssertEquals ("#A26", "My FName", row [1, DataRowVersion.Proposed]); - AssertEquals ("#A27", "My LName", row [2, DataRowVersion.Proposed]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Proposed], "#A26"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Proposed], "#A27"); // Stage 4 //After Edit sessions for (int i=0; i < table.Rows.Count;i++) table.Rows [i].EndEdit (); - AssertEquals ("#A28", "My FName", row [1, DataRowVersion.Default]); - AssertEquals ("#A29", "My LName", row [2, DataRowVersion.Default]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Default], "#A28"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Default], "#A29"); - AssertEquals ("#A30", "My FName", row [1, DataRowVersion.Original]); AssertEquals ("#A31", "LName", row [2, DataRowVersion.Original]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Original], "#A30"); Assert.AreEqual ("LName", row [2, DataRowVersion.Original], "#A31"); - AssertEquals ("#A32", "My FName", row [1, DataRowVersion.Current]); - AssertEquals ("#A33", "My LName", row [2, DataRowVersion.Current]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Current], "#A32"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Current], "#A33"); try { object o = row [1, DataRowVersion.Proposed]; - Fail ("#A34"); + Assert.Fail ("#A34"); } catch (Exception e) { if (e.GetType ()!=typeof (AssertionException)) { - AssertEquals ("#A35", typeof (VersionNotFoundException), e.GetType ()); + Assert.AreEqual (typeof (VersionNotFoundException), e.GetType (), "#A35"); } } //Stage 5 //After Accept Changes table.AcceptChanges (); - AssertEquals ("#A36", "My FName", row [1, DataRowVersion.Default]); - AssertEquals ("#A37", "My LName", row [2, DataRowVersion.Default]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Default], "#A36"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Default], "#A37"); - AssertEquals ("#A38", "My FName", row [1, DataRowVersion.Original]); AssertEquals ("#A39", "My LName", row [2, DataRowVersion.Original]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Original], "#A38"); Assert.AreEqual (row [2, DataRowVersion.Original], "#A39", "My LName"); - AssertEquals ("#A40", "My FName", row [1, DataRowVersion.Current]); - AssertEquals ("#A41", "My LName", row [2, DataRowVersion.Current]); + Assert.AreEqual ("My FName", row [1, DataRowVersion.Current], "#A40"); + Assert.AreEqual ("My LName", row [2, DataRowVersion.Current], "#A41"); try { object o = row [1, DataRowVersion.Proposed]; - Fail ("#A42"); + Assert.Fail ("#A42"); } catch (Exception e) { if (e.GetType () != typeof (AssertionException)) { - AssertEquals ("#A43", typeof (VersionNotFoundException), - e.GetType ()); + Assert.AreEqual (typeof (VersionNotFoundException), e.GetType (), + "#A43"); } } @@ -328,22 +329,22 @@ namespace MonoTests.System.Data rowC.SetParentRow (table.Rows [0], dr); - AssertEquals ("#PRT-01", table.Rows [0], (tableC.Rows [0]).GetParentRow (dr)); - AssertEquals ("#PRT-02", tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0]); + Assert.AreEqual (table.Rows [0], (tableC.Rows [0]).GetParentRow (dr), "#PRT-01"); + Assert.AreEqual (tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0], "#PRT-02"); ds.Relations.Clear (); dr = new DataRelation ("PO", table.Columns ["Id"], tableC.Columns ["Id"], false); ds.Relations.Add (dr); rowC.SetParentRow (table.Rows [0], dr); - AssertEquals ("#PRT-03", table.Rows [0], (tableC.Rows [0]).GetParentRow (dr)); - AssertEquals ("#PRT-04", tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0]); + Assert.AreEqual (table.Rows [0], (tableC.Rows [0]).GetParentRow (dr), "#PRT-03"); + Assert.AreEqual (tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0], "#PRT-04"); ds.Relations.Clear (); dr = new DataRelation ("PO", table.Columns ["Id"], tableC.Columns ["Id"], false); tableC.ParentRelations.Add (dr); rowC.SetParentRow (table.Rows [0]); - AssertEquals ("#PRT-05", table.Rows [0], (tableC.Rows [0]).GetParentRow (dr)); - AssertEquals ("#PRT-06", tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0]); + Assert.AreEqual (table.Rows [0], (tableC.Rows [0]).GetParentRow (dr), "#PRT-05"); + Assert.AreEqual (tableC.Rows [0], (table.Rows [0]).GetChildRows (dr) [0], "#PRT-06"); } @@ -377,8 +378,8 @@ namespace MonoTests.System.Data rowC.SetParentRow (row, dr); DataRow [] rows = rowC.GetParentRows (dr); - AssertEquals ("#A49", 1, rows.Length); - AssertEquals ("#A50", tableP.Rows [0], rows [0]); + Assert.AreEqual (1, rows.Length, "#A49"); + Assert.AreEqual (tableP.Rows [0], rows [0], "#A50"); try{ rows = row.GetParentRows (dr); @@ -386,10 +387,10 @@ namespace MonoTests.System.Data //Test done return ; }catch(Exception e){ - Fail("#A51, InvalidConstraintException expected, got : " + e); + Assert.Fail("#A51, InvalidConstraintException expected, got : " + e); } - Fail("#A52, InvalidConstraintException expected but got none."); + Assert.Fail("#A52, InvalidConstraintException expected but got none."); } [Test] @@ -434,8 +435,8 @@ namespace MonoTests.System.Data DataRow [] rows = (table.Rows [0]).GetChildRows (dr); - AssertEquals ("#A45", 1, rows.Length); - AssertEquals ("#A46", tableC.Rows [0], rows [0]); + Assert.AreEqual (1, rows.Length, "#A45"); + Assert.AreEqual (tableC.Rows [0], rows [0], "#A46"); } @@ -469,8 +470,8 @@ namespace MonoTests.System.Data rowC.SetParentRow (row, dr); DataRow [] rows = row.GetChildRows (dr); - AssertEquals ("#A47", 1, rows.Length); - AssertEquals ("#A48", tableC.Rows [0], rows [0]); + Assert.AreEqual (1, rows.Length, "#A47"); + Assert.AreEqual (tableC.Rows [0], rows [0], "#A48"); try{ rows = rowC.GetChildRows (dr); @@ -478,10 +479,10 @@ namespace MonoTests.System.Data //Test done return ; }catch(Exception e){ - Fail("#A53, InvalidConstraintException expected, got : " + e); + Assert.Fail("#A53, InvalidConstraintException expected, got : " + e); } - Fail("#A54, InvalidConstraintException expected but got none."); + Assert.Fail("#A54, InvalidConstraintException expected but got none."); } [Category ("NotWorking")] //Mismatch in Exception namespace/class reference @@ -528,35 +529,35 @@ namespace MonoTests.System.Data //Test Done return ; }catch (Exception e){ - Fail ("#A55, VersionNotFoundException expected, got : " + e); + Assert.Fail ("#A55, VersionNotFoundException expected, got : " + e); } - Fail ("#A56, VersionNotFoundException expected but got none."); + Assert.Fail ("#A56, VersionNotFoundException expected but got none."); }catch (Exception e){ - Fail ("#A57, VersionNotFoundException expected, got : " + e); + Assert.Fail ("#A57, VersionNotFoundException expected, got : " + e); } - Fail("#A58, VersionNotFoundException expected but got none."); + Assert.Fail("#A58, VersionNotFoundException expected but got none."); } // tests item at row, column in table to be DBNull.Value private void DBNullTest (string message, DataTable dt, int row, int column) { object val = dt.Rows[row].ItemArray[column]; - AssertEquals(message, DBNull.Value, val); + Assert.AreEqual(DBNull.Value, val, message); } // tests item at row, column in table to be null private void NullTest (string message, DataTable dt, int row, int column) { object val = dt.Rows[row].ItemArray[column]; - AssertEquals(message, null, val); + Assert.AreEqual(null, val, message); } // tests item at row, column in table to be private void ValueTest (string message, DataTable dt, int row, int column, object value) { object val = dt.Rows[row].ItemArray[column]; - AssertEquals(message, value, val); + Assert.AreEqual(value, val, message); } // test set null, DBNull.Value, and ItemArray short count @@ -588,7 +589,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e1) { - Fail("DR1: Exception Caught: " + e1); + Assert.Fail("DR1: Exception Caught: " + e1); } table.Rows.Add(row); @@ -606,7 +607,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR2: Exception Caught: " + e2); + Assert.Fail("DR2: Exception Caught: " + e2); } table.Rows.Add(row); @@ -624,7 +625,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR3: Exception Caught: " + e3); + Assert.Fail("DR3: Exception Caught: " + e3); } table.Rows.Add(row); @@ -646,7 +647,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR4: Exception Caught: " + e3); + Assert.Fail("DR4: Exception Caught: " + e3); } table.Rows.Add(row); @@ -698,7 +699,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e1) { - Fail("DR17: Exception Caught: " + e1); + Assert.Fail("DR17: Exception Caught: " + e1); } table.Rows.Add(row); @@ -715,7 +716,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR18: Exception Caught: " + e2); + Assert.Fail("DR18: Exception Caught: " + e2); } table.Rows.Add(row); @@ -733,7 +734,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR19: Exception Caught: " + e3); + Assert.Fail("DR19: Exception Caught: " + e3); } table.Rows.Add(row); @@ -753,7 +754,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR20: Exception Caught: " + e3); + Assert.Fail("DR20: Exception Caught: " + e3); } table.Rows.Add(row); @@ -802,7 +803,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e1) { - Fail("DR28: Exception Caught: " + e1); + Assert.Fail("DR28: Exception Caught: " + e1); } table.Rows.Add(row); @@ -819,7 +820,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR29: Exception Caught: " + e2); + Assert.Fail("DR29: Exception Caught: " + e2); } table.Rows.Add(row); @@ -836,7 +837,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR30: Exception Caught: " + e2); + Assert.Fail("DR30: Exception Caught: " + e2); } table.Rows.Add(row); @@ -853,7 +854,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR31: Exception Caught: " + e2); + Assert.Fail("DR31: Exception Caught: " + e2); } table.Rows.Add(row); @@ -872,7 +873,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR32: Exception Caught: " + e3); + Assert.Fail("DR32: Exception Caught: " + e3); } table.Rows.Add(row); @@ -889,7 +890,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e2) { - Fail("DR48: Exception Caught: " + e2); + Assert.Fail("DR48: Exception Caught: " + e2); } table.Rows.Add(row); @@ -909,7 +910,7 @@ namespace MonoTests.System.Data row.ItemArray = obj; } catch(Exception e3) { - Fail("DR33: Exception Caught: " + e3); + Assert.Fail("DR33: Exception Caught: " + e3); } table.Rows.Add(row); @@ -986,7 +987,7 @@ namespace MonoTests.System.Data DataRow childRow = child.Rows.Add(new object[] { id }); if (parentRow == childRow.GetParentRow(relateParentChild)) { foreach(DataColumn dc in parent.Columns) - AssertEquals(100,parentRow[dc]); + Assert.AreEqual(100,parentRow[dc]); } @@ -1002,9 +1003,9 @@ namespace MonoTests.System.Data dt.Rows.Add ((new object [] {"val"})); DataRow dr = dt.NewRow (); - AssertEquals (DataRowState.Detached, dr.RowState); + Assert.AreEqual (DataRowState.Detached, dr.RowState); dr.CancelEdit (); - AssertEquals (DataRowState.Detached, dr.RowState); + Assert.AreEqual (DataRowState.Detached, dr.RowState); object o = dr ["col"]; } @@ -1056,20 +1057,20 @@ namespace MonoTests.System.Data parent2.Rows.Add(parent2Row); childRow1.SetParentRow(parent1Row); - AssertEquals ("p1c1", childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual ("p1c1", childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); childRow1.SetParentRow(parent2Row); - AssertEquals ("p1c1", childRow1[childColumn1]); - AssertEquals ("p2c2", childRow1[childColumn2]); + Assert.AreEqual ("p1c1", childRow1[childColumn1]); + Assert.AreEqual ("p2c2", childRow1[childColumn2]); childRow1.SetParentRow(null); - AssertEquals (DBNull.Value, childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); childRow1.SetParentRow(parent2Row); - AssertEquals (DBNull.Value, childRow1[childColumn1]); - AssertEquals ("p2c2", childRow1[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn1]); + Assert.AreEqual ("p2c2", childRow1[childColumn2]); } [Test] @@ -1108,29 +1109,29 @@ namespace MonoTests.System.Data childRow1.SetParentRow (null, relation2); - AssertEquals (DBNull.Value, childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); try { childRow1.SetParentRow(parent1Row, relation2); - Fail ("Must throw InvalidConstaintException"); + Assert.Fail ("Must throw InvalidConstaintException"); } catch (InvalidConstraintException e) { } - AssertEquals (DBNull.Value, childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); childRow1.SetParentRow(parent1Row, relation1); - AssertEquals ("p1c1", childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual ("p1c1", childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); childRow1.SetParentRow (null, relation2); - AssertEquals ("p1c1", childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual ("p1c1", childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); childRow1.SetParentRow (null, relation1); - AssertEquals (DBNull.Value, childRow1[childColumn1]); - AssertEquals (DBNull.Value, childRow1[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn1]); + Assert.AreEqual (DBNull.Value, childRow1[childColumn2]); } [Test] @@ -1161,8 +1162,8 @@ namespace MonoTests.System.Data parent2.Rows.Add(parentRow); childRow.SetParentRow(parentRow); - AssertEquals (DBNull.Value, childRow[childColumn1]); - AssertEquals ("value", childRow[childColumn2]); + Assert.AreEqual (DBNull.Value, childRow[childColumn1]); + Assert.AreEqual ("value", childRow[childColumn2]); } } diff --git a/mcs/class/System.Data/Test/System.Data/DataRowViewTest.cs b/mcs/class/System.Data/Test/System.Data/DataRowViewTest.cs index 51885f37bcb..60dbb9d3933 100644 --- a/mcs/class/System.Data/Test/System.Data/DataRowViewTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataRowViewTest.cs @@ -36,7 +36,7 @@ using System.ComponentModel; namespace MonoTests.System.Data { [TestFixture] - public class DataRowViewTest : Assertion + public class DataRowViewTest { private DataView CreateTestView () { @@ -96,8 +96,8 @@ namespace MonoTests.System.Data DataView dv = new DataView (dt1); DataRowView dvr = dv [0]; DataView v = dvr.CreateChildView (dr); - AssertEquals ("RowFilter", "", v.RowFilter); - AssertEquals ("Sort", "", v.Sort); + Assert.AreEqual ("", v.RowFilter, "RowFilter"); + Assert.AreEqual ("", v.Sort, "Sort"); } [Test] @@ -110,12 +110,12 @@ namespace MonoTests.System.Data DataView dv = new DataView (dt); DataRowView drv = dv [0]; dt.Rows [0].BeginEdit (); - AssertEquals ("DataView.Item", true, drv.IsEdit); + Assert.AreEqual (true, drv.IsEdit, "DataView.Item"); drv = dv.AddNew (); drv.Row ["col"] = "test"; drv.Row.CancelEdit (); - AssertEquals ("AddNew", false, drv.IsEdit); + Assert.AreEqual (false, drv.IsEdit, "AddNew"); } [Test] @@ -127,7 +127,7 @@ namespace MonoTests.System.Data DataView dv = new DataView (dt); DataRowView drv = dv [0]; dt.Rows [0].BeginEdit (); - AssertEquals ("DataView.Item", "val", drv ["col"]); + Assert.AreEqual ("val", drv ["col"], "DataView.Item"); } [Test] @@ -153,18 +153,18 @@ namespace MonoTests.System.Data dt.Rows.Add (new object [] {1}); DataView dv = new DataView (dt); DataRowView drv = dv.AddNew (); - AssertEquals (DataRowVersion.Current, drv.RowVersion); - AssertEquals (DataRowVersion.Current, dv [0].RowVersion); + Assert.AreEqual (DataRowVersion.Current, drv.RowVersion); + Assert.AreEqual (DataRowVersion.Current, dv [0].RowVersion); drv ["col"] = "mod"; - AssertEquals (DataRowVersion.Current, drv.RowVersion); - AssertEquals (DataRowVersion.Current, dv [0].RowVersion); + Assert.AreEqual (DataRowVersion.Current, drv.RowVersion); + Assert.AreEqual (DataRowVersion.Current, dv [0].RowVersion); dt.AcceptChanges (); - AssertEquals (DataRowVersion.Current, drv.RowVersion); - AssertEquals (DataRowVersion.Current, dv [0].RowVersion); + Assert.AreEqual (DataRowVersion.Current, drv.RowVersion); + Assert.AreEqual (DataRowVersion.Current, dv [0].RowVersion); drv.EndEdit (); dv [0].EndEdit (); - AssertEquals (DataRowVersion.Current, drv.RowVersion); - AssertEquals (DataRowVersion.Current, dv [0].RowVersion); + Assert.AreEqual (DataRowVersion.Current, drv.RowVersion); + Assert.AreEqual (DataRowVersion.Current, dv [0].RowVersion); } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest.cs b/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest.cs index 05d0eddc7fb..bf34b01d1c6 100644 --- a/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataTableCollectionTest.cs @@ -37,7 +37,7 @@ namespace MonoTests.System.Data { [TestFixture] - public class DataTableCollectionTest : Assertion { + public class DataTableCollectionTest { // common variables here private DataSet [] _dataset; private DataTable [] _tables; @@ -76,11 +76,11 @@ namespace MonoTests.System.Data foreach( DataTable table in tbcol ) { - AssertEquals("test#1",_tables[i].TableName,table.TableName); + Assert.AreEqual(_tables[i].TableName,table.TableName,"test#1"); j=0; foreach( DataColumn column in table.Columns ) { - AssertEquals("test#2",_tables[i].Columns[j].ColumnName,column.ColumnName); + Assert.AreEqual(_tables[i].Columns[j].ColumnName,column.ColumnName,"test#2"); j++; } i++; @@ -90,11 +90,11 @@ namespace MonoTests.System.Data i=0; foreach( DataTable table in tbcol ) { - AssertEquals("test#3",_tables[i].TableName,table.TableName); + Assert.AreEqual(_tables[i].TableName,table.TableName,"test#3"); j=0; foreach( DataColumn column in table.Columns ) { - AssertEquals("test#4",_tables[i].Columns[j].ColumnName,column.ColumnName); + Assert.AreEqual(_tables[i].Columns[j].ColumnName,column.ColumnName,"test#4"); j++; } i++; @@ -143,9 +143,9 @@ namespace MonoTests.System.Data { DataTableCollection tbcol = _dataset[0].Tables; tbcol.Add(_tables[0]); - AssertEquals("test#1",1, tbcol.Count); + Assert.AreEqual(1,tbcol.Count, "test#1"); tbcol.Add(_tables[1]); - AssertEquals("test#2",2, tbcol.Count); + Assert.AreEqual(2,tbcol.Count, "test#2"); } [Test] @@ -159,11 +159,11 @@ namespace MonoTests.System.Data i=0; foreach( DataTable table in tbcol ) { - AssertEquals("test#1",_tables[i].TableName,table.TableName); + Assert.AreEqual(_tables[i].TableName,table.TableName,"test#1"); j=0; foreach( DataColumn column in table.Columns ) { - AssertEquals("test#2",_tables[i].Columns[j].ColumnName,column.ColumnName); + Assert.AreEqual(_tables[i].Columns[j].ColumnName,column.ColumnName,"test#2"); j++; } i++; @@ -179,11 +179,11 @@ namespace MonoTests.System.Data tbcol.AddRange(_tables); DataTable tbl = null; /* checking for a recently input table, expecting true */ - AssertEquals("test#1",true,tbcol.CanRemove(_tables[0])); + Assert.AreEqual(true,tbcol.CanRemove(_tables[0]),"test#1"); /* trying to check with a null reference, expecting false */ - AssertEquals("test#2",false,tbcol.CanRemove(tbl)); + Assert.AreEqual(false,tbcol.CanRemove(tbl),"test#2"); /* trying to check with a table that does not exist in collection, expecting false */ - AssertEquals("test#3",false,tbcol.CanRemove(new DataTable("newTable"))); + Assert.AreEqual(false,tbcol.CanRemove(new DataTable("newTable")),"test#3"); } [Test] @@ -197,27 +197,27 @@ namespace MonoTests.System.Data /* removing a recently added table */ int count = tbcol.Count; tbcol.Remove(_tables[0]); - AssertEquals("test#1",count-1,tbcol.Count); + Assert.AreEqual(count-1,tbcol.Count,"test#1"); DataTable tbl = null; /* removing a null reference. must generate an Exception */ try { tbcol.Remove(tbl); - Fail("Err:: tbcol.Rmove(null) must fail"); + Assert.Fail("Err:: tbcol.Rmove(null) must fail"); } catch(Exception e) { - AssertEquals ("test#2", typeof (ArgumentNullException), e.GetType()); + Assert.AreEqual (typeof (ArgumentNullException), e.GetType(), "test#2"); } /* removing a table that is not there in collection */ try { tbcol.Remove(new DataTable("newTable")); - Fail("Err:: cannot remove a table that is not there in collection"); + Assert.Fail("Err:: cannot remove a table that is not there in collection"); } catch(Exception e) { - AssertEquals ("test#3", typeof (ArgumentException), e.GetType()); + Assert.AreEqual (typeof (ArgumentException), e.GetType(), "test#3"); } } @@ -227,11 +227,11 @@ namespace MonoTests.System.Data DataTableCollection tbcol = _dataset[0].Tables; tbcol.Add(_tables[0]); tbcol.Clear(); - AssertEquals("Test#1",0,tbcol.Count); + Assert.AreEqual(0,tbcol.Count,"Test#1"); tbcol.AddRange(new DataTable[] {_tables[0],_tables[1]}); tbcol.Clear(); - AssertEquals("Test#2",0,tbcol.Count); + Assert.AreEqual(0,tbcol.Count,"Test#2"); } [Test] public void Contains() @@ -242,11 +242,11 @@ namespace MonoTests.System.Data tbcol.AddRange(_tables); string tblname = ""; /* checking for a recently input table, expecting true */ - AssertEquals("test#1",true,tbcol.Contains(_tables[0].TableName)); + Assert.AreEqual(true,tbcol.Contains(_tables[0].TableName),"test#1"); /* trying to check with a empty string, expecting false */ - AssertEquals("test#2",false,tbcol.Contains(tblname)); + Assert.AreEqual(false,tbcol.Contains(tblname),"test#2"); /* trying to check for a table that donot exist, expecting false */ - AssertEquals("test#3",false,tbcol.Contains("InvalidTableName")); + Assert.AreEqual(false,tbcol.Contains("InvalidTableName"),"test#3"); } [Test] @@ -261,21 +261,21 @@ namespace MonoTests.System.Data DataTable [] array = new DataTable[4]; /* copying to the beginning of the array */ tbcol.CopyTo(array,0); - AssertEquals ("test#01", 4, array.Length); - AssertEquals ("test#02", "Table1", array[0].TableName); - AssertEquals ("test#03", "Table2", array[1].TableName); - AssertEquals ("test#04", "Table3", array[2].TableName); - AssertEquals ("test#05", "Table4", array[3].TableName); + Assert.AreEqual (4, array.Length, "test#01"); + Assert.AreEqual ("Table1", array[0].TableName, "test#02"); + Assert.AreEqual ("Table2", array[1].TableName, "test#03"); + Assert.AreEqual ("Table3", array[2].TableName, "test#04"); + Assert.AreEqual ("Table4", array[3].TableName, "test#05"); /* copying with in a array */ DataTable [] array1 = new DataTable[6]; tbcol.CopyTo(array1,2); - AssertEquals("test#06",null,array1[0]); - AssertEquals("test#07",null,array1[1]); - AssertEquals("test#08","Table1",array1[2].TableName); - AssertEquals("test#09","Table2",array1[3].TableName); - AssertEquals("test#10","Table3",array1[4].TableName); - AssertEquals("test#11","Table4",array1[5].TableName); + Assert.AreEqual(null,array1[0],"test#06"); + Assert.AreEqual(null,array1[1],"test#07"); + Assert.AreEqual("Table1",array1[2].TableName,"test#08"); + Assert.AreEqual("Table2",array1[3].TableName,"test#09"); + Assert.AreEqual("Table3",array1[4].TableName,"test#10"); + Assert.AreEqual("Table4",array1[5].TableName,"test#11"); } [Test] public void Equals() @@ -287,16 +287,16 @@ namespace MonoTests.System.Data tbcol2.Add(_tables[1]); tbcol3 = tbcol1; - AssertEquals("test#1",true,tbcol1.Equals(tbcol1)); - AssertEquals("test#2",true,tbcol1.Equals(tbcol3)); - AssertEquals("test#3",true,tbcol3.Equals(tbcol1)); + Assert.AreEqual(true,tbcol1.Equals(tbcol1),"test#1"); + Assert.AreEqual(true,tbcol1.Equals(tbcol3),"test#2"); + Assert.AreEqual(true,tbcol3.Equals(tbcol1),"test#3"); - AssertEquals("test#4",false,tbcol1.Equals(tbcol2)); - AssertEquals("test#5",false,tbcol2.Equals(tbcol1)); + Assert.AreEqual(false,tbcol1.Equals(tbcol2),"test#4"); + Assert.AreEqual(false,tbcol2.Equals(tbcol1),"test#5"); - AssertEquals("test#6",true,Object.Equals(tbcol1,tbcol3)); - AssertEquals("test#7",true,Object.Equals(tbcol1,tbcol1)); - AssertEquals("test#8",false,Object.Equals(tbcol1,tbcol2)); + Assert.AreEqual(true,Object.Equals(tbcol1,tbcol3),"test#6"); + Assert.AreEqual(true,Object.Equals(tbcol1,tbcol1),"test#7"); + Assert.AreEqual(false,Object.Equals(tbcol1,tbcol2),"test#8"); } [Test] public void IndexOf() @@ -306,16 +306,16 @@ namespace MonoTests.System.Data tbcol.Add("table1"); tbcol.Add("table2"); - AssertEquals("test#1",0,tbcol.IndexOf(_tables[0])); - AssertEquals("test#2",-1,tbcol.IndexOf(_tables[1])); - AssertEquals("test#3",1,tbcol.IndexOf("table1")); - AssertEquals("test#4",2,tbcol.IndexOf("table2")); + Assert.AreEqual(0,tbcol.IndexOf(_tables[0]),"test#1"); + Assert.AreEqual(-1,tbcol.IndexOf(_tables[1]),"test#2"); + Assert.AreEqual(1,tbcol.IndexOf("table1"),"test#3"); + Assert.AreEqual(2,tbcol.IndexOf("table2"),"test#4"); - AssertEquals("test#5",0,tbcol.IndexOf(tbcol[0])); - AssertEquals("test#6",1,tbcol.IndexOf(tbcol[1])); - AssertEquals("test#7",-1,tbcol.IndexOf("_noTable_")); + Assert.AreEqual(0,tbcol.IndexOf(tbcol[0]),"test#5"); + Assert.AreEqual(1,tbcol.IndexOf(tbcol[1]),"test#6"); + Assert.AreEqual(-1,tbcol.IndexOf("_noTable_"),"test#7"); DataTable tb = new DataTable("new_table"); - AssertEquals("test#8",-1,tbcol.IndexOf(tb)); + Assert.AreEqual(-1,tbcol.IndexOf(tb),"test#8"); } [Test] @@ -328,7 +328,7 @@ namespace MonoTests.System.Data try { tbcol.RemoveAt(-1); - Fail("the index was out of bound: must have failed"); + Assert.Fail("the index was out of bound: must have failed"); } catch(IndexOutOfRangeException e) { @@ -336,15 +336,15 @@ namespace MonoTests.System.Data try { tbcol.RemoveAt(101); - Fail("the index was out of bound: must have failed"); + Assert.Fail("the index was out of bound: must have failed"); } catch(IndexOutOfRangeException e) { } tbcol.RemoveAt (1); - AssertEquals ("test#5", 1, tbcol.Count); + Assert.AreEqual (1, tbcol.Count, "test#5"); tbcol.RemoveAt (0); - AssertEquals ("test#6", 0, tbcol.Count); + Assert.AreEqual (0, tbcol.Count, "test#6"); } [Test] @@ -354,46 +354,46 @@ namespace MonoTests.System.Data tbcol.Add("Table1"); tbcol.Add("Table2"); tbcol.Add("Table3"); - AssertEquals("test#1","System.Data.DataTableCollection",tbcol.ToString()); + Assert.AreEqual("System.Data.DataTableCollection",tbcol.ToString(),"test#1"); } [Test] public void TableDataSetNamespaces () { DataTable dt = new DataTable ("dt1"); - AssertEquals ("#1-1", String.Empty, dt.Namespace); - AssertNull ("#1-2", dt.DataSet); + Assert.AreEqual (String.Empty, dt.Namespace, "#1-1"); + Assert.IsNull (dt.DataSet, "#1-2"); DataSet ds1 = new DataSet ("ds1"); ds1.Tables.Add (dt); - AssertEquals ("#2-1", String.Empty, dt.Namespace); - AssertEquals ("#2-2", ds1, dt.DataSet); + Assert.AreEqual (String.Empty, dt.Namespace, "#2-1"); + Assert.AreEqual (ds1, dt.DataSet, "#2-2"); ds1.Namespace = "ns1"; - AssertEquals ("#3", "ns1", dt.Namespace); + Assert.AreEqual ("ns1", dt.Namespace, "#3"); // back to null again ds1.Tables.Remove (dt); - AssertEquals ("#4-1", String.Empty, dt.Namespace); - AssertNull ("#4-2", dt.DataSet); + Assert.AreEqual (String.Empty, dt.Namespace, "#4-1"); + Assert.IsNull (dt.DataSet, "#4-2"); // This table is being added to _already namespaced_ // dataset. dt = new DataTable ("dt2"); ds1.Tables.Add (dt); - AssertEquals ("#5-1", "ns1", dt.Namespace); - AssertEquals ("#5-2", ds1, dt.DataSet); + Assert.AreEqual ("ns1", dt.Namespace, "#5-1"); + Assert.AreEqual (ds1, dt.DataSet, "#5-2"); ds1.Tables.Remove (dt); - AssertEquals ("#6-1", String.Empty, dt.Namespace); - AssertNull ("#6-2", dt.DataSet); + Assert.AreEqual (String.Empty, dt.Namespace, "#6-1"); + Assert.IsNull (dt.DataSet, "#6-2"); DataSet ds2 = new DataSet ("ds2"); ds2.Namespace = "ns2"; ds2.Tables.Add (dt); - AssertEquals ("#7-1", "ns2", dt.Namespace); - AssertEquals ("#7-2", ds2, dt.DataSet); + Assert.AreEqual ("ns2", dt.Namespace, "#7-1"); + Assert.AreEqual (ds2, dt.DataSet, "#7-2"); } } } diff --git a/mcs/class/System.Data/Test/System.Data/DataViewManagerTest.cs b/mcs/class/System.Data/Test/System.Data/DataViewManagerTest.cs index 57b5eb30846..392f9b0d4f4 100644 --- a/mcs/class/System.Data/Test/System.Data/DataViewManagerTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataViewManagerTest.cs @@ -36,7 +36,7 @@ using System.ComponentModel; namespace MonoTests.System.Data { [TestFixture] - public class DataViewManagerTest : Assertion + public class DataViewManagerTest { [Test] public void Ctor () @@ -46,40 +46,40 @@ namespace MonoTests.System.Data string deleted = @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter="""" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>"; DataViewManager m = new DataViewManager (null); - AssertNull (m.DataSet); - AssertEquals ("", m.DataViewSettingCollectionString); - AssertNotNull (m.DataViewSettings); + Assert.IsNull (m.DataSet); + Assert.AreEqual ("", m.DataViewSettingCollectionString); + Assert.IsNotNull (m.DataViewSettings); DataSet ds = new DataSet ("ds"); m.DataSet = ds; - AssertEquals ("default#1", defaultString, - m.DataViewSettingCollectionString); + Assert.AreEqual (defaultString, m.DataViewSettingCollectionString, + "default#1"); DataSet ds2 = new DataSet ("ds2"); - AssertEquals ("default#2", defaultString, - ds.DefaultViewManager.DataViewSettingCollectionString); + Assert.AreEqual (defaultString, ds.DefaultViewManager.DataViewSettingCollectionString, + "default#2"); DataTable dt2_1 = new DataTable ("table2-1"); dt2_1.Namespace ="urn:foo"; // It is ignored though. ds2.Tables.Add (dt2_1); m.DataSet = ds2; - AssertEquals ("#3", current, m.DataViewSettingCollectionString); + Assert.AreEqual (current, m.DataViewSettingCollectionString, "#3"); // Note that " Deleted " is trimmed. m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter=' Deleted '/></DataViewSettingCollectionString>"; - AssertEquals ("#4", deleted, m.DataViewSettingCollectionString); + Assert.AreEqual (deleted, m.DataViewSettingCollectionString, "#4"); m.DataSet = ds2; //resets modified string. - AssertEquals ("#5", current, m.DataViewSettingCollectionString); + Assert.AreEqual (current, m.DataViewSettingCollectionString, "#5"); m.DataViewSettingCollectionString = @"<DataViewSettingCollectionString><table2-1 Sort='' RowFilter='' RowStateFilter='Deleted'/></DataViewSettingCollectionString>"; // it does not clear anything. m.DataViewSettingCollectionString = "<DataViewSettingCollectionString/>"; - AssertEquals ("#6", deleted, m.DataViewSettingCollectionString); + Assert.AreEqual (deleted, m.DataViewSettingCollectionString, "#6"); // text node is not rejected (ignored). // RowFilter is not examined. m.DataViewSettingCollectionString = "<DataViewSettingCollectionString>blah<table2-1 RowFilter='a=b' ApplyDefaultSort='true' /></DataViewSettingCollectionString>"; // LAMESPEC: MS.NET ignores ApplyDefaultSort. -// AssertEquals ("#7", @"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter=""a=b"" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>", m.DataViewSettingCollectionString); +// Assert.AreEqual (@"<DataViewSettingCollectionString><table2-1 Sort="""" RowFilter=""a=b"" RowStateFilter=""Deleted""/></DataViewSettingCollectionString>", m.DataViewSettingCollectionString, "#7"); } [Test] diff --git a/mcs/class/System.Data/Test/System.Data/DataViewTest.cs b/mcs/class/System.Data/Test/System.Data/DataViewTest.cs index 4be1824f667..8829819a450 100644 --- a/mcs/class/System.Data/Test/System.Data/DataViewTest.cs +++ b/mcs/class/System.Data/Test/System.Data/DataViewTest.cs @@ -42,7 +42,7 @@ using System.IO; namespace MonoTests.System.Data { [TestFixture] - public class DataViewTest : Assertion + public class DataViewTest { DataTable dataTable; DataView dataView; @@ -145,7 +145,7 @@ namespace MonoTests.System.Data dv.Sort = "abc"; dv.Sort = string.Empty; dv.Sort = "abc"; - AssertEquals ("test#01", "abc", dv.Sort); + Assert.AreEqual ("abc", dv.Sort, "test#01"); } [Test] @@ -154,24 +154,24 @@ namespace MonoTests.System.Data DataView dv1,dv2,dv3; dv1 = new DataView (); // AssertEquals ("test#01",null,dv1.Table); - AssertEquals ("test#02",true,dv1.AllowNew); - AssertEquals ("test#03",true,dv1.AllowEdit); - AssertEquals ("test#04",true,dv1.AllowDelete); - AssertEquals ("test#05",false,dv1.ApplyDefaultSort); - AssertEquals ("test#06",string.Empty,dv1.RowFilter); - AssertEquals ("test#07",DataViewRowState.CurrentRows,dv1.RowStateFilter); - AssertEquals ("test#08",string.Empty,dv1.Sort); + Assert.AreEqual (true,dv1.AllowNew,"test#02");; + Assert.AreEqual (true,dv1.AllowEdit,"test#03");; + Assert.AreEqual (true,dv1.AllowDelete,"test#04");; + Assert.AreEqual (false,dv1.ApplyDefaultSort,"test#05");; + Assert.AreEqual (string.Empty,dv1.RowFilter,"test#06");; + Assert.AreEqual (DataViewRowState.CurrentRows,dv1.RowStateFilter,"test#07");; + Assert.AreEqual (string.Empty,dv1.Sort,"test#08");; dv2 = new DataView (dataTable); - AssertEquals ("test#09","itemTable",dv2.Table.TableName); - AssertEquals ("test#10",string.Empty,dv2.Sort); - AssertEquals ("test#11",false,dv2.ApplyDefaultSort); - AssertEquals ("test#12",dataTable.Rows[0],dv2[0].Row); + Assert.AreEqual ("itemTable",dv2.Table.TableName,"test#09");; + Assert.AreEqual (string.Empty,dv2.Sort,"test#10");; + Assert.AreEqual (false,dv2.ApplyDefaultSort,"test#11");; + Assert.AreEqual (dataTable.Rows[0],dv2[0].Row,"test#12");; dv3 = new DataView (dataTable,"","itemId DESC",DataViewRowState.CurrentRows); - AssertEquals ("test#13","",dv3.RowFilter); - AssertEquals ("test#14","itemId DESC",dv3.Sort); - AssertEquals ("test#15",DataViewRowState.CurrentRows,dv3.RowStateFilter); + Assert.AreEqual ("",dv3.RowFilter,"test#13");; + Assert.AreEqual ("itemId DESC",dv3.Sort,"test#14");; + Assert.AreEqual (DataViewRowState.CurrentRows,dv3.RowStateFilter,"test#15");; //AssertEquals ("test#16",dataTable.Rows.[(dataTable.Rows.Count-1)],dv3[0]); } @@ -179,20 +179,20 @@ namespace MonoTests.System.Data public void TestValue () { DataView TestView = new DataView (dataTable); - Assertion.AssertEquals ("Dv #1", "item 1", TestView [0]["itemId"]); + Assert.AreEqual ("item 1", TestView [0]["itemId"], "Dv #1"); } [Test] public void TestCount () { DataView TestView = new DataView (dataTable); - Assertion.AssertEquals ("Dv #3", 5, TestView.Count); + Assert.AreEqual (5, TestView.Count, "Dv #3"); } [Test] public void AllowNew () { - AssertEquals ("test#01",true,dataView.AllowNew); + Assert.AreEqual (true, dataView.AllowNew, "test#01"); } [Test] @@ -203,7 +203,7 @@ namespace MonoTests.System.Data dataView.ApplyDefaultSort = true; // dataView.Sort = "itemName"; // AssertEquals ("test#01","item 1",dataView[0]["itemId"]); - AssertEquals ("test#02",ListChangedType.Reset,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.Reset,listChangedArgs.ListChangedType, "test#02"); // UnComment the line below to see if dataView is sorted // PrintTableOrView (dataView,"* OnApplyDefaultSort"); } @@ -212,7 +212,7 @@ namespace MonoTests.System.Data public void RowStateFilter () { dataView.RowStateFilter = DataViewRowState.Deleted; - AssertEquals ("test#01",ListChangedType.Reset,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.Reset,listChangedArgs.ListChangedType, "test#01"); } [Test] @@ -239,16 +239,16 @@ namespace MonoTests.System.Data dataView [0] ["col1"] = -1; dataView.RowStateFilter = DataViewRowState.ModifiedOriginal; v = dataView [0] [0].ToString (); - AssertEquals ("ModifiedOriginal.Count", 1, dataView.Count); - AssertEquals ("ModifiedOriginal.Value", "1", v); + Assert.AreEqual (1, dataView.Count, "ModifiedOriginal.Count"); + Assert.AreEqual ("1", v, "ModifiedOriginal.Value"); // Deleting the row dataView.Delete (0); dataView.RowStateFilter = DataViewRowState.Deleted; v = dataView [0] [0].ToString (); - AssertEquals ("Deleted.Count", 1, dataView.Count); - AssertEquals ("Deleted.Value", "1", v); + Assert.AreEqual (1, dataView.Count, "Deleted.Count"); + Assert.AreEqual ("1", v, "Deleted.Value"); } //xamarin bug #18898 # / novell bug #595899 @@ -276,10 +276,10 @@ namespace MonoTests.System.Data another_new_row[0] = "9"; another_new_row[1] = "10"; - AssertEquals ("#1", dv[2][0], "9"); + Assert.AreEqual (dv[2][0], "9", "#1"); //This should not throw a System.Data.VersionNotFoundException: "There is no Proposed data to accces" - AssertEquals ("#1", dv[1][0], "7"); + Assert.AreEqual (dv[1][0], "7", "#1"); } @@ -288,7 +288,7 @@ namespace MonoTests.System.Data { DataView dataview = new DataView (); PropertyDescriptorCollection col = ((ITypedList)dataview).GetItemProperties (null); - AssertEquals ("1", 0, col.Count); + Assert.AreEqual (0, col.Count, "1"); } #region Sort Tests @@ -296,7 +296,7 @@ namespace MonoTests.System.Data public void SortListChangedTest () { dataView.Sort = "itemName DESC"; - AssertEquals ("test#01",ListChangedType.Reset,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.Reset,listChangedArgs.ListChangedType, "test#01"); // UnComment the line below to see if dataView is sorted // PrintTableOrView (dataView); } @@ -338,60 +338,60 @@ namespace MonoTests.System.Data DataView dataView = dataTable.DefaultView; string s = "Default sorting: "; - AssertEquals (s + "First entry has wrong item", 1, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 0, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 3, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 2, dataView[3][0]); + Assert.AreEqual (1, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (0, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (3, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (2, dataView[3][0], s + "Fourth entry has wrong item"); s = "Ascending sorting 1: "; dataView.Sort = "itemId ASC"; - AssertEquals (s + "First entry has wrong item", 0, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 1, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 2, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 3, dataView[3][0]); + Assert.AreEqual (0, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (1, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (2, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (3, dataView[3][0], s + "Fourth entry has wrong item"); // bug #77104 (2-5) s = "Ascending sorting 2: "; dataView.Sort = "itemId ASC"; - AssertEquals (s + "First entry has wrong item", 0, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 1, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 2, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 3, dataView[3][0]); + Assert.AreEqual (0, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (1, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (2, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (3, dataView[3][0], s + "Fourth entry has wrong item"); s = "Ascending sorting 3: "; dataView.Sort = "[itemId] ASC"; - AssertEquals (s + "First entry has wrong item", 0, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 1, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 2, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 3, dataView[3][0]); + Assert.AreEqual (0, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (1, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (2, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (3, dataView[3][0], s + "Fourth entry has wrong item"); s = "Ascending sorting 4: "; dataView.Sort = "[itemId] ASC"; - AssertEquals (s + "First entry has wrong item", 0, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 1, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 2, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 3, dataView[3][0]); + Assert.AreEqual (0, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (1, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (2, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (3, dataView[3][0], s + "Fourth entry has wrong item"); s = "Ascending sorting 5: "; try { dataView.Sort = "itemId \tASC"; - AssertEquals (s + "Tab cannot be a separator" , true, false); + Assert.AreEqual (true, false, s + "Tab cannot be a separator"); }catch (IndexOutOfRangeException e) { } s = "Descending sorting : "; dataView.Sort = "itemId DESC"; - AssertEquals (s + "First entry has wrong item", 3, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 2, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 1, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 0, dataView[3][0]); + Assert.AreEqual (3, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (2, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (1, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (0, dataView[3][0], s + "Fourth entry has wrong item"); s = "Reverted to default sorting: "; dataView.Sort = null; - AssertEquals (s + "First entry has wrong item", 1, dataView[0][0]); - AssertEquals (s + "Second entry has wrong item", 0, dataView[1][0]); - AssertEquals (s + "Third entry has wrong item", 3, dataView[2][0]); - AssertEquals (s + "Fourth entry has wrong item", 2, dataView[3][0]); + Assert.AreEqual (1, dataView[0][0], s + "First entry has wrong item"); + Assert.AreEqual (0, dataView[1][0], s + "Second entry has wrong item"); + Assert.AreEqual (3, dataView[2][0], s + "Third entry has wrong item"); + Assert.AreEqual (2, dataView[3][0], s + "Fourth entry has wrong item"); } #endregion // Sort Tests @@ -409,21 +409,21 @@ namespace MonoTests.System.Data { dataView.AllowNew = true; DataRowView drv = dataView.AddNew (); - AssertEquals ("test#01",ListChangedType.ItemAdded,listChangedArgs.ListChangedType); - AssertEquals ("test#02",-1,listChangedArgs.OldIndex); - AssertEquals ("test#03",5,listChangedArgs.NewIndex); - AssertEquals ("test#04",drv["itemName"],dataView [dataView.Count - 1]["itemName"]); + Assert.AreEqual (ListChangedType.ItemAdded,listChangedArgs.ListChangedType, "test#01"); + Assert.AreEqual (-1,listChangedArgs.OldIndex, "test#02"); + Assert.AreEqual (5,listChangedArgs.NewIndex, "test#03"); + Assert.AreEqual (drv["itemName"],dataView [dataView.Count - 1]["itemName"], "test#04"); listChangedArgs = null; drv["itemId"] = "item " + 1001; drv["itemName"] = "name " + rndm.Next(); drv["itemPrice"] = "Rs. " + (rndm.Next() % 1000); drv["itemCategory"] = "Cat " + ((rndm.Next() % 10) + 1); // Actually no events are arisen when items are set. - AssertNull ("test#05", listChangedArgs); + Assert.IsNull (listChangedArgs, "test#05"); drv.CancelEdit (); - AssertEquals ("test#06",ListChangedType.ItemDeleted,listChangedArgs.ListChangedType); - AssertEquals ("test#07",-1,listChangedArgs.OldIndex); - AssertEquals ("test#08",5,listChangedArgs.NewIndex); + Assert.AreEqual (ListChangedType.ItemDeleted,listChangedArgs.ListChangedType, "test#06"); + Assert.AreEqual (-1,listChangedArgs.OldIndex, "test#07"); + Assert.AreEqual (5,listChangedArgs.NewIndex, "test#08"); } [Test] @@ -439,15 +439,15 @@ namespace MonoTests.System.Data table.Columns.AddRange (new DataColumn[] {col1,col2}); dv.Table = table; - AssertNull ("#1", dv.Table); + Assert.IsNull (dv.Table, "#1"); dv.EndInit (); - AssertNull ("#2", dv.Table); // still. - AssertEquals ("#3", 0, table.Columns.Count); + Assert.IsNull (dv.Table, "#2"); // still. + Assert.AreEqual (0, table.Columns.Count, "#3"); table.EndInit (); - AssertEquals ("#5", table, dv.Table); - AssertEquals ("#4", 2, table.Columns.Count); + Assert.AreEqual (table, dv.Table, "#4"); + Assert.AreEqual (2, table.Columns.Count, "#5"); } private bool dvInitialized; @@ -472,19 +472,19 @@ namespace MonoTests.System.Data table.Columns.AddRange (new DataColumn[] {col1,col2}); dv.Table = table; - AssertNull ("#1", dv.Table); + Assert.IsNull (dv.Table, "#1"); dv.EndInit (); - AssertNull ("#2", dv.Table); - AssertEquals ("#3", 0, table.Columns.Count); + Assert.IsNull (dv.Table, "#2"); + Assert.AreEqual (0, table.Columns.Count, "#3"); table.EndInit (); dv.Initialized -= new EventHandler (OnDataViewInitialized); // this should not be unregistered before table.EndInit(). - AssertEquals ("#4", 2, table.Columns.Count); - AssertEquals ("#6", table, dv.Table); - AssertEquals ("DataViewInitialized #5", true, dvInitialized); + Assert.AreEqual (2, table.Columns.Count, "#4"); + Assert.AreEqual (table, dv.Table, "#6"); + Assert.AreEqual (true, dvInitialized, "DataViewInitialized #5"); } [Test] @@ -503,21 +503,21 @@ namespace MonoTests.System.Data randInt = rndm.Next () % rowCount; dataView.Sort = "itemId"; drv = dataView [randInt]; - AssertEquals ("test#01",randInt,dataView.Find (drv ["itemId"])); + Assert.AreEqual (randInt,dataView.Find (drv ["itemId"]), "test#01"); dataView.Sort = "itemId DESC"; drv = dataView [randInt]; - AssertEquals ("test#02",randInt,dataView.Find (drv ["itemId"])); + Assert.AreEqual (randInt,dataView.Find (drv ["itemId"]), "test#02"); dataView.Sort = "itemId, itemName"; drv = dataView [randInt]; object [] keys = new object [2]; keys [0] = drv ["itemId"]; keys [1] = drv ["itemName"]; - AssertEquals ("test#03",randInt,dataView.Find (keys)); + Assert.AreEqual (randInt,dataView.Find (keys), "test#03"); dataView.Sort = "itemId"; - AssertEquals ("test#04",-1,dataView.Find("no item")); + Assert.AreEqual (-1,dataView.Find("no item"), "test#04"); } @@ -540,7 +540,7 @@ namespace MonoTests.System.Data [Test] public void ToStringTest () { - AssertEquals ("test#01","System.Data.DataView",dataView.ToString()); + Assert.AreEqual ("System.Data.DataView",dataView.ToString(), "test#01"); } [Test] @@ -556,38 +556,38 @@ namespace MonoTests.System.Data dataTable.Rows.Add(dr); //PrintTableOrView(dataView, "ItemAdded"); - AssertEquals ("test#01",ListChangedType.ItemAdded,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.ItemAdded,listChangedArgs.ListChangedType, "test#01"); listChangedArgs = null; dr ["itemId"] = "aitem 0"; // PrintTableOrView(dataView, "ItemChanged"); - AssertEquals ("test#02",ListChangedType.ItemChanged,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.ItemChanged,listChangedArgs.ListChangedType, "test#02"); listChangedArgs = null; dr ["itemId"] = "zitem 0"; // PrintTableOrView(dataView, "ItemMoved"); - AssertEquals ("test#03",ListChangedType.ItemMoved,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.ItemMoved,listChangedArgs.ListChangedType, "test#03"); listChangedArgs = null; dataTable.Rows.Remove (dr); // PrintTableOrView(dataView, "ItemDeleted"); - AssertEquals ("test#04",ListChangedType.ItemDeleted,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.ItemDeleted,listChangedArgs.ListChangedType, "test#04"); listChangedArgs = null; DataColumn dc5 = new DataColumn ("itemDesc"); dataTable.Columns.Add (dc5); // PrintTableOrView(dataView, "PropertyDescriptorAdded"); - AssertEquals ("test#05",ListChangedType.PropertyDescriptorAdded,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.PropertyDescriptorAdded,listChangedArgs.ListChangedType, "test#05"); listChangedArgs = null; dc5.ColumnName = "itemDescription"; // PrintTableOrView(dataView, "PropertyDescriptorChanged"); - // AssertEquals ("test#06",ListChangedType.PropertyDescriptorChanged,listChangedArgs.ListChangedType); + // Assert.AreEqual ("test#06",ListChangedType.PropertyDescriptorChanged,listChangedArgs.ListChangedType); listChangedArgs = null; dataTable.Columns.Remove (dc5); // PrintTableOrView(dataView, "PropertyDescriptorDeleted"); - AssertEquals ("test#07",ListChangedType.PropertyDescriptorDeleted,listChangedArgs.ListChangedType); + Assert.AreEqual (ListChangedType.PropertyDescriptorDeleted,listChangedArgs.ListChangedType, "test#07"); } [Test] @@ -596,8 +596,8 @@ namespace MonoTests.System.Data DataView TestView = new DataView (dataTable); TestView.Sort = "itemId"; DataRowView[] Result = TestView.FindRows ("item 3"); - Assertion.AssertEquals ("Dv #1", 1, Result.Length); - Assertion.AssertEquals ("Dv #2", "item 3", Result [0]["itemId"]); + Assert.AreEqual (1, Result.Length, "Dv #1"); + Assert.AreEqual ("item 3", Result [0]["itemId"], "Dv #2"); } [Test] @@ -642,7 +642,7 @@ namespace MonoTests.System.Data DataView TestView = new DataView (dataTable); TestView.Delete (0); DataRow r = TestView.Table.Rows [0]; - Assertion.Assert ("Dv #1", !((string)r ["itemId"] == "item 1")); + Assert.IsTrue (!((string)r ["itemId"] == "item 1"), "Dv #1"); } [Test] @@ -685,13 +685,13 @@ namespace MonoTests.System.Data DataView dataView = new DataView (dataset.Tables[0]); - AssertEquals ("before delete", 3, dataView.Count); + Assert.AreEqual (3, dataView.Count, "before delete"); dataView.AllowDelete = true; // Deleting the first row dataView.Delete (0); - AssertEquals ("before delete", 2, dataView.Count); + Assert.AreEqual (2, dataView.Count, "before delete"); } [Test] @@ -746,7 +746,7 @@ namespace MonoTests.System.Data eventWriter.Write (" ------" + dv.Count); DataRowView a3 = dv.AddNew (); - AssertEquals (reference, eventWriter.ToString ()); + Assert.AreEqual (reference, eventWriter.ToString ()); } [Test] @@ -766,7 +766,7 @@ table was set. dc2.ColumnName = "new_column_name"; - AssertEquals (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); + Assert.AreEqual (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); } private void ListChanged (object o, ListChangedEventArgs e) @@ -830,7 +830,7 @@ removed relation 2 ds.Relations.Remove (dr); eventWriter.WriteLine ("removed relation 2"); - AssertEquals (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); + Assert.AreEqual (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); } [Test] @@ -942,7 +942,7 @@ table changed. dv.Table = new DataTable ("table2"); eventWriter.WriteLine ("table changed."); - AssertEquals (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); + Assert.AreEqual (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); } [Test] @@ -982,7 +982,7 @@ table was set. dt.Columns.Add (""); eventWriter.WriteLine (" add a column with an empty name."); - AssertEquals (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); + Assert.AreEqual (result.Replace ("\r\n", "\n"), eventWriter.ToString ().Replace ("\r\n", "\n")); GC.KeepAlive (dv); } diff --git a/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest.cs b/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest.cs index 6e5d2a4df92..21742eb3aa3 100644 --- a/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest.cs +++ b/mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest.cs @@ -38,7 +38,7 @@ using System.Data; namespace MonoTests.System.Data { [TestFixture] - public class ForeignKeyConstraintTest : Assertion + public class ForeignKeyConstraintTest { private DataSet _ds; @@ -73,23 +73,23 @@ namespace MonoTests.System.Data { DataTable Table = _ds.Tables [0]; - AssertEquals ("test#01", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#01"); Table = _ds.Tables [1]; - AssertEquals ("test#02", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#02"); // ctor (string, DataColumn, DataColumn ForeignKeyConstraint Constraint = new ForeignKeyConstraint ("test", _ds.Tables [0].Columns [2], _ds.Tables [1].Columns [0]); Table = _ds.Tables [1]; Table.Constraints.Add (Constraint); - AssertEquals ("test#03", 1, Table.Constraints.Count); - AssertEquals ("test#04", "test", Table.Constraints [0].ConstraintName); - AssertEquals ("test#05", typeof (ForeignKeyConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#03"); + Assert.AreEqual ("test", Table.Constraints [0].ConstraintName, "test#04"); + Assert.AreEqual (typeof (ForeignKeyConstraint), Table.Constraints [0].GetType (), "test#05"); Table = _ds.Tables [0]; - AssertEquals ("test#06", 1, Table.Constraints.Count); - AssertEquals ("test#07", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#08", typeof (UniqueConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#06"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#07"); + Assert.AreEqual (typeof (UniqueConstraint), Table.Constraints [0].GetType (), "test#08"); } // Tests ctor (DataColumn, DataColumn) @@ -98,23 +98,23 @@ namespace MonoTests.System.Data { DataTable Table = _ds.Tables [0]; - AssertEquals ("test#01", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#01"); Table = _ds.Tables [1]; - AssertEquals ("test#02", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#02"); // ctor (string, DataColumn, DataColumn ForeignKeyConstraint Constraint = new ForeignKeyConstraint (_ds.Tables [0].Columns [2], _ds.Tables [1].Columns [0]); Table = _ds.Tables [1]; Table.Constraints.Add (Constraint); - AssertEquals ("test#03", 1, Table.Constraints.Count); - AssertEquals ("test#04", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#05", typeof (ForeignKeyConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#03"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#04"); + Assert.AreEqual (typeof (ForeignKeyConstraint), Table.Constraints [0].GetType (), "test#05"); Table = _ds.Tables [0]; - AssertEquals ("test#06", 1, Table.Constraints.Count); - AssertEquals ("test#07", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#08", typeof (UniqueConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#06"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#07"); + Assert.AreEqual (typeof (UniqueConstraint), Table.Constraints [0].GetType (), "test#08"); } // Test ctor (DataColumn [], DataColumn []) @@ -123,9 +123,9 @@ namespace MonoTests.System.Data { DataTable Table = _ds.Tables [0]; - AssertEquals ("test#01", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#01"); Table = _ds.Tables [1]; - AssertEquals ("test#02", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#02"); DataColumn [] Cols1 = new DataColumn [2]; Cols1 [0] = _ds.Tables [0].Columns [1]; @@ -139,14 +139,14 @@ namespace MonoTests.System.Data Table = _ds.Tables [1]; Table.Constraints.Add (Constraint); - AssertEquals ("test#03", 1, Table.Constraints.Count); - AssertEquals ("test#04", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#05", typeof (ForeignKeyConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#03"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#04"); + Assert.AreEqual (typeof (ForeignKeyConstraint), Table.Constraints [0].GetType (), "test#05"); Table = _ds.Tables [0]; - AssertEquals ("test#06", 1, Table.Constraints.Count); - AssertEquals ("test#07", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#08", typeof (UniqueConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#06"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#07"); + Assert.AreEqual (typeof (UniqueConstraint), Table.Constraints [0].GetType (), "test#08"); } @@ -156,9 +156,9 @@ namespace MonoTests.System.Data { DataTable Table = _ds.Tables [0]; - AssertEquals ("test#01", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#01"); Table = _ds.Tables [1]; - AssertEquals ("test#02", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#02"); DataColumn [] Cols1 = new DataColumn [2]; Cols1 [0] = _ds.Tables [0].Columns [1]; @@ -172,14 +172,14 @@ namespace MonoTests.System.Data Table = _ds.Tables [1]; Table.Constraints.Add (Constraint); - AssertEquals ("test#03", 1, Table.Constraints.Count); - AssertEquals ("test#04", "Test", Table.Constraints [0].ConstraintName); - AssertEquals ("test#05", typeof (ForeignKeyConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#03"); + Assert.AreEqual ("Test", Table.Constraints [0].ConstraintName, "test#04"); + Assert.AreEqual (typeof (ForeignKeyConstraint), Table.Constraints [0].GetType (), "test#05"); Table = _ds.Tables [0]; - AssertEquals ("test#06", 1, Table.Constraints.Count); - AssertEquals ("test#07", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#08", typeof (UniqueConstraint), Table.Constraints [0].GetType ()); + Assert.AreEqual (1, Table.Constraints.Count, "test#06"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#07"); + Assert.AreEqual (typeof (UniqueConstraint), Table.Constraints [0].GetType (), "test#08"); } [Test] @@ -211,7 +211,7 @@ namespace MonoTests.System.Data ForeignKeyConstraint fkc = new ForeignKeyConstraint ("hello world", parentTableName, parentColumnNames, childColumnNames, AcceptRejectRule.Cascade, Rule.Cascade, Rule.Cascade); // Assert that the Constraint object does not belong to any table yet try { DataTable tmp = fkc.Table; - Fail ("When table is null, get_Table causes an InvalidOperationException."); + Assert.Fail ("When table is null, get_Table causes an InvalidOperationException."); } catch (NullReferenceException) { // actually .NET throws this (bug) } catch (InvalidOperationException) { } @@ -234,9 +234,12 @@ namespace MonoTests.System.Data // OK - So AddRange() is the only way! table2.Constraints.AddRange (constraints); // After AddRange(), Check the properties of ForeignKeyConstraint object - Assertion.Assert("#A04", fkc.RelatedColumns [0].ColumnName.Equals ("col1")); Assertion.Assert("#A05", fkc.RelatedColumns [1].ColumnName.Equals ("col2")); Assertion.Assert("#A06", fkc.RelatedColumns [2].ColumnName.Equals ("col3")); Assertion.Assert("#A07", fkc.Columns [0].ColumnName.Equals ("col4")); - Assertion.Assert("#A08", fkc.Columns [1].ColumnName.Equals ("col5")); - Assertion.Assert("#A09", fkc.Columns [2].ColumnName.Equals ("col6")); + Assert.IsTrue(fkc.RelatedColumns [0].ColumnName.Equals ("col1"), "#A04"); + Assert.IsTrue(fkc.RelatedColumns [1].ColumnName.Equals ("col2"), "#A05"); + Assert.IsTrue(fkc.RelatedColumns [2].ColumnName.Equals ("col3"), "#A06"); + Assert.IsTrue(fkc.Columns [0].ColumnName.Equals ("col4"), "#A07"); + Assert.IsTrue(fkc.Columns [1].ColumnName.Equals ("col5"), "#A08"); + Assert.IsTrue(fkc.Columns [2].ColumnName.Equals ("col6"), "#A09"); #endif // Try to add columns with names which do not exist in the table parentColumnNames [2] = "noColumn"; @@ -255,7 +258,7 @@ namespace MonoTests.System.Data #if false // FIXME: Here this test crashes under MS.NET. // Check whether the child table really contains the foreign key constraint named "hello world" - Assertion.Assert("#A11 ", table2.Constraints.Contains ("hello world")); + Assert.IsTrue(table2.Constraints.Contains ("hello world"), "#A11 "); #endif } @@ -267,20 +270,20 @@ namespace MonoTests.System.Data { DataTable Table = _ds.Tables [0]; - AssertEquals ("test#01", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#01"); Table = _ds.Tables [1]; - AssertEquals ("test#02", 0, Table.Constraints.Count); + Assert.AreEqual (0, Table.Constraints.Count, "test#02"); ForeignKeyConstraint Constraint = new ForeignKeyConstraint ("Test", _ds.Tables [0].Columns [0], _ds.Tables [0].Columns [2]); Table = _ds.Tables [0]; Table.Constraints.Add (Constraint); - AssertEquals ("test#03", 2, Table.Constraints.Count); - AssertEquals ("test#04", "Constraint1", Table.Constraints [0].ConstraintName); - AssertEquals ("test#05", typeof (UniqueConstraint), Table.Constraints [0].GetType ()); - AssertEquals ("test#04", "Test", Table.Constraints [1].ConstraintName); - AssertEquals ("test#05", typeof (ForeignKeyConstraint), Table.Constraints [1].GetType ()); + Assert.AreEqual (2, Table.Constraints.Count, "test#03"); + Assert.AreEqual ("Constraint1", Table.Constraints [0].ConstraintName, "test#04"); + Assert.AreEqual (typeof (UniqueConstraint), Table.Constraints [0].GetType (), "test#05"); + Assert.AreEqual ("Test", Table.Constraints [1].ConstraintName, "test#04"); + Assert.AreEqual (typeof (ForeignKeyConstraint), Table.Constraints [1].GetType (), "test#05"); } @@ -297,45 +300,45 @@ namespace MonoTests.System.Data try { fkc = new ForeignKeyConstraint((DataColumn)null,(DataColumn)null); - Fail("Failed to throw ArgumentNullException."); + Assert.Fail("Assert.Failed to throw ArgumentNullException."); } catch (NullReferenceException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("A1: Wrong Exception type. " + exc.ToString()); + Assert.Fail("A1: Wrong Exception type. " + exc.ToString()); } //zero length collection try { fkc = new ForeignKeyConstraint(new DataColumn[]{},new DataColumn[]{}); - Fail("B1: Failed to throw ArgumentException."); + Assert.Fail("B1: Assert.Failed to throw ArgumentException."); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("A2: Wrong Exception type. " + exc.ToString()); + Assert.Fail("A2: Wrong Exception type. " + exc.ToString()); } //different datasets try { fkc = new ForeignKeyConstraint(_ds.Tables[0].Columns[0], localTable.Columns[0]); - Fail("Failed to throw InvalidOperationException."); + Assert.Fail("Assert.Failed to throw InvalidOperationException."); } catch (InvalidOperationException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("A3: Wrong Exception type. " + exc.ToString()); + Assert.Fail("A3: Wrong Exception type. " + exc.ToString()); } try { fkc = new ForeignKeyConstraint(_ds.Tables[0].Columns[0], localTable.Columns[1]); - Fail("Failed to throw InvalidConstraintException."); + Assert.Fail("Assert.Failed to throw InvalidConstraintException."); } // tables in different datasets catch (InvalidOperationException) {} @@ -345,7 +348,7 @@ namespace MonoTests.System.Data try { fkc = new ForeignKeyConstraint(new DataColumn [] {_ds.Tables[0].Columns[0], _ds.Tables[0].Columns[1]}, new DataColumn [] {localTable.Columns[1], _ds.Tables[1].Columns [0]}); - Fail("Failed to throw InvalidOperationException."); + Assert.Fail("Assert.Failed to throw InvalidOperationException."); } catch (InvalidConstraintException) {} catch (AssertionException exc) {throw exc;} @@ -362,13 +365,13 @@ namespace MonoTests.System.Data try { fkc = new ForeignKeyConstraint(col, _ds.Tables[0].Columns[0]); - Fail("FTT1: Failed to throw ArgumentException."); + Assert.Fail("FTT1: Assert.Failed to throw ArgumentException."); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} // catch (Exception exc) // { -// Fail("WET1: Wrong Exception type. " + exc.ToString()); +// Assert.Fail("WET1: Wrong Exception type. " + exc.ToString()); // } //Columns must belong to the same table @@ -382,13 +385,13 @@ namespace MonoTests.System.Data _ds.Tables[0].Columns[1], _ds.Tables[0].Columns[0]}); - Fail("FTT2: Failed to throw InvalidConstraintException."); + Assert.Fail("FTT2: Assert.Failed to throw InvalidConstraintException."); } catch (InvalidConstraintException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("WET2: Wrong Exception type. " + exc.ToString()); + Assert.Fail("WET2: Wrong Exception type. " + exc.ToString()); } @@ -403,13 +406,13 @@ namespace MonoTests.System.Data fkc = new ForeignKeyConstraint(twoCol, new DataColumn[] { _ds.Tables[0].Columns[0]}); - Fail("FTT3: Failed to throw ArgumentException."); + Assert.Fail("FTT3: Assert.Failed to throw ArgumentException."); } catch (ArgumentException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("WET3: Wrong Exception type. " + exc.ToString()); + Assert.Fail("WET3: Wrong Exception type. " + exc.ToString()); } //InvalidOperation: Parent and child are the same column. @@ -418,13 +421,13 @@ namespace MonoTests.System.Data fkc = new ForeignKeyConstraint( _ds.Tables[0].Columns[0], _ds.Tables[0].Columns[0] ); - Fail("FTT4: Failed to throw InvalidOperationException."); + Assert.Fail("FTT4: Assert.Failed to throw InvalidOperationException."); } catch (InvalidOperationException) {} catch (AssertionException exc) {throw exc;} catch (Exception exc) { - Fail("WET4: Wrong Exception type. " + exc.ToString()); + Assert.Fail("WET4: Wrong Exception type. " + exc.ToString()); } } @@ -446,14 +449,14 @@ namespace MonoTests.System.Data ForeignKeyConstraint fkcDiff = new ForeignKeyConstraint( tbl.Columns[1], tbl.Columns[2]); - Assert( "Equals failed. 1" , fkc.Equals(fkc2)); - Assert( "Equals failed. 2" , fkc2.Equals(fkc)); - Assert( "Equals failed. 3" , fkc.Equals(fkc)); + Assert.IsTrue( fkc.Equals(fkc2) , "Equals Assert.IsTrue.Failed. 1"); + Assert.IsTrue( fkc2.Equals(fkc) , "Equals Assert.IsTrue.Failed. 2"); + Assert.IsTrue( fkc.Equals(fkc) , "Equals Assert.IsTrue.Failed. 3"); - Assert( "Equals failed diff. 1" , fkc.Equals(fkcDiff) == false); + Assert.IsTrue( fkc.Equals(fkcDiff) == false , "Equals Assert.IsTrue.Failed diff. 1"); - //Assert( "Hash Code Failed. 1", fkc.GetHashCode() == fkc2.GetHashCode() ); - Assert( "Hash Code Failed. 2", fkc.GetHashCode() != fkcDiff.GetHashCode() ); + //Assert.IsTrue( "Hash Code Assert.IsTrue.Failed. 1", fkc.GetHashCode() == fkc2.GetHashCode() ); + Assert.IsTrue( fkc.GetHashCode() != fkcDiff.GetHashCode() , "Hash Code Assert.IsTrue.Failed. 2"); } @@ -512,7 +515,7 @@ namespace MonoTests.System.Data t2.Rows.Add (new object [] {10}); t1.Rows [0][0]=20; - Assert("#1", (int)t2.Rows [0][0] == 20); + Assert.IsTrue((int)t2.Rows [0][0] == 20, "#1"); } [Test] diff --git a/mcs/class/System.Data/Test/System.Xml/XmlDataDocumentTest2.cs b/mcs/class/System.Data/Test/System.Xml/XmlDataDocumentTest2.cs index cc8196e0c96..0a99b71bc32 100644 --- a/mcs/class/System.Data/Test/System.Xml/XmlDataDocumentTest2.cs +++ b/mcs/class/System.Data/Test/System.Xml/XmlDataDocumentTest2.cs @@ -38,7 +38,7 @@ using NUnit.Framework; namespace MonoTests.System.Xml { [TestFixture] - public class XmlDataDocumentTest2 : Assertion + public class XmlDataDocumentTest2 { string xml = "<NewDataSet><table><row><col1>1</col1><col2>2</col2></row></table></NewDataSet>"; @@ -53,8 +53,8 @@ namespace MonoTests.System.Xml public void TestDefaultCtor () { XmlDataDocument doc = new XmlDataDocument (); - AssertNotNull (doc.DataSet); - AssertEquals ("NewDataSet", doc.DataSet.DataSetName); + Assert.IsNotNull (doc.DataSet); + Assert.AreEqual ("NewDataSet", doc.DataSet.DataSetName); } [Test] @@ -117,73 +117,73 @@ namespace MonoTests.System.Xml ds.Relations.Add (rel);
XmlDataDocument doc = new XmlDataDocument (ds);
doc.LoadXml ("<set><tab1><col1>1</col1><col2/><child><ref>1</ref><val>aaa</val></child></tab1></set>");
- AssertEquals (1, ds.Tables [0].Rows.Count);
- AssertEquals (1, ds.Tables [1].Rows.Count);
+ Assert.AreEqual (1, ds.Tables [0].Rows.Count);
+ Assert.AreEqual (1, ds.Tables [1].Rows.Count);
// document element - no mapped row
XmlElement el = doc.DocumentElement;
- AssertNull (doc.GetRowFromElement (el));
+ Assert.IsNull (doc.GetRowFromElement (el));
// tab1 element - has mapped row
el = el.FirstChild as XmlElement;
DataRow row = doc.GetRowFromElement (el);
- AssertNotNull (row);
- AssertEquals (DataRowState.Added, row.RowState);
+ Assert.IsNotNull (row);
+ Assert.AreEqual (DataRowState.Added, row.RowState);
// col1 - it is column. no mapped row
el = el.FirstChild as XmlElement;
row = doc.GetRowFromElement (el);
- AssertNull (row);
+ Assert.IsNull (row);
// col2 - it is column. np mapped row
el = el.NextSibling as XmlElement;
row = doc.GetRowFromElement (el);
- AssertNull (row);
+ Assert.IsNull (row);
// child - has mapped row
el = el.NextSibling as XmlElement;
row = doc.GetRowFromElement (el);
- AssertNotNull (row);
- AssertEquals (DataRowState.Added, row.RowState);
+ Assert.IsNotNull (row);
+ Assert.AreEqual (DataRowState.Added, row.RowState);
// created (detached) table 1 element (used later)
el = doc.CreateElement ("tab1");
row = doc.GetRowFromElement (el);
- AssertEquals (DataRowState.Detached, row.RowState);
- AssertEquals (1, dt.Rows.Count); // not added yet
+ Assert.AreEqual (DataRowState.Detached, row.RowState);
+ Assert.AreEqual (1, dt.Rows.Count); // not added yet
// adding a node before setting EnforceConstraints
// raises an error
try {
doc.DocumentElement.AppendChild (el);
- Fail ("Invalid Operation should occur; EnforceConstraints prevents addition.");
+ Assert.Fail ("Invalid Operation should occur; EnforceConstraints prevents addition.");
} catch (InvalidOperationException) {
}
// try again...
ds.EnforceConstraints = false;
- AssertEquals (1, dt.Rows.Count); // not added yet
+ Assert.AreEqual (1, dt.Rows.Count); // not added yet
doc.DocumentElement.AppendChild (el);
- AssertEquals (2, dt.Rows.Count); // added
+ Assert.AreEqual (2, dt.Rows.Count); // added
row = doc.GetRowFromElement (el);
- AssertEquals (DataRowState.Added, row.RowState); // changed
+ Assert.AreEqual (DataRowState.Added, row.RowState); // changed
// Irrelevant element
XmlElement el2 = doc.CreateElement ("hoge");
row = doc.GetRowFromElement (el2);
- AssertNull (row);
+ Assert.IsNull (row);
// created table 2 element (used later)
el = doc.CreateElement ("child");
row = doc.GetRowFromElement (el);
- AssertEquals (DataRowState.Detached, row.RowState);
+ Assert.AreEqual (DataRowState.Detached, row.RowState);
// Adding it to irrelevant element performs no row state change.
- AssertEquals (1, dt2.Rows.Count); // not added yet
+ Assert.AreEqual (1, dt2.Rows.Count); // not added yet
el2.AppendChild (el);
- AssertEquals (1, dt2.Rows.Count); // still not added
+ Assert.AreEqual (1, dt2.Rows.Count); // still not added
row = doc.GetRowFromElement (el);
- AssertEquals (DataRowState.Detached, row.RowState); // still detached here
+ Assert.AreEqual (DataRowState.Detached, row.RowState); // still detached here
}
// bug #54505 @@ -244,8 +244,8 @@ namespace MonoTests.System.Xml StringReader sr = new StringReader (sw.ToString()); doc1.Load (sr); - AssertEquals ("#1", 1, ds1.Tables [0].Rows.Count); - AssertEquals ("#2", 1, ds1.Tables [0].Rows [0][0]); + Assert.AreEqual (1, ds1.Tables [0].Rows.Count, "#1"); + Assert.AreEqual (1, ds1.Tables [0].Rows [0][0], "#2"); } [Test] @@ -267,8 +267,8 @@ namespace MonoTests.System.Xml StringReader sr = new StringReader (sw.ToString()); doc1.Load (sr); - AssertEquals ("#1", 1, ds1.Tables [0].Rows [0][0]); - AssertEquals ("#2", true, ds1.Tables [0].Rows [0].IsNull (1)); + Assert.AreEqual (1, ds1.Tables [0].Rows [0][0], "#1"); + Assert.AreEqual (true, ds1.Tables [0].Rows [0].IsNull (1), "#2"); } [Test] @@ -301,9 +301,9 @@ namespace MonoTests.System.Xml StringReader sreader = new StringReader (swriter.ToString ()); DataSet ds1 = ds.Clone (); XmlDataDocument doc1 = new XmlDataDocument (ds1); - AssertEquals ("#2" , 0, ds1.Tables [0].Rows.Count); + Assert.AreEqual (0 , ds1.Tables [0].Rows.Count, "#2"); doc1.Load (sreader); - AssertEquals ("#3" , 3, ds1.Tables [0].Rows.Count); + Assert.AreEqual (3 , ds1.Tables [0].Rows.Count, "#3"); } } } diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/InternalSoapValuesTest.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/InternalSoapValuesTest.cs index cbab4c217e3..86b4617162f 100644 --- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/InternalSoapValuesTest.cs +++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/InternalSoapValuesTest.cs @@ -53,7 +53,7 @@ namespace SoapShared Serialize(obj, ms);
ms.Position = 0;
Object des = Deserialize(ms);
- Assertion.AssertEquals(obj.GetType(), des.GetType());
+ Assert.AreEqual (obj.GetType(), des.GetType());
}
private void Serialize(object ob, Stream stream)
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SerializationTest.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SerializationTest.cs index d3914d9b327..3aee88df4a8 100644 --- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SerializationTest.cs +++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SerializationTest.cs @@ -222,7 +222,7 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap if (expected != null && expected.GetType().IsArray)
EqualsArray (message, (Array)expected, (Array)actual);
else
- Assertion.AssertEquals (message, expected, actual);
+ Assert.AreEqual (expected, actual, message);
}
public static void EqualsArray (string message, object oar1, object oar2)
diff --git a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SoapFormatterTest.cs b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SoapFormatterTest.cs index 9735ce04b04..91fdd7857d8 100644 --- a/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SoapFormatterTest.cs +++ b/mcs/class/System.Runtime.Serialization.Formatters.Soap/Test/SoapFormatterTest.cs @@ -171,8 +171,8 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { private object Serialize(object objGraph) {
MemoryStream stream = new MemoryStream();
- Assertion.Assert(objGraph != null);
- Assertion.Assert(stream != null);
+ Assert.IsTrue(objGraph != null);
+ Assert.IsTrue(stream != null);
_soapFormatter.SurrogateSelector = _surrogate;
_soapFormatter.Serialize(stream, objGraph);
@@ -182,8 +182,8 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { stream.Position = 0;
object objReturn = _soapFormatterDeserializer.Deserialize(stream);
- Assertion.Assert(objReturn != null);
- Assertion.AssertEquals("#Tests "+objGraph.GetType(), objGraph.GetType(), objReturn.GetType());
+ Assert.IsTrue(objReturn != null);
+ Assert.AreEqual(objGraph.GetType(), objReturn.GetType(), "#Tests "+objGraph.GetType());
stream = new MemoryStream();
_soapFormatter.Serialize(stream, objReturn);
stream.Position = 0;
@@ -209,19 +209,19 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { public void TestValueTypes() {
object objReturn;
objReturn = Serialize((short)1);
- Assertion.AssertEquals("#int16", objReturn, 1);
+ Assert.AreEqual(objReturn, 1, "#int16");
objReturn = Serialize(1);
- Assertion.AssertEquals("#int32", objReturn, 1);
+ Assert.AreEqual(objReturn, 1, "#int32");
objReturn = Serialize((Single)0.1234);
- Assertion.AssertEquals("#Single", objReturn, 0.123400003f);
+ Assert.AreEqual(objReturn, 0.123400003f, "#Single");
objReturn = Serialize((Double)1234567890.0987654321);
- Assertion.AssertEquals("#iDouble", objReturn, 1234567890.0987654321);
+ Assert.AreEqual(objReturn, 1234567890.0987654321, "#iDouble");
objReturn = Serialize(true);
- Assertion.AssertEquals("#Bool", objReturn, true);
+ Assert.AreEqual(objReturn, true, "#Bool");
objReturn = Serialize((Int64) 1234567890);
- Assertion.AssertEquals("#Int64", objReturn, 1234567890);
+ Assert.AreEqual(objReturn, 1234567890, "#Int64");
objReturn = Serialize('c');
- Assertion.AssertEquals("#Char", objReturn, 'c');
+ Assert.AreEqual(objReturn, 'c', "#Char");
}
[Test]
@@ -229,7 +229,7 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { object objReturn;
objReturn = Serialize("");
objReturn = Serialize("hello world!");
- Assertion.AssertEquals("#string", "hello world!", objReturn);
+ Assert.AreEqual("hello world!", objReturn, "#string");
SoapMessage soapMsg = new SoapMessage();
soapMsg.Headers = new Header[0];
soapMsg.MethodName = "Equals";
@@ -242,27 +242,27 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { _soapFormatterDeserializer.TopObject = null;
SimpleObject obj = new SimpleObject("simple object", 1);
objReturn = Serialize(obj);
- Assertion.AssertEquals("#SimpleObject", obj, objReturn);
+ Assert.AreEqual(obj, objReturn, "#SimpleObject");
objReturn = Serialize(typeof(SimpleObject));
- Assertion.AssertEquals("#Type", typeof(SimpleObject), (Type)objReturn);
+ Assert.AreEqual(typeof(SimpleObject), (Type)objReturn, "#Type");
objReturn = Serialize(obj.GetType().Assembly);
- Assertion.AssertEquals("#Assembly", obj.GetType().Assembly, objReturn);
+ Assert.AreEqual(obj.GetType().Assembly, objReturn, "#Assembly");
}
public static bool CheckArray(object objTest, object objReturn) {
Array objTestAsArray = objTest as Array;
Array objReturnAsArray = objReturn as Array;
- Assertion.Assert("#Not an Array "+objTest, objReturnAsArray != null);
- Assertion.AssertEquals("#Different lengths "+objTest, objTestAsArray.Length, objReturnAsArray.Length);
-
+ Assert.IsTrue(objReturnAsArray != null, "#Not an Array "+objTest);
+ Assert.AreEqual(objTestAsArray.Length, objReturnAsArray.Length, "#Different lengths "+objTest);
+ IEnumerator iEnum = objReturnAsArray.GetEnumerator();
iEnum.Reset();
object obj2;
foreach(object obj1 in objTestAsArray) {
iEnum.MoveNext();
obj2 = iEnum.Current;
- Assertion.AssertEquals("#The content of the 2 arrays is different", obj1, obj2);
+ Assert.AreEqual(obj1, obj2, "#The content of the 2 arrays is different");
}
return true;
@@ -315,9 +315,9 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { MoreComplexObject objReturn;
MoreComplexObject objTest = new MoreComplexObject();
objReturn = (MoreComplexObject) Serialize(objTest);
- Assertion.AssertEquals("#Equals", objTest, objReturn);
+ Assert.AreEqual(objTest, objReturn, "#Equals");
objReturn.OnTrucEvent("bidule");
- Assertion.AssertEquals("#dlg", "bidule", objReturn.ObjString);
+ Assert.AreEqual("bidule", objReturn.ObjString, "#dlg");
}
[Test]
@@ -333,9 +333,9 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { _soapFormatterDeserializer.Binder = new Version1ToVersion2Binder();
objReturn = _soapFormatterDeserializer.Deserialize(stream);
- Assertion.AssertEquals("#Version1 Version2", "Version2", objReturn.GetType().Name);
- Assertion.AssertEquals("#_value", 123, ((Version2) objReturn)._value);
- Assertion.AssertEquals("#_foo", "Default value", ((Version2) objReturn)._foo);
+ Assert.AreEqual("Version2", objReturn.GetType().Name, "#Version1 Version2");
+ Assert.AreEqual(123, ((Version2) objReturn)._value, "#_value");
+ Assert.AreEqual("Default value", ((Version2) objReturn)._foo, "#_foo");
}
[Test]
@@ -360,17 +360,17 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { sf.TopObject = t;
t = (SoapMessage) sf.Deserialize (ms);
- Assertion.AssertNotNull ("#1", t.Headers[0].Value);
- Assertion.AssertEquals ("#2", t.Headers[0].Value.GetType (), typeof(Type[]));
+ Assert.IsNotNull (t.Headers[0].Value, "#1");
+ Assert.AreEqual (t.Headers[0].Value.GetType (), typeof(Type[]), "#2");
Type[] ts = (Type[]) t.Headers[0].Value;
- Assertion.AssertEquals ("#3", 2, ts.Length);
- Assertion.AssertNotNull ("#4", ts[0]);
- Assertion.AssertNotNull ("#5", ts[1]);
+ Assert.AreEqual (2, ts.Length, "#3");
+ Assert.IsNotNull (ts[0], "#4");
+ Assert.IsNotNull (ts[1], "#5");
Console.WriteLine ("PPP:" + ts[0].GetType());
- Assertion.AssertEquals ("#6", typeof(string), ts[0]);
- Assertion.AssertEquals ("#7", typeof(SignatureTest[]), ts[1]);
+ Assert.AreEqual (typeof(string), ts[0], "#6");
+ Assert.AreEqual (typeof(SignatureTest[]), ts[1], "#7");
}
[Test]
@@ -398,14 +398,14 @@ namespace MonoTests.System.Runtime.Serialization.Formatters.Soap { public void OnDeserialization (StreamingContext context)
{
var ci = Thread.CurrentThread.CurrentCulture;
- Assertion.AssertEquals("#1", "German (Germany)", ci.EnglishName);
+ Assert.AreEqual("German (Germany)", ci.EnglishName, "#1");
}
[OnSerialized]
public void OnSerialized (StreamingContext context)
{
var ci = Thread.CurrentThread.CurrentCulture;
- Assertion.AssertEquals("#2", "German (Germany)", ci.EnglishName);
+ Assert.AreEqual("German (Germany)", ci.EnglishName, "#2");
}
}
}
diff --git a/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs b/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs index dbc4110cb20..ec9d6b1bb0a 100644 --- a/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs +++ b/mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs @@ -190,7 +190,7 @@ namespace MonoTests.System.ComponentModel.Design.Serialization { { #if MOBILE // ensure the property is not linked out of the application since it make the test fails - Assert.NotNull (Thread.CurrentPrincipal, "pre-test"); + Assert.IsNotNull (Thread.CurrentPrincipal, "pre-test"); #endif PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal"); @@ -213,7 +213,7 @@ namespace MonoTests.System.ComponentModel.Design.Serialization { { #if MOBILE // ensure the property is not linked out of the application since it make the test fails - Assert.NotNull (Thread.CurrentPrincipal, "pre-test"); + Assert.IsNotNull (Thread.CurrentPrincipal, "pre-test"); #endif PropertyInfo pi = typeof (Thread).GetProperty ("CurrentPrincipal"); diff --git a/mcs/class/corlib/Test/Mono.Math/ArithmeticBigTest.cs b/mcs/class/corlib/Test/Mono.Math/ArithmeticBigTest.cs index 94ff296ced5..007c0a44d9d 100644 --- a/mcs/class/corlib/Test/Mono.Math/ArithmeticBigTest.cs +++ b/mcs/class/corlib/Test/Mono.Math/ArithmeticBigTest.cs @@ -179,48 +179,48 @@ namespace MonoTests.Mono.Math.Arithmetic.Big { [Test] public void AgtB () { - Assertion.Assert(A > B); + Assert.IsTrue(A > B); } [Test] public void ANotLtB () { - Assertion.Assert(!(A < B)); + Assert.IsTrue(!(A < B)); } [Test] public void BNotGtA () { - Assertion.Assert(!(B > A)); + Assert.IsTrue(!(B > A)); } [Test] public void AltB () { - Assertion.Assert(B < A); + Assert.IsTrue(B < A); } [Test] public void AeqA () { - Assertion.Assert(A == A); + Assert.IsTrue(A == A); } [Test] public void BeqB () { - Assertion.Assert(B == B); + Assert.IsTrue(B == B); } [Test] public void AneqB () { - Assertion.Assert(A != B); + Assert.IsTrue(A != B); } [Test] public void BneqA () { - Assertion.Assert(B != A); + Assert.IsTrue(B != A); } #endregion diff --git a/mcs/class/corlib/Test/Mono.Math/PrimeTestingTest.cs b/mcs/class/corlib/Test/Mono.Math/PrimeTestingTest.cs index e6ddb0fc36e..b1ba0d26e6e 100644 --- a/mcs/class/corlib/Test/Mono.Math/PrimeTestingTest.cs +++ b/mcs/class/corlib/Test/Mono.Math/PrimeTestingTest.cs @@ -81,12 +81,12 @@ namespace MonoTests.Mono.Math { private void ExpectComposite (BigInteger bi) { - Assertion.AssertEquals (false, bi.isProbablePrime ()); + Assert.AreEqual (false, bi.isProbablePrime ()); } private void ExpectPrime (BigInteger bi) { - Assertion.AssertEquals (true, bi.isProbablePrime ()); + Assert.AreEqual (true, bi.isProbablePrime ()); } } diff --git a/mcs/class/doc/NUnitGuidelines b/mcs/class/doc/NUnitGuidelines index 5b7b87f5d95..191d5dd7ac8 100644 --- a/mcs/class/doc/NUnitGuidelines +++ b/mcs/class/doc/NUnitGuidelines @@ -45,45 +45,45 @@ build and the tests will be run along with all the others. * Tips --- Provide an unique error message for Assertion.Assert () +-- Provide an unique error message for Assert.IsTrue () -Include an unique message for each Assertion.Assert () so that when the assert +Include an unique message for each Assert.IsTrue () so that when the assert fails, it is trivial to locate the failing one. Otherwise, it may be difficult to determine which part of the test is failing. A good way to ensure unique messages is to use something like #A01, #A02 etc. Bad: - Assertion.AssertEquals ("array match", compare[0], i1[0]); - Assertion.AssertEquals ("array match", compare[1], i1[1]); - Assertion.AssertEquals ("array match", compare[2], i1[2]); - Assertion.AssertEquals ("array match", compare[3], i1[3]); + Assert.AreEqual (compare[0], i1[0], "array match"); + Assert.AreEqual (compare[1], i1[1], "array match"); + Assert.AreEqual (compare[2], i1[2], "array match"); + Assert.AreEqual (compare[3], i1[3], "array match"); Good: - Assertion.AssertEquals ("#A01", compare[0], i1[0]); - Assertion.AssertEquals ("#A02", compare[1], i1[1]); - Assertion.AssertEquals ("#A03", compare[2], i1[2]); - Assertion.AssertEquals ("#A04", compare[3], i1[3]); + Assert.AreEqual (compare[0], i1[0], "#A01"); + Assert.AreEqual (compare[1], i1[1], "#A02"); + Assert.AreEqual (compare[2], i1[2], "#A03"); + Assert.AreEqual (compare[3], i1[3], "#A04"); -Once you used such a number in an Assertion.Assert (), don't change it later on - +Once you used such a number in an Assert.IsTrue (), don't change it later on - people might use it it identify the test in bug reports or in mailing lists. --- Use Assertion.AssertEquals () to compare things, not Assertion.Assert (). +-- Use Assert.AreEqual () to compare things, not Assert.IsTrue (). -Never compare two values with Assertion.Assert () - if the test fails, people -have no idea what went wrong while Assertion.AssertEquals () reports the failed +Never compare two values with Assert.IsTrue () - if the test fails, people +have no idea what went wrong while Assert.AreEqual () reports the failed value. Also, make sure the second paramter is the expected value, and the third parameter is the actual value. Bad: - Assertion.Assert ("A01", myTicks[0] == t1.Ticks); + Assert.IsTrue (myTicks[0] == t1.Ticks, "A01"); Good: - Assertion.AssertEquals ("A01", myTicks[0], t1.Ticks); + Assert.AreEqual (myTicks[0], t1.Ticks, "A01"); -- Namespace |