AssertCrypto.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // MonoTests.System.Security.Cryptography.Xml.AssertCrypto.cs
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using System;
  10. using System.Security.Cryptography;
  11. using NUnit.Framework;
  12. namespace MonoTests.System.Security.Cryptography.Xml {
  13. public class AssertCrypto : Assertion {
  14. // because most crypto stuff works with byte[] buffers
  15. static public void AssertEquals (string msg, byte[] array1, byte[] array2)
  16. {
  17. if ((array1 == null) && (array2 == null))
  18. return;
  19. if (array1 == null)
  20. Fail (msg + " -> First array is NULL");
  21. if (array2 == null)
  22. Fail (msg + " -> Second array is NULL");
  23. bool a = (array1.Length == array2.Length);
  24. if (a) {
  25. for (int i = 0; i < array1.Length; i++) {
  26. if (array1 [i] != array2 [i]) {
  27. a = false;
  28. break;
  29. }
  30. }
  31. }
  32. msg += " -> Expected " + BitConverter.ToString (array1, 0);
  33. msg += " is different than " + BitConverter.ToString (array2, 0);
  34. Assert (msg, a);
  35. }
  36. }
  37. }