2 // TestSuite.System.Security.Cryptography.SymmetricAlgorithmTest.cs
\r
5 // Thomas Neidhart (tome@sbox.tugraz.at)
\r
10 using System.Security.Cryptography;
\r
12 using NUnit.Framework;
\r
14 namespace Testsuite.System.Security.Cryptography {
\r
16 public class SymmetricAlgorithmTest : TestCase {
\r
17 private SymmetricAlgorithm _algo;
\r
19 public SymmetricAlgorithmTest(String name) : base(name) {
\r
23 public static ITest Suite {
\r
25 return new TestSuite(typeof(SymmetricAlgorithmTest));
\r
29 protected override void SetUp() {
\r
30 _algo = SymmetricAlgorithm.Create();
\r
33 private void SetDefaultData() {
\r
36 public void TestProperties() {
\r
37 Assert("Properties (1)", _algo != null);
\r
39 bool thrown = false;
\r
42 // try setting an illegal blocksize -> must throw an exception
\r
43 _algo.BlockSize = 12;
\r
44 } catch (CryptographicException) {thrown = true;}
\r
45 Assert("Properties (2)", thrown);
\r
47 byte[] key = _algo.Key;
\r
48 Assert("Properties (3)", key != null);
\r
52 KeySizes[] keys = _algo.LegalKeySizes;
\r
53 foreach (KeySizes myKey in keys) {
\r
54 for (int i=myKey.MinSize; i<=myKey.MaxSize; i+=myKey.SkipSize) {
\r
58 } catch (CryptographicException) {thrown=true;}
\r
59 Assert("Properties (4)", !thrown);
\r