Jelajahi Sumber

2002-05-19 Martin Baulig <[email protected]>

	* Added System.Security.Cryptography.FromBase64TransformTest.cs.

svn path=/trunk/mcs/; revision=4760
Martin Baulig 23 tahun lalu
induk
melakukan
dca14bea40

+ 4 - 0
mcs/class/corlib/Test/ChangeLog

@@ -1,3 +1,7 @@
+2002-05-19  Martin Baulig  <[email protected]>
+
+	* Added System.Security.Cryptography.FromBase64TransformTest.cs.
+
 2002-05-19  Martin Baulig  <[email protected]>
 
 	* TheTests.cs: Removed.

+ 1 - 0
mcs/class/corlib/Test/System.Security.Cryptography/AllTests.cs

@@ -23,6 +23,7 @@ namespace MonoTests.System.Security.Cryptography {
                                 suite.AddTest(SymmetricAlgorithmTest.Suite);
 				suite.AddTest(AsymmetricAlgorithmTest.Suite); 
                         	suite.AddTest(RNGCryptoServiceProviderTest.Suite);
+				suite.AddTest(FromBase64TransformTest.Suite);
                                 return suite;
                         }
                 }

+ 75 - 0
mcs/class/corlib/Test/System.Security.Cryptography/FromBase64Transform.cs

@@ -0,0 +1,75 @@
+//
+// TestSuite.System.Security.Cryptography.FromBase64Transform.cs
+//
+// Author:
+//      Martin Baulig ([email protected])
+//
+// (C) 2002 Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Security.Cryptography;
+using NUnit.Framework;
+
+namespace MonoTests.System.Security.Cryptography {
+
+	public class FromBase64TransformTest : TestCase {
+		private FromBase64Transform _algo;
+
+		public FromBase64TransformTest() : base ("MonoTests.System.Security.Cryptography.FromBase64Transform testcase") {
+			_algo = null;
+		}
+		public FromBase64TransformTest(String name) : base(name)
+		{
+			_algo = null;
+		}
+		
+		public static ITest Suite {
+			get {
+				return new TestSuite(typeof(FromBase64TransformTest));
+			}
+		}
+
+		protected override void SetUp() {
+			_algo = new FromBase64Transform ();
+		}
+
+		protected void TransformFinalBlock (string name, byte[] input, byte[] expected,
+						    int inputOffset, int inputCount)
+		{
+			byte[] output = _algo.TransformFinalBlock (input, inputOffset, inputCount);
+
+			AssertEquals (name, expected.Length, output.Length);
+			for (int i = 0; i < expected.Length; i++)
+				AssertEquals (name + "(" + i + ")", expected [i], output [i]);
+		}
+
+		protected void TransformFinalBlock (string name, byte[] input, byte[] expected)
+		{
+			TransformFinalBlock (name, input, expected, 0, input.Length);
+		}
+
+		public void TestFinalBlock ()
+		{
+			{
+				byte[] input = { 114, 108, 112, 55, 81, 115, 110, 69 };
+				byte[] expected = { 174, 90, 123, 66, 201, 196 };
+
+				TransformFinalBlock ("#A1", input, expected);
+			}
+			{
+				byte[] input = { 114, 108, 112, 55, 81, 115, 61, 61 };
+				byte[] expected = { 174, 90, 123, 66 };
+
+				TransformFinalBlock ("#A2", input, expected);
+			}
+			{
+				byte[] input = { 114, 108, 112, 55, 81, 115, 61, 61 };
+				byte[] expected = { 150, 158, 208 };
+
+				TransformFinalBlock ("#A3", input, expected, 1, 5);
+			}
+		}
+
+	}
+}