This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlInt16Test.cs
1 //
2 // SqlInt16Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt16
3 //
4 // Authors:
5 //   Ville Palo (vi64pa@koti.soon.fi)
6 //   Martin Willemoes Hansen (mwh@sysrq.dk)
7 //
8 // (C) 2002 Ville Palo
9 // (C) 2003 Martin Willemoes Hansen
10 // 
11
12 //
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 //
34
35 using NUnit.Framework;
36 using System;
37 using System.Data.SqlTypes;
38
39 namespace MonoTests.System.Data.SqlTypes
40 {
41         [TestFixture]
42         public class SqlInt16Test : Assertion {
43
44                 // Test constructor
45                 [Test]
46                 public void Create()
47                 {
48                         SqlInt16 TestShort = new SqlInt16 (29);
49                         AssertEquals ("Test#1", (short)29, TestShort.Value);
50
51                         TestShort = new SqlInt16 (-9000);
52                         AssertEquals ("Test#2", (short)-9000, TestShort.Value);
53                 }
54
55                 // Test public fields
56                 [Test]
57                 public void PublicFields()
58                 {
59                         AssertEquals ("Test#1", (SqlInt16)32767, SqlInt16.MaxValue);
60                         AssertEquals ("Test#2", (SqlInt16)(-32768), SqlInt16.MinValue);
61                         Assert ("Test#3", SqlInt16.Null.IsNull);
62                         AssertEquals ("Test#4", (short)0, SqlInt16.Zero.Value);
63                 }
64
65                 // Test properties
66                 [Test]
67                 public void Properties()
68                 {
69                         SqlInt16 Test5443 = new SqlInt16 (5443);
70                         SqlInt16 Test1 = new SqlInt16 (1);
71                         Assert ("Test#1", SqlInt16.Null.IsNull);
72                         AssertEquals ("Test#2", (short)5443, Test5443.Value);
73                         AssertEquals ("Test#3", (short)1, Test1.Value);
74                 }
75
76                 // PUBLIC METHODS
77
78                 [Test]
79                 public void ArithmeticMethods()
80                 {
81                         SqlInt16 Test64 = new SqlInt16 (64);
82                         SqlInt16 Test0 = new SqlInt16 (0);
83                         SqlInt16 Test164 = new SqlInt16 (164);
84                         SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);
85
86                         // Add()
87                         AssertEquals ("Test#1", (short)64, SqlInt16.Add (Test64, Test0).Value);
88                         AssertEquals ("Test#2", (short)228, SqlInt16.Add (Test64, Test164).Value);
89                         AssertEquals ("Test#3", (short)164, SqlInt16.Add (Test0, Test164).Value);
90                         AssertEquals ("Test#4", (short)SqlInt16.MaxValue, SqlInt16.Add (TestMax, Test0).Value);
91
92                         try {
93                                 SqlInt16.Add (TestMax, Test64);
94                                 Fail ("Test#5");
95                         } catch (Exception e) {
96                                 AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
97                         }
98
99                         // Divide()
100                         AssertEquals ("Test#7", (short)2, SqlInt16.Divide (Test164, Test64).Value);
101                         AssertEquals ("Test#8", (short)0, SqlInt16.Divide (Test64, Test164).Value);
102                         try {
103                                 SqlInt16.Divide(Test64, Test0);
104                                 Fail ("Test#9");
105                         } catch(Exception e) {
106                                 AssertEquals ("Test#10", typeof (DivideByZeroException), e.GetType ());
107                         }
108
109                         // Mod()
110                         AssertEquals ("Test#11", (SqlInt16)36, SqlInt16.Mod (Test164, Test64));
111                         AssertEquals ("Test#12",  (SqlInt16)64, SqlInt16.Mod (Test64, Test164));
112
113                         // Multiply()
114                         AssertEquals ("Test#13", (short)10496, SqlInt16.Multiply (Test64, Test164).Value);
115                         AssertEquals ("Test#14", (short)0, SqlInt16.Multiply (Test64, Test0).Value);
116
117                         try {
118                                 SqlInt16.Multiply (TestMax, Test64);
119                                 Fail ("Test#15");
120                         } catch(Exception e) {
121                                 AssertEquals ("Test#16", typeof (OverflowException), e.GetType ());
122                         }
123
124                         // Subtract()
125                         AssertEquals ("Test#17", (short)100, SqlInt16.Subtract (Test164, Test64).Value);
126
127                         try {
128                                 SqlInt16.Subtract (SqlInt16.MinValue, Test164);
129                                 Fail("Test#18");
130                         } catch(Exception e) {
131                                 AssertEquals ("Test#19", typeof (OverflowException), e.GetType ());
132                         }
133                 }
134
135                 [Test]
136                 public void BitwiseMethods()
137                 {
138                         short MaxValue = SqlInt16.MaxValue.Value;
139                         SqlInt16 TestInt = new SqlInt16 (0);
140                         SqlInt16 TestIntMax = new SqlInt16 (MaxValue);
141                         SqlInt16 TestInt2 = new SqlInt16 (10922);
142                         SqlInt16 TestInt3 = new SqlInt16 (21845);
143
144                         // BitwiseAnd
145                         AssertEquals ("Test#1", (short)21845, SqlInt16.BitwiseAnd (TestInt3, TestIntMax).Value);
146                         AssertEquals ("Test#2", (short)0, SqlInt16.BitwiseAnd (TestInt2, TestInt3).Value);
147                         AssertEquals ("Test#3", (short)10922, SqlInt16.BitwiseAnd (TestInt2, TestIntMax).Value);
148
149                         //BitwiseOr
150                         AssertEquals ("Test#4", (short)MaxValue, SqlInt16.BitwiseOr (TestInt2, TestInt3).Value);
151                         AssertEquals ("Test#5", (short)21845, SqlInt16.BitwiseOr (TestInt, TestInt3).Value);
152                         AssertEquals ("Test#6", (short)MaxValue, SqlInt16.BitwiseOr (TestIntMax, TestInt2).Value);
153                 }
154
155                 [Test]
156                 public void CompareTo()
157                 {
158                         SqlInt16 TestInt4000 = new SqlInt16 (4000);
159                         SqlInt16 TestInt4000II = new SqlInt16 (4000);
160                         SqlInt16 TestInt10 = new SqlInt16 (10);
161                         SqlInt16 TestInt10000 = new SqlInt16 (10000);
162                         SqlString TestString = new SqlString ("This is a test");
163
164                         Assert ("Test#1", TestInt4000.CompareTo (TestInt10) > 0);
165                         Assert ("Test#2", TestInt10.CompareTo (TestInt4000) < 0);
166                         Assert ("Test#3", TestInt4000II.CompareTo (TestInt4000) == 0);
167                         Assert ("Test#4", TestInt4000II.CompareTo (SqlInt16.Null) > 0);
168
169                         try {
170                                 TestInt10.CompareTo (TestString);
171                                 Fail ("Test#5");
172                         } catch(Exception e) {
173                                 AssertEquals ("Test#6", typeof (ArgumentException), e.GetType ());
174                         }
175                 }
176
177                 [Test]
178                 public void EqualsMethod()
179                 {
180                         SqlInt16 Test0 = new SqlInt16 (0);
181                         SqlInt16 Test158 = new SqlInt16 (158);
182                         SqlInt16 Test180 = new SqlInt16 (180);
183                         SqlInt16 Test180II = new SqlInt16 (180);
184
185                         Assert ("Test#1", !Test0.Equals (Test158));
186                         Assert ("Test#2", !Test158.Equals (Test180));
187                         Assert ("Test#3", !Test180.Equals (new SqlString ("TEST")));
188                         Assert ("Test#4", Test180.Equals (Test180II));
189                 }
190
191                 [Test]
192                 public void StaticEqualsMethod()
193                 {
194                         SqlInt16 Test34 = new SqlInt16 (34);
195                         SqlInt16 Test34II = new SqlInt16 (34);
196                         SqlInt16 Test15 = new SqlInt16 (15);
197
198                         Assert ("Test#1", SqlInt16.Equals (Test34, Test34II).Value);
199                         Assert ("Test#2", !SqlInt16.Equals (Test34, Test15).Value);
200                         Assert ("Test#3", !SqlInt16.Equals (Test15, Test34II).Value);
201                 }
202
203                 [Test]
204                 public void GetHashCodeTest()
205                 {
206                         SqlInt16 Test15 = new SqlInt16 (15);
207
208                         // FIXME: Better way to test GetHashCode()-methods
209                         AssertEquals ("Test#1", Test15.GetHashCode (), Test15.GetHashCode ());
210                 }
211
212                 [Test]
213                 public void GetTypeTest()
214                 {
215                         SqlInt16 Test = new SqlInt16 (84);
216                         AssertEquals ("Test#1", "System.Data.SqlTypes.SqlInt16", Test.GetType ().ToString ());
217                 }
218
219                 [Test]
220                 public void Greaters()
221                 {
222                         SqlInt16 Test10 = new SqlInt16 (10);
223                         SqlInt16 Test10II = new SqlInt16 (10);
224                         SqlInt16 Test110 = new SqlInt16 (110);
225
226                         // GreateThan ()
227                         Assert ("Test#1", !SqlInt16.GreaterThan (Test10, Test110).Value);
228                         Assert ("Test#2", SqlInt16.GreaterThan (Test110, Test10).Value);
229                         Assert ("Test#3", !SqlInt16.GreaterThan (Test10II, Test10).Value);
230
231                         // GreaterTharOrEqual ()
232                         Assert ("Test#4", !SqlInt16.GreaterThanOrEqual (Test10, Test110).Value);
233                         Assert ("Test#5", SqlInt16.GreaterThanOrEqual (Test110, Test10).Value);
234                         Assert ("Test#6", SqlInt16.GreaterThanOrEqual (Test10II, Test10).Value);
235                 }
236
237                 [Test]
238                 public void Lessers()
239                 {
240                         SqlInt16 Test10 = new SqlInt16 (10);
241                         SqlInt16 Test10II = new SqlInt16 (10);
242                         SqlInt16 Test110 = new SqlInt16 (110);
243
244                         // LessThan()
245                         Assert ("Test#1", SqlInt16.LessThan (Test10, Test110).Value);
246                         Assert ("Test#2", !SqlInt16.LessThan (Test110, Test10).Value);
247                         Assert ("Test#3", !SqlInt16.LessThan (Test10II, Test10).Value);
248
249                         // LessThanOrEqual ()
250                         Assert ("Test#4", SqlInt16.LessThanOrEqual (Test10, Test110).Value);
251                         Assert ("Test#5", !SqlInt16.LessThanOrEqual (Test110, Test10).Value);
252                         Assert ("Test#6", SqlInt16.LessThanOrEqual (Test10II, Test10).Value);
253                         Assert ("Test#7", SqlInt16.LessThanOrEqual (Test10II, SqlInt16.Null).IsNull);
254                 }
255
256                 [Test]
257                 public void NotEquals()
258                 {
259                         SqlInt16 Test12 = new SqlInt16 (12);
260                         SqlInt16 Test128 = new SqlInt16 (128);
261                         SqlInt16 Test128II = new SqlInt16 (128);
262
263                         Assert ("Test#1", SqlInt16.NotEquals (Test12, Test128).Value);
264                         Assert ("Test#2", SqlInt16.NotEquals (Test128, Test12).Value);
265                         Assert ("Test#3", SqlInt16.NotEquals (Test128II, Test12).Value);
266                         Assert ("Test#4", !SqlInt16.NotEquals (Test128II, Test128).Value);
267                         Assert ("Test#5", !SqlInt16.NotEquals (Test128, Test128II).Value);
268                         Assert ("Test#6", SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull);
269                         Assert ("Test#7", SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull);
270                 }
271
272                 [Test]
273                 public void OnesComplement()
274                 {
275                         SqlInt16 Test12 = new SqlInt16(12);
276                         SqlInt16 Test128 = new SqlInt16(128);
277
278                         AssertEquals ("Test#1", (SqlInt16)(-13), SqlInt16.OnesComplement (Test12));
279                         AssertEquals ("Test#2", (SqlInt16)(-129), SqlInt16.OnesComplement (Test128));
280                 }
281
282                 [Test]
283                 public void Parse()
284                 {
285                         try {
286                                 SqlInt16.Parse (null);
287                                 Fail ("Test#1");
288                         } catch (Exception e) {
289                                 AssertEquals ("Test#2", typeof (ArgumentNullException), e.GetType ());
290                         }
291
292                         try {
293                                 SqlInt16.Parse ("not-a-number");
294                                 Fail ("Test#3");
295                         } catch (Exception e) {
296                                 AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
297                         }
298
299                         try {
300                                 int OverInt = (int)SqlInt16.MaxValue + 1;
301                                 SqlInt16.Parse (OverInt.ToString ());
302                                 Fail ("Test#5");
303                         } catch (Exception e) {
304                                 AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
305                         }
306
307                         AssertEquals("Test#7", (short)150, SqlInt16.Parse ("150").Value);
308                 }
309
310                 [Test]
311                 public void Conversions()
312                 {
313                         SqlInt16 Test12 = new SqlInt16 (12);
314                         SqlInt16 Test0 = new SqlInt16 (0);
315                         SqlInt16 TestNull = SqlInt16.Null;
316                         SqlInt16 Test1000 = new SqlInt16 (1000);
317                         SqlInt16 Test288 = new SqlInt16(288);
318
319                         // ToSqlBoolean ()
320                         Assert ("TestA#1", Test12.ToSqlBoolean ().Value);
321                         Assert ("TestA#2", !Test0.ToSqlBoolean ().Value);
322                         Assert ("TestA#3", TestNull.ToSqlBoolean ().IsNull);
323
324                         // ToSqlByte ()
325                         AssertEquals ("TestB#1", (byte)12, Test12.ToSqlByte ().Value);
326                         AssertEquals ("TestB#2", (byte)0, Test0.ToSqlByte ().Value);
327
328                         try {
329                                 SqlByte b = (byte)Test1000.ToSqlByte ();
330                                 Fail ("TestB#4");
331                         } catch (Exception e) {
332                                 AssertEquals ("TestB#5", typeof (OverflowException), e.GetType ());
333                         }
334
335                         // ToSqlDecimal ()
336                         AssertEquals ("TestC#1", (decimal)12, Test12.ToSqlDecimal ().Value);
337                         AssertEquals ("TestC#2", (decimal)0, Test0.ToSqlDecimal ().Value);
338                         AssertEquals ("TestC#3", (decimal)288, Test288.ToSqlDecimal ().Value);
339
340                         // ToSqlDouble ()
341                         AssertEquals ("TestD#1", (double)12, Test12.ToSqlDouble ().Value);
342                         AssertEquals ("TestD#2", (double)0, Test0.ToSqlDouble ().Value);
343                         AssertEquals ("TestD#3", (double)1000, Test1000.ToSqlDouble ().Value);
344
345                         // ToSqlInt32 ()
346                         AssertEquals ("TestE#1", (int)12, Test12.ToSqlInt32 ().Value);
347                         AssertEquals ("TestE#2", (int)0, Test0.ToSqlInt32 ().Value);
348                         AssertEquals ("TestE#3", (int)288, Test288.ToSqlInt32().Value);
349
350                         // ToSqlInt64 ()
351                         AssertEquals ("TestF#1", (long)12, Test12.ToSqlInt64 ().Value);
352                         AssertEquals ("TestF#2", (long)0, Test0.ToSqlInt64 ().Value);
353                         AssertEquals ("TestF#3", (long)288, Test288.ToSqlInt64 ().Value);
354
355                         // ToSqlMoney ()
356                         AssertEquals ("TestG#1", 12.0000M, Test12.ToSqlMoney ().Value);
357                         AssertEquals ("TestG#2", (decimal)0, Test0.ToSqlMoney ().Value);
358                         AssertEquals ("TestG#3", 288.0000M, Test288.ToSqlMoney ().Value);
359
360                         // ToSqlSingle ()
361                         AssertEquals ("TestH#1", (float)12, Test12.ToSqlSingle ().Value);
362                         AssertEquals ("TestH#2", (float)0, Test0.ToSqlSingle ().Value);
363                         AssertEquals ("TestH#3", (float)288, Test288.ToSqlSingle().Value);
364
365                         // ToSqlString ()
366                         AssertEquals ("TestI#1", "12", Test12.ToSqlString ().Value);
367                         AssertEquals ("TestI#2", "0", Test0.ToSqlString ().Value);
368                         AssertEquals ("TestI#3", "288", Test288.ToSqlString ().Value);
369
370                         // ToString ()
371                         AssertEquals ("TestJ#1", "12", Test12.ToString ());
372                         AssertEquals ("TestJ#2", "0", Test0.ToString ());
373                         AssertEquals ("TestJ#3", "288", Test288.ToString ());
374                 }
375
376                 [Test]
377                 public void Xor()
378                 {
379                         SqlInt16 Test14 = new SqlInt16 (14);
380                         SqlInt16 Test58 = new SqlInt16 (58);
381                         SqlInt16 Test130 = new SqlInt16 (130);
382                         SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);
383                         SqlInt16 Test0 = new SqlInt16 (0);
384
385                         AssertEquals ("Test#1", (short)52, SqlInt16.Xor (Test14, Test58).Value);
386                         AssertEquals ("Test#2", (short)140, SqlInt16.Xor (Test14, Test130).Value);
387                         AssertEquals ("Test#3", (short)184, SqlInt16.Xor (Test58, Test130).Value);
388                         AssertEquals ("Test#4", (short)0, SqlInt16.Xor (TestMax, TestMax).Value);
389                         AssertEquals ("Test#5", TestMax.Value, SqlInt16.Xor (TestMax, Test0).Value);
390                 }
391
392                 // OPERATORS
393
394                 [Test]
395                 public void ArithmeticOperators()
396                 {
397                         SqlInt16 Test24 = new SqlInt16 (24);
398                         SqlInt16 Test64 = new SqlInt16 (64);
399                         SqlInt16 Test2550 = new SqlInt16 (2550);
400                         SqlInt16 Test0 = new SqlInt16 (0);
401
402                         // "+"-operator
403                         AssertEquals ("TestA#1", (SqlInt16)2614,Test2550 + Test64);
404                         try {
405                                 SqlInt16 result = Test64 + SqlInt16.MaxValue;
406                                 Fail ("TestA#2");
407                         } catch (Exception e) {
408                                 AssertEquals ("TestA#3", typeof (OverflowException), e.GetType ());
409                         }
410
411                         // "/"-operator
412                         AssertEquals ("TestB#1", (SqlInt16)39, Test2550 / Test64);
413                         AssertEquals ("TestB#2", (SqlInt16)0, Test24 / Test64);
414
415                         try {
416                                 SqlInt16 result = Test2550 / Test0;
417                                 Fail ("TestB#3");
418                         } catch (Exception e) {
419                                 AssertEquals ("TestB#4", typeof (DivideByZeroException), e.GetType ());
420                         }
421
422                         // "*"-operator
423                         AssertEquals ("TestC#1", (SqlInt16)1536, Test64 * Test24);
424
425                         try {
426                                 SqlInt16 test = (SqlInt16.MaxValue * Test64);
427                                 Fail ("TestC#2");
428                         } catch (Exception e) {
429                                 AssertEquals ("TestC#3", typeof (OverflowException), e.GetType ());
430                         }
431
432                         // "-"-operator
433                         AssertEquals ("TestD#1", (SqlInt16)2526, Test2550 - Test24);
434
435                         try {
436                                 SqlInt16 test = SqlInt16.MinValue - Test64;
437                                 Fail ("TestD#2");
438                         } catch (Exception e) {
439                                 AssertEquals ("OverflowException", typeof (OverflowException), e.GetType ());
440                         }
441
442                         // "%"-operator
443                         AssertEquals ("TestE#1", (SqlInt16)54, Test2550 % Test64);
444                         AssertEquals ("TestE#2", (SqlInt16)24, Test24 % Test64);
445                         AssertEquals ("TestE#1", (SqlInt16)0, new SqlInt16 (100) % new SqlInt16 (10));
446                 }
447
448                 [Test]
449                 public void BitwiseOperators()
450                 {
451                         SqlInt16 Test2 = new SqlInt16 (2);
452                         SqlInt16 Test4 = new SqlInt16 (4);
453                         SqlInt16 Test2550 = new SqlInt16 (2550);
454
455                         // & -operator
456                         AssertEquals ("TestA#1", (SqlInt16)0, Test2 & Test4);
457                         AssertEquals ("TestA#2", (SqlInt16)2, Test2 & Test2550);
458                         AssertEquals ("TestA#3", (SqlInt16)0,  SqlInt16.MaxValue & SqlInt16.MinValue);
459
460                         // | -operator
461                         AssertEquals ("TestB#1", (SqlInt16)6,Test2 | Test4);
462                         AssertEquals ("TestB#2", (SqlInt16)2550, Test2 | Test2550);
463                         AssertEquals ("TestB#3", (SqlInt16)(-1), SqlInt16.MinValue | SqlInt16.MaxValue);
464
465                         //  ^ -operator
466                         AssertEquals("TestC#1", (SqlInt16)2546, (Test2550 ^ Test4));
467                         AssertEquals("TestC#2", (SqlInt16)6, (Test2 ^ Test4));
468                 }
469
470                 [Test]
471                 public void ThanOrEqualOperators()
472                 {
473                         SqlInt16 Test165 = new SqlInt16 (165);
474                         SqlInt16 Test100 = new SqlInt16 (100);
475                         SqlInt16 Test100II = new SqlInt16 (100);
476                         SqlInt16 Test255 = new SqlInt16 (2550);
477
478                         // == -operator
479                         Assert ("TestA#1", (Test100 == Test100II).Value);
480                         Assert ("TestA#2", !(Test165 == Test100).Value);
481                         Assert ("TestA#3", (Test165 == SqlInt16.Null).IsNull);
482
483                         // != -operator
484                         Assert ("TestB#1", !(Test100 != Test100II).Value);
485                         Assert ("TestB#2", (Test100 != Test255).Value);
486                         Assert ("TestB#3", (Test165 != Test255).Value);
487                         Assert ("TestB#4", (Test165 != SqlInt16.Null).IsNull);
488
489                         // > -operator
490                         Assert ("TestC#1", (Test165 > Test100).Value);
491                         Assert ("TestC#2", !(Test165 > Test255).Value);
492                         Assert ("TestC#3", !(Test100 > Test100II).Value);
493                         Assert ("TestC#4", (Test165 > SqlInt16.Null).IsNull);
494
495                         // >=  -operator
496                         Assert ("TestD#1", !(Test165 >= Test255).Value);
497                         Assert ("TestD#2", (Test255 >= Test165).Value);
498                         Assert ("TestD#3", (Test100 >= Test100II).Value);
499                         Assert ("TestD#4", (Test165 >= SqlInt16.Null).IsNull);
500
501                         // < -operator
502                         Assert ("TestE#1", !(Test165 < Test100).Value);
503                         Assert ("TestE#2", (Test165 < Test255).Value);
504                         Assert ("TestE#3", !(Test100 < Test100II).Value);
505                         Assert ("TestE#4", (Test165 < SqlInt16.Null).IsNull);
506
507                         // <= -operator
508                         Assert ("TestF#1", (Test165 <= Test255).Value);
509                         Assert ("TestF#2", !(Test255 <= Test165).Value);
510                         Assert ("TestF#3", (Test100 <= Test100II).Value);
511                         Assert ("TestF#4", (Test165 <= SqlInt16.Null).IsNull);
512                 }
513
514                 [Test]
515                 public void OnesComplementOperator()
516                 {
517                         SqlInt16 Test12 = new SqlInt16 (12);
518                         SqlInt16 Test128 = new SqlInt16 (128);
519
520                         AssertEquals ("Test#1", (SqlInt16)(-13), ~Test12);
521                         AssertEquals ("Test#2", (SqlInt16)(-129), ~Test128);
522                         AssertEquals ("Test#3", SqlInt16.Null, ~SqlInt16.Null);
523                 }
524
525                 [Test]
526                 public void UnaryNegation()
527                 {
528                         SqlInt16 Test = new SqlInt16 (2000);
529                         SqlInt16 TestNeg = new SqlInt16 (-3000);
530
531                         SqlInt16 Result = -Test;
532                         AssertEquals ("Test#1", (short)(-2000), Result.Value);
533
534                         Result = -TestNeg;
535                         AssertEquals ("Test#2", (short)3000, Result.Value);
536                 }
537
538                 [Test]
539                 public void SqlBooleanToSqlInt16()
540                 {
541                         SqlBoolean TestBoolean = new SqlBoolean (true);
542                         SqlInt16 Result;
543
544                         Result = (SqlInt16)TestBoolean;
545
546                         AssertEquals ("Test#1", (short)1, Result.Value);
547
548                         Result = (SqlInt16)SqlBoolean.Null;
549                         Assert ("Test#2", Result.IsNull);
550                 }
551
552                 [Test]
553                 public void SqlDecimalToSqlInt16()
554                 {
555                         SqlDecimal TestDecimal64 = new SqlDecimal (64);
556                         SqlDecimal TestDecimal900 = new SqlDecimal (90000);
557
558                         AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDecimal64).Value);
559                         AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDecimal.Null));
560
561                         try {
562                                 SqlInt16 test = (SqlInt16)TestDecimal900;
563                                 Fail ("Test#3");
564                         } catch (Exception e) {
565                                 AssertEquals("Test#4", typeof(OverflowException), e.GetType ());
566                         }
567                 }
568
569                 [Test]
570                 public void SqlDoubleToSqlInt16()
571                 {
572                         SqlDouble TestDouble64 = new SqlDouble (64);
573                         SqlDouble TestDouble900 = new SqlDouble (90000);
574
575                         AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDouble64).Value);
576                         AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDouble.Null));
577
578                         try {
579                                 SqlInt16 test = (SqlInt16)TestDouble900;
580                                 Fail ("Test#3");
581                         } catch (Exception e) {
582                                 AssertEquals("Test#4", typeof (OverflowException), e.GetType ());
583                         }
584                 }
585
586                 [Test]
587                 public void SqlIntToInt16()
588                 {
589                         SqlInt16 Test = new SqlInt16(12);
590                         Int16 Result = (Int16)Test;
591                         AssertEquals("Test#1", (short)12, Result);
592                 }
593
594                 [Test]
595                 public void SqlInt32ToSqlInt16()
596                 {
597                         SqlInt32 Test64 = new SqlInt32 (64);
598                         SqlInt32 Test900 = new SqlInt32 (90000);
599
600                         AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
601
602                         try {
603                                 SqlInt16 test = (SqlInt16)Test900;
604                                 Fail ("Test#2");
605                         } catch (Exception e) {
606                                 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
607                         }
608                 }
609
610                 [Test]
611                 public void SqlInt64ToSqlInt16()
612                 {
613                         SqlInt64 Test64 = new SqlInt64 (64);
614                         SqlInt64 Test900 = new SqlInt64 (90000);
615
616                         AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
617
618                         try {
619                                 SqlInt16 test = (SqlInt16)Test900;
620                                 Fail ("Test#2");
621                         } catch (Exception e) {
622                                 AssertEquals("Test#3", typeof (OverflowException), e.GetType ());
623                         }
624                 }
625
626                 [Test]
627                 public void SqlMoneyToSqlInt16()
628                 {
629                         SqlMoney TestMoney64 = new SqlMoney(64);
630                         SqlMoney TestMoney900 = new SqlMoney(90000);
631
632                         AssertEquals ("Test#1", (short)64, ((SqlInt16)TestMoney64).Value);
633
634                         try {
635                                 SqlInt16 test = (SqlInt16)TestMoney900;
636                                 Fail ("Test#2");
637                         } catch (Exception e) {
638                                 AssertEquals("test#3", typeof (OverflowException), e.GetType ());
639                         }
640                 }
641
642                 [Test]
643                 public void SqlSingleToSqlInt16()
644                 {
645                         SqlSingle TestSingle64 = new SqlSingle(64);
646                         SqlSingle TestSingle900 = new SqlSingle(90000);
647
648                         AssertEquals("Test#1", (short)64, ((SqlInt16)TestSingle64).Value);
649
650                         try {
651                                 SqlInt16 test = (SqlInt16)TestSingle900;
652                                 Fail ("Test#2");
653                         } catch (Exception e) {
654                                 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
655                         }
656                 }
657
658                 [Test]
659                 public void SqlStringToSqlInt16()
660                 {
661                         SqlString TestString = new SqlString("Test string");
662                         SqlString TestString100 = new SqlString("100");
663                         SqlString TestString1000 = new SqlString("100000");
664
665                         AssertEquals ("Test#1", (short)100, ((SqlInt16)TestString100).Value);
666
667                         try {
668                                 SqlInt16 test = (SqlInt16)TestString1000;
669                                 Fail ("Test#2");
670                         } catch(Exception e) {
671                                 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
672                         }
673
674                         try {
675                                 SqlInt16 test = (SqlInt16)TestString;
676                                 Fail ("Test#3");
677                         } catch(Exception e) {
678                                 AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
679                         }
680                 }
681
682                 [Test]
683                 public void ByteToSqlInt16()
684                 {
685                         short TestShort = 14;
686                         AssertEquals ("Test#1", (short)14, ((SqlInt16)TestShort).Value);
687                 }
688         }
689 }
690