FromBase64Transform.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // TestSuite.System.Security.Cryptography.FromBase64Transform.cs
  3. //
  4. // Author:
  5. // Martin Baulig ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc. http://www.ximian.com
  8. //
  9. using System;
  10. using System.Security.Cryptography;
  11. using NUnit.Framework;
  12. namespace MonoTests.System.Security.Cryptography {
  13. public class FromBase64TransformTest : TestCase {
  14. private FromBase64Transform _algo;
  15. protected override void SetUp() {
  16. _algo = new FromBase64Transform ();
  17. }
  18. protected void TransformFinalBlock (string name, byte[] input, byte[] expected,
  19. int inputOffset, int inputCount)
  20. {
  21. byte[] output = _algo.TransformFinalBlock (input, inputOffset, inputCount);
  22. AssertEquals (name, expected.Length, output.Length);
  23. for (int i = 0; i < expected.Length; i++)
  24. AssertEquals (name + "(" + i + ")", expected [i], output [i]);
  25. }
  26. protected void TransformFinalBlock (string name, byte[] input, byte[] expected)
  27. {
  28. TransformFinalBlock (name, input, expected, 0, input.Length);
  29. }
  30. public void TestFinalBlock ()
  31. {
  32. {
  33. byte[] input = { 114, 108, 112, 55, 81, 115, 110, 69 };
  34. byte[] expected = { 174, 90, 123, 66, 201, 196 };
  35. TransformFinalBlock ("#A1", input, expected);
  36. }
  37. {
  38. byte[] input = { 114, 108, 112, 55, 81, 115, 61, 61 };
  39. byte[] expected = { 174, 90, 123, 66 };
  40. TransformFinalBlock ("#A2", input, expected);
  41. }
  42. {
  43. byte[] input = { 114, 108, 112, 55, 81, 115, 61, 61 };
  44. byte[] expected = { 150, 158, 208 };
  45. TransformFinalBlock ("#A3", input, expected, 1, 5);
  46. }
  47. }
  48. }
  49. }