(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / corlib / Test / System.Security.Cryptography / ToBase64TransformTest.cs
blob6023dfe8bf733d262769d38bbe2f315eecc1704e
1 //
2 // ToBase64TransformTest.cs - NUnit Test Cases for ToBase64Transform
3 //
4 // Author:
5 // Sebastien Pouliot (sebastien@ximian.com)
6 //
7 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using NUnit.Framework;
30 using System;
31 using System.Security.Cryptography;
33 namespace MonoTests.System.Security.Cryptography {
35 [TestFixture]
36 public class ToBase64TransformTest : Assertion {
38 [Test]
39 public void Properties ()
41 ICryptoTransform t = new ToBase64Transform ();
42 Assert ("CanReuseTransform", t.CanReuseTransform);
43 Assert ("CanTransformMultipleBlocks", !t.CanTransformMultipleBlocks);
44 AssertEquals ("InputBlockSize", 3, t.InputBlockSize);
45 AssertEquals ("OutputBlockSize", 4, t.OutputBlockSize);
48 [Test]
49 [ExpectedException (typeof (ArgumentNullException))]
50 public void TransformBlock_NullInput ()
52 byte[] output = new byte [4];
53 ToBase64Transform t = new ToBase64Transform ();
54 t.TransformBlock (null, 0, 0, output, 0);
57 [Test]
58 public void TransformBlock_WrongLength ()
60 byte[] input = new byte [6];
61 byte[] output = new byte [8];
62 ToBase64Transform t = new ToBase64Transform ();
63 t.TransformBlock (input, 0, 6, output, 0);
64 // note only the first block has been processed
65 AssertEquals ("WrongLength", "41-41-41-41-00-00-00-00", BitConverter.ToString (output));
68 [Test]
69 [ExpectedException (typeof (ArgumentNullException))]
70 #if ! NET_2_0
71 [Ignore ("MS throw a ExecutionEngineException")]
72 #endif
73 public void TransformBlock_NullOutput ()
75 byte[] input = new byte [3];
76 ToBase64Transform t = new ToBase64Transform ();
77 t.TransformBlock (input, 0, 3, null, 0);
80 [Test]
81 [ExpectedException (typeof (ObjectDisposedException))]
82 public void TransformBlock_Dispose ()
84 byte[] input = new byte [3];
85 byte[] output = new byte [4];
86 ToBase64Transform t = new ToBase64Transform ();
87 t.Clear ();
88 t.TransformBlock (input, 0, input.Length, output, 0);
91 [Test]
92 [ExpectedException (typeof (ArgumentNullException))]
93 public void TransformFinalBlock_Null ()
95 byte[] input = new byte [3];
96 ToBase64Transform t = new ToBase64Transform ();
97 t.TransformFinalBlock (null, 0, 3);
100 [Test]
101 public void TransformFinalBlock_SmallLength ()
103 byte[] input = new byte [2]; // smaller than InputBlockSize
104 ToBase64Transform t = new ToBase64Transform ();
105 t.TransformFinalBlock (input, 0, 2);
108 [Test]
109 [ExpectedException (typeof (ArgumentOutOfRangeException))]
110 public void TransformFinalBlock_WrongLength ()
112 byte[] input = new byte [6];
113 ToBase64Transform t = new ToBase64Transform ();
114 t.TransformFinalBlock (input, 0, 6);
117 [Test]
118 [ExpectedException (typeof (ObjectDisposedException))]
119 public void TransformFinalBlock_Dispose ()
121 byte[] input = new byte [3];
122 ToBase64Transform t = new ToBase64Transform ();
123 t.Clear ();
124 t.TransformFinalBlock (input, 0, input.Length);
127 [Test]
128 [ExpectedException (typeof (ArgumentOutOfRangeException))]
129 public void TransformBlock_InputOffset_Negative ()
131 byte[] input = new byte [15];
132 byte[] output = new byte [16];
133 using (ICryptoTransform t = new ToBase64Transform ()) {
134 t.TransformBlock (input, -1, input.Length, output, 0);
138 [Test]
139 [ExpectedException (typeof (ArgumentException))]
140 public void TransformBlock_InputOffset_Overflow ()
142 byte[] input = new byte [15];
143 byte[] output = new byte [16];
144 using (ICryptoTransform t = new ToBase64Transform ()) {
145 t.TransformBlock (input, Int32.MaxValue, input.Length, output, 0);
149 [Test]
150 [ExpectedException (typeof (ArgumentException))]
151 public void TransformBlock_InputCount_Negative ()
153 byte[] input = new byte [15];
154 byte[] output = new byte [16];
155 using (ICryptoTransform t = new ToBase64Transform ()) {
156 t.TransformBlock (input, 0, -1, output, 0);
160 [Test]
161 [ExpectedException (typeof (ArgumentException))]
162 public void TransformBlock_InputCount_Overflow ()
164 byte[] input = new byte [15];
165 byte[] output = new byte [16];
166 using (ICryptoTransform t = new ToBase64Transform ()) {
167 t.TransformBlock (input, 0, Int32.MaxValue, output, 0);
171 [Test]
172 #if NET_2_0
173 [ExpectedException (typeof (ArgumentOutOfRangeException))]
174 #else
175 [ExpectedException (typeof (IndexOutOfRangeException))]
176 #endif
177 public void TransformBlock_OutputOffset_Negative ()
179 byte[] input = new byte [15];
180 byte[] output = new byte [16];
181 using (ICryptoTransform t = new ToBase64Transform ()) {
182 t.TransformBlock (input, 0, input.Length, output, -1);
186 [Test]
187 #if NET_2_0
188 [ExpectedException (typeof (ArgumentException))]
189 #else
190 [ExpectedException (typeof (IndexOutOfRangeException))]
191 #endif
192 public void TransformBlock_OutputOffset_Overflow ()
194 byte[] input = new byte [15];
195 byte[] output = new byte [16];
196 using (ICryptoTransform t = new ToBase64Transform ()) {
197 t.TransformBlock (input, 0, input.Length, output, Int32.MaxValue);
201 [Test]
202 [ExpectedException (typeof (ArgumentNullException))]
203 public void TransformFinalBlock_Input_Null ()
205 using (ICryptoTransform t = new ToBase64Transform ()) {
206 t.TransformFinalBlock (null, 0, 15);
210 [Test]
211 [ExpectedException (typeof (ArgumentOutOfRangeException))]
212 public void TransformFinalBlock_InputOffset_Negative ()
214 byte[] input = new byte [15];
215 using (ICryptoTransform t = new ToBase64Transform ()) {
216 t.TransformFinalBlock (input, -1, input.Length);
220 [Test]
221 [ExpectedException (typeof (ArgumentException))]
222 public void TransformFinalBlock_InputOffset_Overflow ()
224 byte[] input = new byte [15];
225 using (ICryptoTransform t = new ToBase64Transform ()) {
226 t.TransformFinalBlock (input, Int32.MaxValue, input.Length);
230 [Test]
231 [ExpectedException (typeof (ArgumentException))]
232 public void TransformFinalBlock_InputCount_Negative ()
234 byte[] input = new byte [15];
235 using (ICryptoTransform t = new ToBase64Transform ()) {
236 t.TransformFinalBlock (input, 0, -1);
240 [Test]
241 [ExpectedException (typeof (ArgumentException))]
242 public void TransformFinalBlock_InputCount_Overflow ()
244 byte[] input = new byte [15];
245 using (ICryptoTransform t = new ToBase64Transform ()) {
246 t.TransformFinalBlock (input, 0, Int32.MaxValue);