AsymmetricAlgorithmTest.cs 920 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. protected override void SetUp() {
  14. _algo = AsymmetricAlgorithm.Create();
  15. }
  16. private void SetDefaultData() {
  17. }
  18. public void TestProperties() {
  19. Assert("Properties (1)", _algo != null);
  20. bool thrown = false;
  21. try {
  22. KeySizes[] keys = _algo.LegalKeySizes;
  23. foreach (KeySizes myKey in keys) {
  24. for (int i=myKey.MinSize; i<=myKey.MaxSize; i+=myKey.SkipSize) {
  25. _algo.KeySize = i;
  26. }
  27. }
  28. } catch (CryptographicException) {thrown=true;}
  29. Assert("Properties (2)", !thrown);
  30. }
  31. }
  32. }