RNGCryptoServiceProviderTest.cs 895 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. protected override void SetUp() {
  14. _algo = new RNGCryptoServiceProvider();
  15. }
  16. private void SetDefaultData() {
  17. }
  18. public void TestProperties() {
  19. Assert("Properties (1)", _algo != null);
  20. byte[] random = new Byte[25];
  21. // The C code doesn't throw an exception yet.
  22. _algo.GetBytes(random);
  23. // This one we can check...
  24. _algo.GetNonZeroBytes(random);
  25. foreach (Byte rnd_byte in random) {
  26. Assert("Properties (2)", rnd_byte != 0);
  27. }
  28. }
  29. }
  30. }