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 {
48 SqlInt16 TestShort = new SqlInt16 (29);
49 Assert.AreEqual ((short)29, TestShort.Value, "Test#1");
51 TestShort = new SqlInt16 (-9000);
52 Assert.AreEqual ((short)-9000, TestShort.Value, "Test#2");
57 public void PublicFields()
59 Assert.AreEqual ((SqlInt16)32767, SqlInt16.MaxValue, "Test#1");
60 Assert.AreEqual ((SqlInt16)(-32768), SqlInt16.MinValue, "Test#2");
61 Assert.IsTrue (SqlInt16.Null.IsNull, "Test#3");
62 Assert.AreEqual ((short)0, SqlInt16.Zero.Value, "Test#4");
67 public void Properties()
69 SqlInt16 Test5443 = new SqlInt16 (5443);
70 SqlInt16 Test1 = new SqlInt16 (1);
71 Assert.IsTrue (SqlInt16.Null.IsNull, "Test#1");
72 Assert.AreEqual ((short)5443, Test5443.Value, "Test#2");
73 Assert.AreEqual ((short)1, Test1.Value, "Test#3");
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 Assert.AreEqual ((short)64, SqlInt16.Add (Test64, Test0).Value, "Test#1");
88 Assert.AreEqual ((short)228, SqlInt16.Add (Test64, Test164).Value, "Test#2");
89 Assert.AreEqual ((short)164, SqlInt16.Add (Test0, Test164).Value, "Test#3");
90 Assert.AreEqual ((short)SqlInt16.MaxValue, SqlInt16.Add (TestMax, Test0).Value, "Test#4");
93 SqlInt16.Add (TestMax, Test64);
94 Assert.Fail ("Test#5");
95 } catch (Exception e) {
96 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#6");
100 Assert.AreEqual ((short)2, SqlInt16.Divide (Test164, Test64).Value, "Test#7");
101 Assert.AreEqual ((short)0, SqlInt16.Divide (Test64, Test164).Value, "Test#8");
103 SqlInt16.Divide(Test64, Test0);
104 Assert.Fail ("Test#9");
105 } catch(Exception e) {
106 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "Test#10");
110 Assert.AreEqual ((SqlInt16)36, SqlInt16.Mod (Test164, Test64), "Test#11");
111 Assert.AreEqual ((SqlInt16)64, SqlInt16.Mod (Test64, Test164), "Test#12");
114 Assert.AreEqual ((short)10496, SqlInt16.Multiply (Test64, Test164).Value, "Test#13");
115 Assert.AreEqual ((short)0, SqlInt16.Multiply (Test64, Test0).Value, "Test#14");
118 SqlInt16.Multiply (TestMax, Test64);
119 Assert.Fail ("Test#15");
120 } catch(Exception e) {
121 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#16");
125 Assert.AreEqual ((short)100, SqlInt16.Subtract (Test164, Test64).Value, "Test#17");
128 SqlInt16.Subtract (SqlInt16.MinValue, Test164);
129 Assert.Fail("Test#18");
130 } catch(Exception e) {
131 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#19");
136 Assert.AreEqual ((SqlInt16)36, SqlInt16.Modulus (Test164, Test64), "Test#20");
137 Assert.AreEqual ((SqlInt16)64, SqlInt16.Modulus (Test64, Test164), "Test#21");
144 public void BitwiseMethods()
146 short MaxValue = SqlInt16.MaxValue.Value;
147 SqlInt16 TestInt = new SqlInt16 (0);
148 SqlInt16 TestIntMax = new SqlInt16 (MaxValue);
149 SqlInt16 TestInt2 = new SqlInt16 (10922);
150 SqlInt16 TestInt3 = new SqlInt16 (21845);
153 Assert.AreEqual ((short)21845, SqlInt16.BitwiseAnd (TestInt3, TestIntMax).Value, "Test#1");
154 Assert.AreEqual ((short)0, SqlInt16.BitwiseAnd (TestInt2, TestInt3).Value, "Test#2");
155 Assert.AreEqual ((short)10922, SqlInt16.BitwiseAnd (TestInt2, TestIntMax).Value, "Test#3");
158 Assert.AreEqual ((short)MaxValue, SqlInt16.BitwiseOr (TestInt2, TestInt3).Value, "Test#4");
159 Assert.AreEqual ((short)21845, SqlInt16.BitwiseOr (TestInt, TestInt3).Value, "Test#5");
160 Assert.AreEqual ((short)MaxValue, SqlInt16.BitwiseOr (TestIntMax, TestInt2).Value, "Test#6");
164 public void CompareTo()
166 SqlInt16 TestInt4000 = new SqlInt16 (4000);
167 SqlInt16 TestInt4000II = new SqlInt16 (4000);
168 SqlInt16 TestInt10 = new SqlInt16 (10);
169 SqlInt16 TestInt10000 = new SqlInt16 (10000);
170 SqlString TestString = new SqlString ("This is a test");
172 Assert.IsTrue (TestInt4000.CompareTo (TestInt10) > 0, "Test#1");
173 Assert.IsTrue (TestInt10.CompareTo (TestInt4000) < 0, "Test#2");
174 Assert.IsTrue (TestInt4000II.CompareTo (TestInt4000) == 0, "Test#3");
175 Assert.IsTrue (TestInt4000II.CompareTo (SqlInt16.Null) > 0, "Test#4");
178 TestInt10.CompareTo (TestString);
179 Assert.Fail ("Test#5");
180 } catch(Exception e) {
181 Assert.AreEqual (typeof (ArgumentException), e.GetType (), "Test#6");
186 public void EqualsMethod()
188 SqlInt16 Test0 = new SqlInt16 (0);
189 SqlInt16 Test158 = new SqlInt16 (158);
190 SqlInt16 Test180 = new SqlInt16 (180);
191 SqlInt16 Test180II = new SqlInt16 (180);
193 Assert.IsTrue (!Test0.Equals (Test158), "Test#1");
194 Assert.IsTrue (!Test158.Equals (Test180), "Test#2");
195 Assert.IsTrue (!Test180.Equals (new SqlString ("TEST")), "Test#3");
196 Assert.IsTrue (Test180.Equals (Test180II), "Test#4");
200 public void StaticEqualsMethod()
202 SqlInt16 Test34 = new SqlInt16 (34);
203 SqlInt16 Test34II = new SqlInt16 (34);
204 SqlInt16 Test15 = new SqlInt16 (15);
206 Assert.IsTrue (SqlInt16.Equals (Test34, Test34II).Value, "Test#1");
207 Assert.IsTrue (!SqlInt16.Equals (Test34, Test15).Value, "Test#2");
208 Assert.IsTrue (!SqlInt16.Equals (Test15, Test34II).Value, "Test#3");
212 public void GetHashCodeTest()
214 SqlInt16 Test15 = new SqlInt16 (15);
216 // FIXME: Better way to test GetHashCode()-methods
217 Assert.AreEqual (Test15.GetHashCode (), Test15.GetHashCode (), "Test#1");
221 public void GetTypeTest()
223 SqlInt16 Test = new SqlInt16 (84);
224 Assert.AreEqual ("System.Data.SqlTypes.SqlInt16", Test.GetType ().ToString (), "Test#1");
228 public void Greaters()
230 SqlInt16 Test10 = new SqlInt16 (10);
231 SqlInt16 Test10II = new SqlInt16 (10);
232 SqlInt16 Test110 = new SqlInt16 (110);
235 Assert.IsTrue (!SqlInt16.GreaterThan (Test10, Test110).Value, "Test#1");
236 Assert.IsTrue (SqlInt16.GreaterThan (Test110, Test10).Value, "Test#2");
237 Assert.IsTrue (!SqlInt16.GreaterThan (Test10II, Test10).Value, "Test#3");
239 // GreaterTharOrEqual ()
240 Assert.IsTrue (!SqlInt16.GreaterThanOrEqual (Test10, Test110).Value, "Test#4");
241 Assert.IsTrue (SqlInt16.GreaterThanOrEqual (Test110, Test10).Value, "Test#5");
242 Assert.IsTrue (SqlInt16.GreaterThanOrEqual (Test10II, Test10).Value, "Test#6");
246 public void Lessers()
248 SqlInt16 Test10 = new SqlInt16 (10);
249 SqlInt16 Test10II = new SqlInt16 (10);
250 SqlInt16 Test110 = new SqlInt16 (110);
253 Assert.IsTrue (SqlInt16.LessThan (Test10, Test110).Value, "Test#1");
254 Assert.IsTrue (!SqlInt16.LessThan (Test110, Test10).Value, "Test#2");
255 Assert.IsTrue (!SqlInt16.LessThan (Test10II, Test10).Value, "Test#3");
257 // LessThanOrEqual ()
258 Assert.IsTrue (SqlInt16.LessThanOrEqual (Test10, Test110).Value, "Test#4");
259 Assert.IsTrue (!SqlInt16.LessThanOrEqual (Test110, Test10).Value, "Test#5");
260 Assert.IsTrue (SqlInt16.LessThanOrEqual (Test10II, Test10).Value, "Test#6");
261 Assert.IsTrue (SqlInt16.LessThanOrEqual (Test10II, SqlInt16.Null).IsNull, "Test#7");
265 public void NotEquals()
267 SqlInt16 Test12 = new SqlInt16 (12);
268 SqlInt16 Test128 = new SqlInt16 (128);
269 SqlInt16 Test128II = new SqlInt16 (128);
271 Assert.IsTrue (SqlInt16.NotEquals (Test12, Test128).Value, "Test#1");
272 Assert.IsTrue (SqlInt16.NotEquals (Test128, Test12).Value, "Test#2");
273 Assert.IsTrue (SqlInt16.NotEquals (Test128II, Test12).Value, "Test#3");
274 Assert.IsTrue (!SqlInt16.NotEquals (Test128II, Test128).Value, "Test#4");
275 Assert.IsTrue (!SqlInt16.NotEquals (Test128, Test128II).Value, "Test#5");
276 Assert.IsTrue (SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull, "Test#6");
277 Assert.IsTrue (SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull, "Test#7");
281 public void OnesComplement()
283 SqlInt16 Test12 = new SqlInt16(12);
284 SqlInt16 Test128 = new SqlInt16(128);
286 Assert.AreEqual ((SqlInt16)(-13), SqlInt16.OnesComplement (Test12), "Test#1");
287 Assert.AreEqual ((SqlInt16)(-129), SqlInt16.OnesComplement (Test128), "Test#2");
294 SqlInt16.Parse (null);
295 Assert.Fail ("Test#1");
296 } catch (Exception e) {
297 Assert.AreEqual (typeof (ArgumentNullException), e.GetType (), "Test#2");
301 SqlInt16.Parse ("not-a-number");
302 Assert.Fail ("Test#3");
303 } catch (Exception e) {
304 Assert.AreEqual (typeof (FormatException), e.GetType (), "Test#4");
308 int OverInt = (int)SqlInt16.MaxValue + 1;
309 SqlInt16.Parse (OverInt.ToString ());
310 Assert.Fail ("Test#5");
311 } catch (Exception e) {
312 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#6");
315 Assert.AreEqual((short)150, SqlInt16.Parse ("150").Value, "Test#7");
319 public void Conversions()
321 SqlInt16 Test12 = new SqlInt16 (12);
322 SqlInt16 Test0 = new SqlInt16 (0);
323 SqlInt16 TestNull = SqlInt16.Null;
324 SqlInt16 Test1000 = new SqlInt16 (1000);
325 SqlInt16 Test288 = new SqlInt16(288);
328 Assert.IsTrue (Test12.ToSqlBoolean ().Value, "TestA#1");
329 Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "TestA#2");
330 Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "TestA#3");
333 Assert.AreEqual ((byte)12, Test12.ToSqlByte ().Value, "TestB#1");
334 Assert.AreEqual ((byte)0, Test0.ToSqlByte ().Value, "TestB#2");
337 SqlByte b = (byte)Test1000.ToSqlByte ();
338 Assert.Fail ("TestB#4");
339 } catch (Exception e) {
340 Assert.AreEqual (typeof (OverflowException), e.GetType (), "TestB#5");
344 Assert.AreEqual ((decimal)12, Test12.ToSqlDecimal ().Value, "TestC#1");
345 Assert.AreEqual ((decimal)0, Test0.ToSqlDecimal ().Value, "TestC#2");
346 Assert.AreEqual ((decimal)288, Test288.ToSqlDecimal ().Value, "TestC#3");
349 Assert.AreEqual ((double)12, Test12.ToSqlDouble ().Value, "TestD#1");
350 Assert.AreEqual ((double)0, Test0.ToSqlDouble ().Value, "TestD#2");
351 Assert.AreEqual ((double)1000, Test1000.ToSqlDouble ().Value, "TestD#3");
354 Assert.AreEqual ((int)12, Test12.ToSqlInt32 ().Value, "TestE#1");
355 Assert.AreEqual ((int)0, Test0.ToSqlInt32 ().Value, "TestE#2");
356 Assert.AreEqual ((int)288, Test288.ToSqlInt32().Value, "TestE#3");
359 Assert.AreEqual ((long)12, Test12.ToSqlInt64 ().Value, "TestF#1");
360 Assert.AreEqual ((long)0, Test0.ToSqlInt64 ().Value, "TestF#2");
361 Assert.AreEqual ((long)288, Test288.ToSqlInt64 ().Value, "TestF#3");
364 Assert.AreEqual (12.0000M, Test12.ToSqlMoney ().Value, "TestG#1");
365 Assert.AreEqual ((decimal)0, Test0.ToSqlMoney ().Value, "TestG#2");
366 Assert.AreEqual (288.0000M, Test288.ToSqlMoney ().Value, "TestG#3");
369 Assert.AreEqual ((float)12, Test12.ToSqlSingle ().Value, "TestH#1");
370 Assert.AreEqual ((float)0, Test0.ToSqlSingle ().Value, "TestH#2");
371 Assert.AreEqual ((float)288, Test288.ToSqlSingle().Value, "TestH#3");
374 Assert.AreEqual ("12", Test12.ToSqlString ().Value, "TestI#1");
375 Assert.AreEqual ("0", Test0.ToSqlString ().Value, "TestI#2");
376 Assert.AreEqual ("288", Test288.ToSqlString ().Value, "TestI#3");
379 Assert.AreEqual ("12", Test12.ToString (), "TestJ#1");
380 Assert.AreEqual ("0", Test0.ToString (), "TestJ#2");
381 Assert.AreEqual ("288", Test288.ToString (), "TestJ#3");
387 SqlInt16 Test14 = new SqlInt16 (14);
388 SqlInt16 Test58 = new SqlInt16 (58);
389 SqlInt16 Test130 = new SqlInt16 (130);
390 SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);
391 SqlInt16 Test0 = new SqlInt16 (0);
393 Assert.AreEqual ((short)52, SqlInt16.Xor (Test14, Test58).Value, "Test#1");
394 Assert.AreEqual ((short)140, SqlInt16.Xor (Test14, Test130).Value, "Test#2");
395 Assert.AreEqual ((short)184, SqlInt16.Xor (Test58, Test130).Value, "Test#3");
396 Assert.AreEqual ((short)0, SqlInt16.Xor (TestMax, TestMax).Value, "Test#4");
397 Assert.AreEqual (TestMax.Value, SqlInt16.Xor (TestMax, Test0).Value, "Test#5");
403 public void ArithmeticOperators()
405 SqlInt16 Test24 = new SqlInt16 (24);
406 SqlInt16 Test64 = new SqlInt16 (64);
407 SqlInt16 Test2550 = new SqlInt16 (2550);
408 SqlInt16 Test0 = new SqlInt16 (0);
411 Assert.AreEqual ((SqlInt16)2614,Test2550 + Test64, "TestA#1");
413 SqlInt16 result = Test64 + SqlInt16.MaxValue;
414 Assert.Fail ("TestA#2");
415 } catch (Exception e) {
416 Assert.AreEqual (typeof (OverflowException), e.GetType (), "TestA#3");
420 Assert.AreEqual ((SqlInt16)39, Test2550 / Test64, "TestB#1");
421 Assert.AreEqual ((SqlInt16)0, Test24 / Test64, "TestB#2");
424 SqlInt16 result = Test2550 / Test0;
425 Assert.Fail ("TestB#3");
426 } catch (Exception e) {
427 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "TestB#4");
431 Assert.AreEqual ((SqlInt16)1536, Test64 * Test24, "TestC#1");
434 SqlInt16 test = (SqlInt16.MaxValue * Test64);
435 Assert.Fail ("TestC#2");
436 } catch (Exception e) {
437 Assert.AreEqual (typeof (OverflowException), e.GetType (), "TestC#3");
441 Assert.AreEqual ((SqlInt16)2526, Test2550 - Test24, "TestD#1");
444 SqlInt16 test = SqlInt16.MinValue - Test64;
445 Assert.Fail ("TestD#2");
446 } catch (Exception e) {
447 Assert.AreEqual (typeof (OverflowException), e.GetType (), "OverflowException");
451 Assert.AreEqual ((SqlInt16)54, Test2550 % Test64, "TestE#1");
452 Assert.AreEqual ((SqlInt16)24, Test24 % Test64, "TestE#2");
453 Assert.AreEqual ((SqlInt16)0, new SqlInt16 (100) % new SqlInt16 (10), "TestE#1");
457 public void BitwiseOperators()
459 SqlInt16 Test2 = new SqlInt16 (2);
460 SqlInt16 Test4 = new SqlInt16 (4);
461 SqlInt16 Test2550 = new SqlInt16 (2550);
464 Assert.AreEqual ((SqlInt16)0, Test2 & Test4, "TestA#1");
465 Assert.AreEqual ((SqlInt16)2, Test2 & Test2550, "TestA#2");
466 Assert.AreEqual ((SqlInt16)0, SqlInt16.MaxValue & SqlInt16.MinValue, "TestA#3");
469 Assert.AreEqual ((SqlInt16)6,Test2 | Test4, "TestB#1");
470 Assert.AreEqual ((SqlInt16)2550, Test2 | Test2550, "TestB#2");
471 Assert.AreEqual ((SqlInt16)(-1), SqlInt16.MinValue | SqlInt16.MaxValue, "TestB#3");
474 Assert.AreEqual((SqlInt16)2546, (Test2550 ^ Test4), "TestC#1");
475 Assert.AreEqual((SqlInt16)6, (Test2 ^ Test4), "TestC#2");
479 public void ThanOrEqualOperators()
481 SqlInt16 Test165 = new SqlInt16 (165);
482 SqlInt16 Test100 = new SqlInt16 (100);
483 SqlInt16 Test100II = new SqlInt16 (100);
484 SqlInt16 Test255 = new SqlInt16 (2550);
487 Assert.IsTrue ((Test100 == Test100II).Value, "TestA#1");
488 Assert.IsTrue (!(Test165 == Test100).Value, "TestA#2");
489 Assert.IsTrue ((Test165 == SqlInt16.Null).IsNull, "TestA#3");
492 Assert.IsTrue (!(Test100 != Test100II).Value, "TestB#1");
493 Assert.IsTrue ((Test100 != Test255).Value, "TestB#2");
494 Assert.IsTrue ((Test165 != Test255).Value, "TestB#3");
495 Assert.IsTrue ((Test165 != SqlInt16.Null).IsNull, "TestB#4");
498 Assert.IsTrue ((Test165 > Test100).Value, "TestC#1");
499 Assert.IsTrue (!(Test165 > Test255).Value, "TestC#2");
500 Assert.IsTrue (!(Test100 > Test100II).Value, "TestC#3");
501 Assert.IsTrue ((Test165 > SqlInt16.Null).IsNull, "TestC#4");
504 Assert.IsTrue (!(Test165 >= Test255).Value, "TestD#1");
505 Assert.IsTrue ((Test255 >= Test165).Value, "TestD#2");
506 Assert.IsTrue ((Test100 >= Test100II).Value, "TestD#3");
507 Assert.IsTrue ((Test165 >= SqlInt16.Null).IsNull, "TestD#4");
510 Assert.IsTrue (!(Test165 < Test100).Value, "TestE#1");
511 Assert.IsTrue ((Test165 < Test255).Value, "TestE#2");
512 Assert.IsTrue (!(Test100 < Test100II).Value, "TestE#3");
513 Assert.IsTrue ((Test165 < SqlInt16.Null).IsNull, "TestE#4");
516 Assert.IsTrue ((Test165 <= Test255).Value, "TestF#1");
517 Assert.IsTrue (!(Test255 <= Test165).Value, "TestF#2");
518 Assert.IsTrue ((Test100 <= Test100II).Value, "TestF#3");
519 Assert.IsTrue ((Test165 <= SqlInt16.Null).IsNull, "TestF#4");
523 public void OnesComplementOperator()
525 SqlInt16 Test12 = new SqlInt16 (12);
526 SqlInt16 Test128 = new SqlInt16 (128);
528 Assert.AreEqual ((SqlInt16)(-13), ~Test12, "Test#1");
529 Assert.AreEqual ((SqlInt16)(-129), ~Test128, "Test#2");
530 Assert.AreEqual (SqlInt16.Null, ~SqlInt16.Null, "Test#3");
534 public void UnaryNegation()
536 SqlInt16 Test = new SqlInt16 (2000);
537 SqlInt16 TestNeg = new SqlInt16 (-3000);
539 SqlInt16 Result = -Test;
540 Assert.AreEqual ((short)(-2000), Result.Value, "Test#1");
543 Assert.AreEqual ((short)3000, Result.Value, "Test#2");
547 public void SqlBooleanToSqlInt16()
549 SqlBoolean TestBoolean = new SqlBoolean (true);
552 Result = (SqlInt16)TestBoolean;
554 Assert.AreEqual ((short)1, Result.Value, "Test#1");
556 Result = (SqlInt16)SqlBoolean.Null;
557 Assert.IsTrue (Result.IsNull, "Test#2");
561 public void SqlDecimalToSqlInt16()
563 SqlDecimal TestDecimal64 = new SqlDecimal (64);
564 SqlDecimal TestDecimal900 = new SqlDecimal (90000);
566 Assert.AreEqual ((short)64, ((SqlInt16)TestDecimal64).Value, "Test#1");
567 Assert.AreEqual (SqlInt16.Null, ((SqlInt16)SqlDecimal.Null), "Test#2");
570 SqlInt16 test = (SqlInt16)TestDecimal900;
571 Assert.Fail ("Test#3");
572 } catch (Exception e) {
573 Assert.AreEqual(typeof(OverflowException), e.GetType (), "Test#4");
578 public void SqlDoubleToSqlInt16()
580 SqlDouble TestDouble64 = new SqlDouble (64);
581 SqlDouble TestDouble900 = new SqlDouble (90000);
583 Assert.AreEqual ((short)64, ((SqlInt16)TestDouble64).Value, "Test#1");
584 Assert.AreEqual (SqlInt16.Null, ((SqlInt16)SqlDouble.Null), "Test#2");
587 SqlInt16 test = (SqlInt16)TestDouble900;
588 Assert.Fail ("Test#3");
589 } catch (Exception e) {
590 Assert.AreEqual(typeof (OverflowException), e.GetType (), "Test#4");
595 public void SqlIntToInt16()
597 SqlInt16 Test = new SqlInt16(12);
598 Int16 Result = (Int16)Test;
599 Assert.AreEqual((short)12, Result, "Test#1");
603 public void SqlInt32ToSqlInt16()
605 SqlInt32 Test64 = new SqlInt32 (64);
606 SqlInt32 Test900 = new SqlInt32 (90000);
608 Assert.AreEqual ((short)64, ((SqlInt16)Test64).Value, "Test#1");
611 SqlInt16 test = (SqlInt16)Test900;
612 Assert.Fail ("Test#2");
613 } catch (Exception e) {
614 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#3");
619 public void SqlInt64ToSqlInt16()
621 SqlInt64 Test64 = new SqlInt64 (64);
622 SqlInt64 Test900 = new SqlInt64 (90000);
624 Assert.AreEqual ((short)64, ((SqlInt16)Test64).Value, "Test#1");
627 SqlInt16 test = (SqlInt16)Test900;
628 Assert.Fail ("Test#2");
629 } catch (Exception e) {
630 Assert.AreEqual(typeof (OverflowException), e.GetType (), "Test#3");
635 public void SqlMoneyToSqlInt16()
637 SqlMoney TestMoney64 = new SqlMoney(64);
638 SqlMoney TestMoney900 = new SqlMoney(90000);
640 Assert.AreEqual ((short)64, ((SqlInt16)TestMoney64).Value, "Test#1");
643 SqlInt16 test = (SqlInt16)TestMoney900;
644 Assert.Fail ("Test#2");
645 } catch (Exception e) {
646 Assert.AreEqual(typeof (OverflowException), e.GetType (), "test#3");
651 public void SqlSingleToSqlInt16()
653 SqlSingle TestSingle64 = new SqlSingle(64);
654 SqlSingle TestSingle900 = new SqlSingle(90000);
656 Assert.AreEqual((short)64, ((SqlInt16)TestSingle64).Value, "Test#1");
659 SqlInt16 test = (SqlInt16)TestSingle900;
660 Assert.Fail ("Test#2");
661 } catch (Exception e) {
662 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#3");
667 public void SqlStringToSqlInt16()
669 SqlString TestString = new SqlString("Test string");
670 SqlString TestString100 = new SqlString("100");
671 SqlString TestString1000 = new SqlString("100000");
673 Assert.AreEqual ((short)100, ((SqlInt16)TestString100).Value, "Test#1");
676 SqlInt16 test = (SqlInt16)TestString1000;
677 Assert.Fail ("Test#2");
678 } catch(Exception e) {
679 Assert.AreEqual (typeof (OverflowException), e.GetType (), "Test#3");
683 SqlInt16 test = (SqlInt16)TestString;
684 Assert.Fail ("Test#3");
685 } catch(Exception e) {
686 Assert.AreEqual (typeof (FormatException), e.GetType (), "Test#4");
691 public void ByteToSqlInt16()
693 short TestShort = 14;
694 Assert.AreEqual ((short)14, ((SqlInt16)TestShort).Value, "Test#1");