diff options
author | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-06-03 11:51:22 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@veritas-vos-liberabit.com> | 2013-06-03 11:51:22 +0400 |
commit | 5aaa3ce00b0a96cae9f4650442836e8257d16910 (patch) | |
tree | 04132f207624ff8c02a8b91ff63fe975aba52508 /mcs | |
parent | c01342d8d1a778059a1c6064f7e91f0b1818c023 (diff) |
convert some unit tests to modern style. (not really modern, just killing Assertion!)
Diffstat (limited to 'mcs')
5 files changed, 35 insertions, 20 deletions
diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs index e2c9e9fac9c..110311adf1a 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ARC4ManagedTest.cs @@ -23,7 +23,7 @@ namespace MonoTests.Mono.Security.Cryptography { // http://wp.netscape.com/eng/ssl3/traces/trc-clnt-ex.html [TestFixture] - public class ARC4ManagedTest : Assertion { + public class ARC4ManagedTest { // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) @@ -31,9 +31,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) { @@ -46,7 +46,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); } // from ref. a @@ -205,10 +205,10 @@ namespace MonoTests.Mono.Security.Cryptography { public void DefaultProperties () { ARC4Managed rc4 = new ARC4Managed (); - Assert ("CanReuseTransform", !rc4.CanReuseTransform); - Assert ("CanTransformMultipleBlocks", rc4.CanTransformMultipleBlocks); - AssertEquals ("InputBlockSize", 1, rc4.InputBlockSize); - AssertEquals ("OutputBlockSize", 1, rc4.OutputBlockSize); + Assert.IsFalse (rc4.CanReuseTransform, "CanReuseTransform"); + Assert.IsTrue (rc4.CanTransformMultipleBlocks, "CanTransformMultipleBlocks"); + Assert.AreEqual (1, rc4.InputBlockSize, "InputBlockSize"); + Assert.AreEqual (1, rc4.OutputBlockSize, "OutputBlockSize"); } [Test] @@ -217,9 +217,9 @@ namespace MonoTests.Mono.Security.Cryptography { ARC4Managed rc4 = new ARC4Managed (); rc4.GenerateKey (); rc4.GenerateIV (); - AssertEquals ("Key.Length", 16, rc4.Key.Length); - AssertEquals ("KeySize", 128, rc4.KeySize); - AssertEquals ("IV.Length", 0, rc4.IV.Length); + Assert.AreEqual (16, rc4.Key.Length, "Key.Length"); + Assert.AreEqual (128, rc4.KeySize, "KeySize"); + Assert.AreEqual (0, rc4.IV.Length, "IV.Length"); } [Test] diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs index 5f6469abf1d..01462d5adc9 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2ManagedTest.cs @@ -32,7 +32,7 @@ namespace MonoTests.Mono.Security.Cryptography { { // try creating ourselve using Create HashAlgorithm h = MD2.Create ("MD2Managed"); - Assert ("MD2Managed", (h is MD2Managed)); + Assert.IsTrue ((h is MD2Managed), "MD2Managed"); } } -}
\ No newline at end of file +} diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs index b7307cc9b1b..6fb7abdceff 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD2Test.cs @@ -24,10 +24,20 @@ namespace MonoTests.Mono.Security.Cryptography { // MD2 is a abstract class - so ALL of the test included here wont be tested // on the abstract class but should be tested in ALL its descendants. - public abstract class MD2Test : Assertion { + public abstract class MD2Test { protected MD2 hash; + static void Fail (string msg) + { + Assert.Fail (msg); + } + + static void AssertEquals (string msg, int expected, int actual) + { + Assert.AreEqual (expected, actual, msg); + } + // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) { @@ -51,7 +61,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); } // MD2 ("") = 8350e5a3e24c153df2275c9f80692773 @@ -232,7 +242,7 @@ namespace MonoTests.Mono.Security.Cryptography { { // create the default implementation HashAlgorithm h = MD2.Create (); - Assert ("MD2Managed", (h is MD2Managed)); + Assert.IsTrue ((h is MD2Managed), "MD2Managed"); // Note: will fail is default is changed in machine.config } } diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs index ff0bcfb8056..32de43caeb3 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4ManagedTest.cs @@ -32,7 +32,7 @@ namespace MonoTests.Mono.Security.Cryptography { { // try creating ourselve using Create HashAlgorithm h = MD4.Create ("MD4Managed"); - Assert ("MD4Managed", (h is MD4Managed)); + Assert.IsTrue ((h is MD4Managed), "MD4Managed"); } } -}
\ No newline at end of file +} diff --git a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs index dd36e8fa412..fb8e0d74bbc 100644 --- a/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs +++ b/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/MD4Test.cs @@ -24,10 +24,15 @@ namespace MonoTests.Mono.Security.Cryptography { // MD4 is a abstract class - so ALL of the test included here wont be tested // on the abstract class but should be tested in ALL its descendants. - public abstract class MD4Test : Assertion { + public abstract class MD4Test { protected MD4 hash; + static void AssertEquals (string msg, int expected, int actual) + { + Assert.AreEqual (expected, actual, msg); + } + // because most crypto stuff works with byte[] buffers static public void AssertEquals (string msg, byte[] array1, byte[] array2) { @@ -232,7 +237,7 @@ namespace MonoTests.Mono.Security.Cryptography { { // create the default implementation HashAlgorithm h = MD4.Create (); - Assert ("MD4Managed", (h is MD4Managed)); + Assert.IsTrue ((h is MD4Managed), "MD4Managed"); // Note: will fail is default is changed in machine.config } } |