Use __cdecl rather than __stdcall for icalls on Windows 32-bit
[mono.git] / mcs / class / corlib / Test / System.Security.Cryptography / RNGCryptoServiceProviderTest.cs
1 //
2 // TestSuite.System.Security.Cryptography.RNGCryptoServiceProviderTest.cs
3 //
4 // Authors:
5 //      Mark Crichton (crichton@gimp.org)
6 //      Sebastien Pouliot  (sebastien@ximian.com)
7 //
8 // Copyright (C) 2004 Novell (http://www.novell.com)
9 //
10
11 using System;
12 using System.Security.Cryptography;
13
14 using NUnit.Framework;
15
16 namespace MonoTests.System.Security.Cryptography {
17
18         [TestFixture]
19         public class RNGCryptoServiceProviderTest {
20
21                 private RNGCryptoServiceProvider _algo;
22                 
23                 [SetUp]
24                 public void SetUp () 
25                 {
26                         _algo = new RNGCryptoServiceProvider ();
27                 }
28 #if !MOBILE
29                 [Test]
30                 public void ConstructorByteArray () 
31                 {
32                         byte[] array = new byte [16];
33                         byte[] seed = (byte[]) array.Clone ();
34                         RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (seed);
35                         Assert.AreEqual (BitConverter.ToString (array), BitConverter.ToString (seed), "Seed");
36                 }
37
38                 [Test]
39                 public void ConstructorByteArray_Null () 
40                 {
41                         byte[] array = null;
42                         RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (array);
43                 }
44
45                 [Test]
46                 public void ConstructorCsp_Null () 
47                 {
48                         CspParameters csp = null;
49                         RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (csp);
50                 }
51
52                 [Test]
53                 public void ConstructorString () 
54                 {
55                         string s = "Mono seed";
56                         RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (s);
57                 }
58
59                 [Test]
60                 public void ConstructorString_Null () 
61                 {
62                         string s = null;
63                         RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider (s);
64                 }
65 #endif
66                 [Test]
67                 public void GetBytes () 
68                 {
69                         byte[] random = new byte [25];
70                         // The C code doesn't throw an exception yet.
71                         _algo.GetBytes (random);
72                 }
73
74                 [Test]
75                 public void GetNonZeroBytes () 
76                 {
77                         byte[] random = new byte [25];
78                         // This one we can check...
79                         _algo.GetNonZeroBytes (random);
80                         
81                         foreach (Byte rnd_byte in random) {
82                                 Assert.IsTrue(rnd_byte != 0);
83                         }
84                 }
85
86                 [Test]
87                 [ExpectedException (typeof (ArgumentNullException))]
88                 public void GetBytesNull () 
89                 {
90                         _algo.GetBytes (null);
91                 }
92
93                 [Test]
94                 [ExpectedException (typeof (ArgumentNullException))]
95                 public void GetNonZeroBytesNull () 
96                 {
97                         _algo.GetNonZeroBytes (null);
98                 }
99         }
100 }