2 // SqlInt16Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt16
5 // Ville Palo (vi64pa@koti.soon.fi)
6 // Martin Willemoes Hansen (mwh@sysrq.dk)
9 // (C) 2003 Martin Willemoes Hansen
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
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.
35 using NUnit.Framework;
37 using System.Data.SqlTypes;
39 namespace MonoTests.System.Data.SqlTypes
42 public class SqlInt16Test : Assertion {
48 SqlInt16 TestShort = new SqlInt16 (29);
49 AssertEquals ("Test#1", (short)29, TestShort.Value);
51 TestShort = new SqlInt16 (-9000);
52 AssertEquals ("Test#2", (short)-9000, TestShort.Value);
57 public void PublicFields()
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);
67 public void Properties()
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);
79 public void ArithmeticMethods()
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);
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);
93 SqlInt16.Add (TestMax, Test64);
95 } catch (Exception e) {
96 AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
100 AssertEquals ("Test#7", (short)2, SqlInt16.Divide (Test164, Test64).Value);
101 AssertEquals ("Test#8", (short)0, SqlInt16.Divide (Test64, Test164).Value);
103 SqlInt16.Divide(Test64, Test0);
105 } catch(Exception e) {
106 AssertEquals ("Test#10", typeof (DivideByZeroException), e.GetType ());
110 AssertEquals ("Test#11", (SqlInt16)36, SqlInt16.Mod (Test164, Test64));
111 AssertEquals ("Test#12", (SqlInt16)64, SqlInt16.Mod (Test64, Test164));
114 AssertEquals ("Test#13", (short)10496, SqlInt16.Multiply (Test64, Test164).Value);
115 AssertEquals ("Test#14", (short)0, SqlInt16.Multiply (Test64, Test0).Value);
118 SqlInt16.Multiply (TestMax, Test64);
120 } catch(Exception e) {
121 AssertEquals ("Test#16", typeof (OverflowException), e.GetType ());
125 AssertEquals ("Test#17", (short)100, SqlInt16.Subtract (Test164, Test64).Value);
128 SqlInt16.Subtract (SqlInt16.MinValue, Test164);
130 } catch(Exception e) {
131 AssertEquals ("Test#19", typeof (OverflowException), e.GetType ());
136 public void BitwiseMethods()
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);
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);
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);
156 public void CompareTo()
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");
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);
170 TestInt10.CompareTo (TestString);
172 } catch(Exception e) {
173 AssertEquals ("Test#6", typeof (ArgumentException), e.GetType ());
178 public void EqualsMethod()
180 SqlInt16 Test0 = new SqlInt16 (0);
181 SqlInt16 Test158 = new SqlInt16 (158);
182 SqlInt16 Test180 = new SqlInt16 (180);
183 SqlInt16 Test180II = new SqlInt16 (180);
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));
192 public void StaticEqualsMethod()
194 SqlInt16 Test34 = new SqlInt16 (34);
195 SqlInt16 Test34II = new SqlInt16 (34);
196 SqlInt16 Test15 = new SqlInt16 (15);
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);
204 public void GetHashCodeTest()
206 SqlInt16 Test15 = new SqlInt16 (15);
208 // FIXME: Better way to test GetHashCode()-methods
209 AssertEquals ("Test#1", Test15.GetHashCode (), Test15.GetHashCode ());
213 public void GetTypeTest()
215 SqlInt16 Test = new SqlInt16 (84);
216 AssertEquals ("Test#1", "System.Data.SqlTypes.SqlInt16", Test.GetType ().ToString ());
220 public void Greaters()
222 SqlInt16 Test10 = new SqlInt16 (10);
223 SqlInt16 Test10II = new SqlInt16 (10);
224 SqlInt16 Test110 = new SqlInt16 (110);
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);
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);
238 public void Lessers()
240 SqlInt16 Test10 = new SqlInt16 (10);
241 SqlInt16 Test10II = new SqlInt16 (10);
242 SqlInt16 Test110 = new SqlInt16 (110);
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);
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);
257 public void NotEquals()
259 SqlInt16 Test12 = new SqlInt16 (12);
260 SqlInt16 Test128 = new SqlInt16 (128);
261 SqlInt16 Test128II = new SqlInt16 (128);
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);
273 public void OnesComplement()
275 SqlInt16 Test12 = new SqlInt16(12);
276 SqlInt16 Test128 = new SqlInt16(128);
278 AssertEquals ("Test#1", (SqlInt16)(-13), SqlInt16.OnesComplement (Test12));
279 AssertEquals ("Test#2", (SqlInt16)(-129), SqlInt16.OnesComplement (Test128));
286 SqlInt16.Parse (null);
288 } catch (Exception e) {
289 AssertEquals ("Test#2", typeof (ArgumentNullException), e.GetType ());
293 SqlInt16.Parse ("not-a-number");
295 } catch (Exception e) {
296 AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
300 int OverInt = (int)SqlInt16.MaxValue + 1;
301 SqlInt16.Parse (OverInt.ToString ());
303 } catch (Exception e) {
304 AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
307 AssertEquals("Test#7", (short)150, SqlInt16.Parse ("150").Value);
311 public void Conversions()
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);
320 Assert ("TestA#1", Test12.ToSqlBoolean ().Value);
321 Assert ("TestA#2", !Test0.ToSqlBoolean ().Value);
322 Assert ("TestA#3", TestNull.ToSqlBoolean ().IsNull);
325 AssertEquals ("TestB#1", (byte)12, Test12.ToSqlByte ().Value);
326 AssertEquals ("TestB#2", (byte)0, Test0.ToSqlByte ().Value);
329 SqlByte b = (byte)Test1000.ToSqlByte ();
331 } catch (Exception e) {
332 AssertEquals ("TestB#5", typeof (OverflowException), e.GetType ());
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);
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);
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);
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);
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);
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);
366 AssertEquals ("TestI#1", "12", Test12.ToSqlString ().Value);
367 AssertEquals ("TestI#2", "0", Test0.ToSqlString ().Value);
368 AssertEquals ("TestI#3", "288", Test288.ToSqlString ().Value);
371 AssertEquals ("TestJ#1", "12", Test12.ToString ());
372 AssertEquals ("TestJ#2", "0", Test0.ToString ());
373 AssertEquals ("TestJ#3", "288", Test288.ToString ());
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);
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);
395 public void ArithmeticOperators()
397 SqlInt16 Test24 = new SqlInt16 (24);
398 SqlInt16 Test64 = new SqlInt16 (64);
399 SqlInt16 Test2550 = new SqlInt16 (2550);
400 SqlInt16 Test0 = new SqlInt16 (0);
403 AssertEquals ("TestA#1", (SqlInt16)2614,Test2550 + Test64);
405 SqlInt16 result = Test64 + SqlInt16.MaxValue;
407 } catch (Exception e) {
408 AssertEquals ("TestA#3", typeof (OverflowException), e.GetType ());
412 AssertEquals ("TestB#1", (SqlInt16)39, Test2550 / Test64);
413 AssertEquals ("TestB#2", (SqlInt16)0, Test24 / Test64);
416 SqlInt16 result = Test2550 / Test0;
418 } catch (Exception e) {
419 AssertEquals ("TestB#4", typeof (DivideByZeroException), e.GetType ());
423 AssertEquals ("TestC#1", (SqlInt16)1536, Test64 * Test24);
426 SqlInt16 test = (SqlInt16.MaxValue * Test64);
428 } catch (Exception e) {
429 AssertEquals ("TestC#3", typeof (OverflowException), e.GetType ());
433 AssertEquals ("TestD#1", (SqlInt16)2526, Test2550 - Test24);
436 SqlInt16 test = SqlInt16.MinValue - Test64;
438 } catch (Exception e) {
439 AssertEquals ("OverflowException", typeof (OverflowException), e.GetType ());
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));
449 public void BitwiseOperators()
451 SqlInt16 Test2 = new SqlInt16 (2);
452 SqlInt16 Test4 = new SqlInt16 (4);
453 SqlInt16 Test2550 = new SqlInt16 (2550);
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);
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);
466 AssertEquals("TestC#1", (SqlInt16)2546, (Test2550 ^ Test4));
467 AssertEquals("TestC#2", (SqlInt16)6, (Test2 ^ Test4));
471 public void ThanOrEqualOperators()
473 SqlInt16 Test165 = new SqlInt16 (165);
474 SqlInt16 Test100 = new SqlInt16 (100);
475 SqlInt16 Test100II = new SqlInt16 (100);
476 SqlInt16 Test255 = new SqlInt16 (2550);
479 Assert ("TestA#1", (Test100 == Test100II).Value);
480 Assert ("TestA#2", !(Test165 == Test100).Value);
481 Assert ("TestA#3", (Test165 == SqlInt16.Null).IsNull);
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);
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);
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);
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);
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);
515 public void OnesComplementOperator()
517 SqlInt16 Test12 = new SqlInt16 (12);
518 SqlInt16 Test128 = new SqlInt16 (128);
520 AssertEquals ("Test#1", (SqlInt16)(-13), ~Test12);
521 AssertEquals ("Test#2", (SqlInt16)(-129), ~Test128);
522 AssertEquals ("Test#3", SqlInt16.Null, ~SqlInt16.Null);
526 public void UnaryNegation()
528 SqlInt16 Test = new SqlInt16 (2000);
529 SqlInt16 TestNeg = new SqlInt16 (-3000);
531 SqlInt16 Result = -Test;
532 AssertEquals ("Test#1", (short)(-2000), Result.Value);
535 AssertEquals ("Test#2", (short)3000, Result.Value);
539 public void SqlBooleanToSqlInt16()
541 SqlBoolean TestBoolean = new SqlBoolean (true);
544 Result = (SqlInt16)TestBoolean;
546 AssertEquals ("Test#1", (short)1, Result.Value);
548 Result = (SqlInt16)SqlBoolean.Null;
549 Assert ("Test#2", Result.IsNull);
553 public void SqlDecimalToSqlInt16()
555 SqlDecimal TestDecimal64 = new SqlDecimal (64);
556 SqlDecimal TestDecimal900 = new SqlDecimal (90000);
558 AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDecimal64).Value);
559 AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDecimal.Null));
562 SqlInt16 test = (SqlInt16)TestDecimal900;
564 } catch (Exception e) {
565 AssertEquals("Test#4", typeof(OverflowException), e.GetType ());
570 public void SqlDoubleToSqlInt16()
572 SqlDouble TestDouble64 = new SqlDouble (64);
573 SqlDouble TestDouble900 = new SqlDouble (90000);
575 AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDouble64).Value);
576 AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDouble.Null));
579 SqlInt16 test = (SqlInt16)TestDouble900;
581 } catch (Exception e) {
582 AssertEquals("Test#4", typeof (OverflowException), e.GetType ());
587 public void SqlIntToInt16()
589 SqlInt16 Test = new SqlInt16(12);
590 Int16 Result = (Int16)Test;
591 AssertEquals("Test#1", (short)12, Result);
595 public void SqlInt32ToSqlInt16()
597 SqlInt32 Test64 = new SqlInt32 (64);
598 SqlInt32 Test900 = new SqlInt32 (90000);
600 AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
603 SqlInt16 test = (SqlInt16)Test900;
605 } catch (Exception e) {
606 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
611 public void SqlInt64ToSqlInt16()
613 SqlInt64 Test64 = new SqlInt64 (64);
614 SqlInt64 Test900 = new SqlInt64 (90000);
616 AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
619 SqlInt16 test = (SqlInt16)Test900;
621 } catch (Exception e) {
622 AssertEquals("Test#3", typeof (OverflowException), e.GetType ());
627 public void SqlMoneyToSqlInt16()
629 SqlMoney TestMoney64 = new SqlMoney(64);
630 SqlMoney TestMoney900 = new SqlMoney(90000);
632 AssertEquals ("Test#1", (short)64, ((SqlInt16)TestMoney64).Value);
635 SqlInt16 test = (SqlInt16)TestMoney900;
637 } catch (Exception e) {
638 AssertEquals("test#3", typeof (OverflowException), e.GetType ());
643 public void SqlSingleToSqlInt16()
645 SqlSingle TestSingle64 = new SqlSingle(64);
646 SqlSingle TestSingle900 = new SqlSingle(90000);
648 AssertEquals("Test#1", (short)64, ((SqlInt16)TestSingle64).Value);
651 SqlInt16 test = (SqlInt16)TestSingle900;
653 } catch (Exception e) {
654 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
659 public void SqlStringToSqlInt16()
661 SqlString TestString = new SqlString("Test string");
662 SqlString TestString100 = new SqlString("100");
663 SqlString TestString1000 = new SqlString("100000");
665 AssertEquals ("Test#1", (short)100, ((SqlInt16)TestString100).Value);
668 SqlInt16 test = (SqlInt16)TestString1000;
670 } catch(Exception e) {
671 AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
675 SqlInt16 test = (SqlInt16)TestString;
677 } catch(Exception e) {
678 AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
683 public void ByteToSqlInt16()
685 short TestShort = 14;
686 AssertEquals ("Test#1", (short)14, ((SqlInt16)TestShort).Value);