RNGCryptoServiceProviderTest.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // TestSuite.System.Security.Cryptography.RNGCryptoServiceProviderTest.cs
  3. //
  4. // Author:
  5. // Mark Crichton ([email protected])
  6. //
  7. using System;
  8. using System.Security.Cryptography;
  9. using NUnit.Framework;
  10. namespace MonoTests.System.Security.Cryptography {
  11. public class RNGCryptoServiceProviderTest : TestCase {
  12. private RNGCryptoServiceProvider _algo;
  13. public RNGCryptoServiceProviderTest() : base ("MonoTests.System.Security.Cryptography.RNGCryptoServiceProviderTest testcase") {
  14. _algo = null;
  15. }
  16. public RNGCryptoServiceProviderTest(String name) : base(name) {
  17. _algo = null;
  18. }
  19. public static ITest Suite {
  20. get {
  21. return new TestSuite(typeof(RNGCryptoServiceProviderTest));
  22. }
  23. }
  24. protected override void SetUp() {
  25. _algo = new RNGCryptoServiceProvider();
  26. }
  27. private void SetDefaultData() {
  28. }
  29. public void TestProperties() {
  30. Assert("Properties (1)", _algo != null);
  31. byte[] random = new Byte[25];
  32. // The C code doesn't throw an exception yet.
  33. _algo.GetBytes(random);
  34. // This one we can check...
  35. _algo.GetNonZeroBytes(random);
  36. foreach (Byte rnd_byte in random) {
  37. Assert("Properties (2)", rnd_byte != 0);
  38. }
  39. }
  40. }
  41. }