AsymmetricAlgorithmTest.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // TestSuite.System.Security.Cryptography.AsymmetricAlgorithmTest.cs
  3. //
  4. // Author:
  5. // Thomas Neidhart ([email protected])
  6. //
  7. using System;
  8. using System.Security.Cryptography;
  9. using NUnit.Framework;
  10. namespace MonoTests.System.Security.Cryptography {
  11. public class AsymmetricAlgorithmTest : TestCase {
  12. private AsymmetricAlgorithm _algo;
  13. public AsymmetricAlgorithmTest() : base ("MonoTests.System.Security.Cryptography.AsymmetricAlgorithmTest testcase") {
  14. _algo = null;
  15. }
  16. public AsymmetricAlgorithmTest(String name) : base(name) {
  17. _algo = null;
  18. }
  19. public static ITest Suite {
  20. get {
  21. return new TestSuite(typeof(AsymmetricAlgorithmTest));
  22. }
  23. }
  24. protected override void SetUp() {
  25. _algo = AsymmetricAlgorithm.Create();
  26. }
  27. private void SetDefaultData() {
  28. }
  29. public void TestProperties() {
  30. Assert("Properties (1)", _algo != null);
  31. bool thrown = false;
  32. try {
  33. KeySizes[] keys = _algo.LegalKeySizes;
  34. foreach (KeySizes myKey in keys) {
  35. for (int i=myKey.MinSize; i<=myKey.MaxSize; i+=myKey.SkipSize) {
  36. _algo.KeySize = i;
  37. }
  38. }
  39. } catch (CryptographicException) {thrown=true;}
  40. Assert("Properties (2)", !thrown);
  41. }
  42. }
  43. }