2002-10-09 Ville Palo (vi64pa@koti.soon.fi)
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlInt64Test.cs
1 //
2 // SqlInt64Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt64
3 //
4 // Ville Palo (vi64pa@koti.soon.fi)
5 //
6 // (C) Ville Palo 2002
7 // 
8
9 using NUnit.Framework;
10 using System;
11 using System.Data.SqlTypes;
12
13 namespace MonoTests.System.Data.SqlTypes
14 {
15         public class SqlInt64Test : TestCase {
16
17                 public SqlInt64Test() : base ("System.Data.SqlTypes.SqlInt64") {}
18                 public SqlInt64Test(string name) : base(name) {}
19
20                 protected override void TearDown() {}
21
22                 protected override void SetUp() {}
23
24                 public static ITest Suite {
25                         get {
26                                 return new TestSuite(typeof(SqlInt64));
27                         }
28                 }
29
30                 // Test constructor
31                 public void TestCreate()
32                 {
33                         SqlInt64 TestLong = new SqlInt64 (29);
34                         AssertEquals ("#A01", (long)29, TestLong.Value);
35
36                         TestLong = new SqlInt64 (-9000);
37                         AssertEquals ("#A02", (long)-9000, TestLong.Value);
38                  }
39
40                 // Test public fields
41                 public void TestPublicFields()
42                 {
43                         AssertEquals ("#B01", (long)9223372036854775807, SqlInt64.MaxValue.Value);
44                         AssertEquals ("#B02", (long)(-9223372036854775808), SqlInt64.MinValue.Value);
45                         Assert ("#B03", SqlInt64.Null.IsNull);
46                         AssertEquals ("#B04", (long)0, SqlInt64.Zero.Value);
47                 }
48
49                 // Test properties
50                 public void TestProperties()
51                 {
52                         SqlInt64 Test5443 = new SqlInt64 (5443);
53                         SqlInt64 Test1 = new SqlInt64 (1);
54
55                         Assert ("#C01", SqlInt64.Null.IsNull);
56                         AssertEquals ("#C02", (long)5443, Test5443.Value);
57                         AssertEquals ("#C03", (long)1, Test1.Value);
58                 }
59
60                 // PUBLIC METHODS
61
62                 public void TestArithmeticMethods()
63                 {
64                         SqlInt64 Test64 = new SqlInt64 (64);
65                         SqlInt64 Test0 = new SqlInt64 (0);
66                         SqlInt64 Test164 = new SqlInt64 (164);
67                         SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
68
69                         // Add()
70                         AssertEquals ("#D01", (long)64, SqlInt64.Add (Test64, Test0).Value);
71                         AssertEquals ("#D02", (long)228, SqlInt64.Add (Test64, Test164).Value);
72                         AssertEquals ("#D03", (long)164, SqlInt64.Add (Test0, Test164).Value);
73                         AssertEquals ("#D04", (long)SqlInt64.MaxValue, SqlInt64.Add (TestMax, Test0).Value);
74
75                         try {
76                                 SqlInt64.Add (TestMax, Test64);
77                                 Fail ("#D05");
78                         } catch (Exception e) {
79                                 AssertEquals ("#D06", typeof (OverflowException), e.GetType ());
80                         }
81
82                         // Divide()
83                         AssertEquals ("#D07", (long)2, SqlInt64.Divide (Test164, Test64).Value);
84                         AssertEquals ("#D08", (long)0, SqlInt64.Divide (Test64, Test164).Value);
85
86                         try {
87                                 SqlInt64.Divide(Test64, Test0);
88                                 Fail ("#D09");
89                         } catch(Exception e) {
90                                 AssertEquals ("#D10", typeof (DivideByZeroException), e.GetType ());
91                         }
92
93                         // Mod()
94                         AssertEquals ("#D11", (SqlInt64)36, SqlInt64.Mod (Test164, Test64));
95                         AssertEquals ("#D12",  (SqlInt64)64, SqlInt64.Mod (Test64, Test164));
96
97                         // Multiply()
98                         AssertEquals ("#D13", (long)10496, SqlInt64.Multiply (Test64, Test164).Value);
99                         AssertEquals ("#D14", (long)0, SqlInt64.Multiply (Test64, Test0).Value);
100
101                         try {
102                                 SqlInt64.Multiply (TestMax, Test64);
103                                 Fail ("#D15");
104                         } catch(Exception e) {
105                                 AssertEquals ("#D16", typeof (OverflowException), e.GetType ());
106                         }
107
108                         // Subtract()
109                         AssertEquals ("#D17", (long)100, SqlInt64.Subtract (Test164, Test64).Value);
110
111                         try {
112                                 SqlInt64.Subtract (SqlInt64.MinValue, Test164);
113                                 Fail ("#D18");
114                         } catch(Exception e) {
115                                 AssertEquals ("#D19", typeof (OverflowException), e.GetType ());
116                         }
117                 }
118
119                 public void TestBitwiseMethods()
120                 {
121                         long MaxValue = SqlInt64.MaxValue.Value;
122                         SqlInt64 TestInt = new SqlInt64 (0);
123                         SqlInt64 TestIntMax = new SqlInt64 (MaxValue);
124                         SqlInt64 TestInt2 = new SqlInt64 (10922);
125                         SqlInt64 TestInt3 = new SqlInt64 (21845);
126
127                         // BitwiseAnd
128                         AssertEquals ("#E01", (long)21845, SqlInt64.BitwiseAnd (TestInt3, TestIntMax).Value);
129                         AssertEquals ("#E02", (long)0, SqlInt64.BitwiseAnd (TestInt2, TestInt3).Value);
130                         AssertEquals ("#E03", (long)10922, SqlInt64.BitwiseAnd (TestInt2, TestIntMax).Value);
131
132                         //BitwiseOr
133                         AssertEquals ("#E04", (long)21845, SqlInt64.BitwiseOr (TestInt, TestInt3).Value);
134                         AssertEquals ("#E05", (long)MaxValue, SqlInt64.BitwiseOr (TestIntMax, TestInt2).Value);
135                 }
136
137                 public void TestCompareTo()
138                 {
139                         SqlInt64 TestInt4000 = new SqlInt64 (4000);
140                         SqlInt64 TestInt4000II = new SqlInt64 (4000);
141                         SqlInt64 TestInt10 = new SqlInt64 (10);
142                         SqlInt64 TestInt10000 = new SqlInt64 (10000);
143                         SqlString TestString = new SqlString ("This is a test");
144
145                         Assert ("#F01", TestInt4000.CompareTo (TestInt10) > 0);
146                         Assert ("#F02", TestInt10.CompareTo (TestInt4000) < 0);
147                         Assert ("#F03", TestInt4000II.CompareTo (TestInt4000) == 0);
148                         Assert ("#F04", TestInt4000II.CompareTo (SqlInt64.Null) > 0);
149
150                         try {
151                                 TestInt10.CompareTo (TestString);
152                                 Fail("#F05");
153                         } catch(Exception e) {
154                                 AssertEquals ("#F06", typeof (ArgumentException), e.GetType ());
155                         }
156                 }
157
158                 public void TestEqualsMethod()
159                 {
160                         SqlInt64 Test0 = new SqlInt64 (0);
161                         SqlInt64 Test158 = new SqlInt64 (158);
162                         SqlInt64 Test180 = new SqlInt64 (180);
163                         SqlInt64 Test180II = new SqlInt64 (180);
164
165                         Assert ("#G01", !Test0.Equals (Test158));
166                         Assert ("#G01", !Test158.Equals (Test180));
167                         Assert ("#G03", !Test180.Equals (new SqlString ("TEST")));
168                         Assert ("#G04", Test180.Equals (Test180II));
169                 }
170
171                 public void TestStaticEqualsMethod()
172                 {
173                         SqlInt64 Test34 = new SqlInt64 (34);
174                         SqlInt64 Test34II = new SqlInt64 (34);
175                         SqlInt64 Test15 = new SqlInt64 (15);
176
177                         Assert ("#H01", SqlInt64.Equals (Test34, Test34II).Value);
178                         Assert ("#H02", !SqlInt64.Equals (Test34, Test15).Value);
179                         Assert ("#H03", !SqlInt64.Equals (Test15, Test34II).Value);
180                 }
181
182                 public void TestGetHashCode()
183                 {
184                         SqlInt64 Test15 = new SqlInt64 (15);
185
186                         // FIXME: Better way to test HashCode
187                         AssertEquals ("#I01", (int)15, Test15.GetHashCode ());
188                 }
189
190                 public void TestGetType()
191                 {
192                         SqlInt64 Test = new SqlInt64 (84);
193                         AssertEquals ("#J01", "System.Data.SqlTypes.SqlInt64", Test.GetType ().ToString ());
194                 }
195
196                 public void TestGreaters()
197                 {
198                         SqlInt64 Test10 = new SqlInt64 (10);
199                         SqlInt64 Test10II = new SqlInt64 (10);
200                         SqlInt64 Test110 = new SqlInt64 (110);
201
202                         // GreateThan ()
203                         Assert ("#K01", !SqlInt64.GreaterThan (Test10, Test110).Value);
204                         Assert ("#K02", SqlInt64.GreaterThan (Test110, Test10).Value);
205                         Assert ("#K03", !SqlInt64.GreaterThan (Test10II, Test10).Value);
206
207                         // GreaterTharOrEqual ()
208                         Assert ("#K04", !SqlInt64.GreaterThanOrEqual (Test10, Test110).Value);
209                         Assert ("#K05", SqlInt64.GreaterThanOrEqual (Test110, Test10).Value);
210                         Assert ("#K06", SqlInt64.GreaterThanOrEqual (Test10II, Test10).Value);
211                 }
212
213                 public void TestLessers()
214                 {
215                         SqlInt64 Test10 = new SqlInt64 (10);
216                         SqlInt64 Test10II = new SqlInt64 (10);
217                         SqlInt64 Test110 = new SqlInt64 (110);
218
219                         // LessThan()
220                         Assert ("#L01", SqlInt64.LessThan (Test10, Test110).Value);
221                         Assert ("#L02", !SqlInt64.LessThan (Test110, Test10).Value);
222                         Assert ("#L03", !SqlInt64.LessThan (Test10II, Test10).Value);
223
224                         // LessThanOrEqual ()
225                         Assert ("#L04", SqlInt64.LessThanOrEqual (Test10, Test110).Value);
226                         Assert ("#L05", !SqlInt64.LessThanOrEqual (Test110, Test10).Value);
227                         Assert ("#L06", SqlInt64.LessThanOrEqual (Test10II, Test10).Value);
228                         Assert ("#L07", SqlInt64.LessThanOrEqual (Test10II, SqlInt64.Null).IsNull);
229                 }
230
231                 public void TestNotEquals()
232                 {
233                         SqlInt64 Test12 = new SqlInt64 (12);
234                         SqlInt64 Test128 = new SqlInt64 (128);
235                         SqlInt64 Test128II = new SqlInt64 (128);
236
237                         Assert ("#M01", SqlInt64.NotEquals (Test12, Test128).Value);
238                         Assert ("#M02", SqlInt64.NotEquals (Test128, Test12).Value);
239                         Assert ("#M03", SqlInt64.NotEquals (Test128II, Test12).Value);
240                         Assert ("#M04", !SqlInt64.NotEquals (Test128II, Test128).Value);
241                         Assert ("#M05", !SqlInt64.NotEquals (Test128, Test128II).Value);
242                         Assert ("#M06", SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull);
243                         Assert ("#M07", SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull);
244                 }
245
246                 public void TestOnesComplement()
247                 {
248                         SqlInt64 Test12 = new SqlInt64(12);
249                         SqlInt64 Test128 = new SqlInt64(128);
250
251                         AssertEquals ("#N01", (SqlInt64)(-13), SqlInt64.OnesComplement (Test12));
252                         AssertEquals ("#N02", (SqlInt64)(-129), SqlInt64.OnesComplement (Test128));
253                 }
254
255                 public void TestParse()
256                 {
257                         try {
258                                 SqlInt64.Parse (null);
259                                 Fail ("#O01");
260                         } catch (Exception e) {
261                                 AssertEquals ("#O02", typeof (ArgumentNullException), e.GetType ());
262                         }
263
264                         try {
265                                 SqlInt64.Parse ("not-a-number");
266                                 Fail ("#O03");
267                         } catch (Exception e) {
268                                 AssertEquals ("#O04", typeof (FormatException), e.GetType ());
269                         }
270
271                         try {
272                                 SqlInt64.Parse ("1000000000000000000000000000");
273                                 Fail ("#O05");
274                         } catch (Exception e) {
275                                 AssertEquals ("#O06", typeof (OverflowException), e.GetType ());
276                         }
277
278                         AssertEquals("#O07", (long)150, SqlInt64.Parse ("150").Value);
279                 }
280
281                 public void TestConversions()
282                 {
283                         SqlInt64 Test12 = new SqlInt64 (12);
284                         SqlInt64 Test0 = new SqlInt64 (0);
285                         SqlInt64 TestNull = SqlInt64.Null;
286                         SqlInt64 Test1000 = new SqlInt64 (1000);
287                         SqlInt64 Test288 = new SqlInt64(288);
288
289                         // ToSqlBoolean ()
290                         Assert ("#P01", Test12.ToSqlBoolean ().Value);
291                         Assert ("#P02", !Test0.ToSqlBoolean ().Value);
292                         Assert ("#P03", TestNull.ToSqlBoolean ().IsNull);
293
294                         // ToSqlByte ()
295                         AssertEquals ("#P04", (byte)12, Test12.ToSqlByte ().Value);
296                         AssertEquals ("#P05", (byte)0, Test0.ToSqlByte ().Value);
297
298                         try {
299                                 SqlByte b = (byte)Test1000.ToSqlByte ();
300                                 Fail ("#P06");
301                         } catch (Exception e) {
302                                 AssertEquals ("#P07", typeof (OverflowException), e.GetType ());
303                         }
304
305                         // ToSqlDecimal ()
306                         AssertEquals ("#P08", (decimal)12, Test12.ToSqlDecimal ().Value);
307                         AssertEquals ("#P09", (decimal)0, Test0.ToSqlDecimal ().Value);
308                         AssertEquals ("#P10", (decimal)288, Test288.ToSqlDecimal ().Value);
309
310                         // ToSqlDouble ()
311                         AssertEquals ("#P11", (double)12, Test12.ToSqlDouble ().Value);
312                         AssertEquals ("#P12", (double)0, Test0.ToSqlDouble ().Value);
313                         AssertEquals ("#P13", (double)1000, Test1000.ToSqlDouble ().Value);
314
315                         // ToSqlInt32 ()
316                         AssertEquals ("#P14", (int)12, Test12.ToSqlInt32 ().Value);
317                         AssertEquals ("#P15", (int)0, Test0.ToSqlInt32 ().Value);
318                         AssertEquals ("#P16", (int)288, Test288.ToSqlInt32().Value);
319
320                         // ToSqlInt16 ()
321                         AssertEquals ("#P17", (short)12, Test12.ToSqlInt16 ().Value);
322                         AssertEquals ("#P18", (short)0, Test0.ToSqlInt16 ().Value);
323                         AssertEquals ("#P19", (short)288, Test288.ToSqlInt16 ().Value);
324
325                         // ToSqlMoney ()
326                         AssertEquals ("#P20", (decimal)12, Test12.ToSqlMoney ().Value);
327                         AssertEquals ("#P21", (decimal)0, Test0.ToSqlMoney ().Value);
328                         AssertEquals ("#P22", (decimal)288, Test288.ToSqlMoney ().Value);
329
330                         // ToSqlSingle ()
331                         AssertEquals ("#P23", (float)12, Test12.ToSqlSingle ().Value);
332                         AssertEquals ("#P24", (float)0, Test0.ToSqlSingle ().Value);
333                         AssertEquals ("#P25", (float)288, Test288.ToSqlSingle().Value);
334
335                         // ToSqlString ()
336                         AssertEquals ("#P26", "12", Test12.ToSqlString ().Value);
337                         AssertEquals ("#P27", "0", Test0.ToSqlString ().Value);
338                         AssertEquals ("#P28", "288", Test288.ToSqlString ().Value);
339
340                         // ToString ()
341                         AssertEquals ("#P29", "12", Test12.ToString ());
342                         AssertEquals ("#P30", "0", Test0.ToString ());
343                         AssertEquals ("#P31", "288", Test288.ToString ());
344                 }
345
346                 public void TestXor()
347                 {
348                         SqlInt64 Test14 = new SqlInt64 (14);
349                         SqlInt64 Test58 = new SqlInt64 (58);
350                         SqlInt64 Test130 = new SqlInt64 (130);
351                         SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
352                         SqlInt64 Test0 = new SqlInt64 (0);
353
354                         AssertEquals ("#Q01", (long)52, SqlInt64.Xor (Test14, Test58).Value);
355                         AssertEquals ("#Q02", (long)140, SqlInt64.Xor (Test14, Test130).Value);
356                         AssertEquals ("#Q03", (long)184, SqlInt64.Xor (Test58, Test130).Value);
357                         AssertEquals ("#Q04", (long)0, SqlInt64.Xor (TestMax, TestMax).Value);
358                         AssertEquals ("#Q05", TestMax.Value, SqlInt64.Xor (TestMax, Test0).Value);
359                 }
360
361                 // OPERATORS
362
363                 public void TestArithmeticOperators()
364                 {
365                         SqlInt64 Test24 = new SqlInt64 (24);
366                         SqlInt64 Test64 = new SqlInt64 (64);
367                         SqlInt64 Test2550 = new SqlInt64 (2550);
368                         SqlInt64 Test0 = new SqlInt64 (0);
369
370                         // "+"-operator
371                         AssertEquals ("#R01", (SqlInt64)2614,Test2550 + Test64);
372                         try {
373                                 SqlInt64 result = Test64 + SqlInt64.MaxValue;
374                                 Fail ("#R02");
375                         } catch (Exception e) {
376                                 AssertEquals ("#R03", typeof (OverflowException), e.GetType ());
377                         }
378
379                         // "/"-operator
380                         AssertEquals ("#R04", (SqlInt64)39, Test2550 / Test64);
381                         AssertEquals ("#R05", (SqlInt64)0, Test24 / Test64);
382
383                         try {
384                                 SqlInt64 result = Test2550 / Test0;
385                                 Fail ("#R06");
386                         } catch (Exception e) {
387                                 AssertEquals ("#R07", typeof (DivideByZeroException), e.GetType ());
388                         }
389
390                         // "*"-operator
391                         AssertEquals ("#R08", (SqlInt64)1536, Test64 * Test24);
392
393                         try {
394                                 SqlInt64 test = (SqlInt64.MaxValue * Test64);
395                                 Fail ("TestC#2");
396                         } catch (Exception e) {
397                                 AssertEquals ("#R08", typeof (OverflowException), e.GetType ());
398                         }
399
400                         // "-"-operator
401                         AssertEquals ("#R09", (SqlInt64)2526, Test2550 - Test24);
402
403                         try {
404                                 SqlInt64 test = SqlInt64.MinValue - Test64;
405                                 Fail ("#R10");
406                         } catch (Exception e) {
407                                 AssertEquals ("#R11", typeof (OverflowException), e.GetType ());
408                         }
409
410                         // "%"-operator
411                         AssertEquals ("#R12", (SqlInt64)54, Test2550 % Test64);
412                         AssertEquals ("#R13", (SqlInt64)24, Test24 % Test64);
413                         AssertEquals ("#R14", (SqlInt64)0, new SqlInt64 (100) % new SqlInt64 (10));
414                 }
415
416                 public void TestBitwiseOperators()
417                 {
418                         SqlInt64 Test2 = new SqlInt64 (2);
419                         SqlInt64 Test4 = new SqlInt64 (4);
420
421                         SqlInt64 Test2550 = new SqlInt64 (2550);
422
423                         // & -operator
424                         AssertEquals ("#S01", (SqlInt64)0, Test2 & Test4);
425                         AssertEquals ("#S02", (SqlInt64)2, Test2 & Test2550);
426                         AssertEquals ("#S03", (SqlInt64)0,  SqlInt64.MaxValue & SqlInt64.MinValue);
427
428                         // | -operator
429                         AssertEquals ("#S04", (SqlInt64)6,Test2 | Test4);
430                         AssertEquals ("#S05", (SqlInt64)2550, Test2 | Test2550);
431                         AssertEquals ("#S06", (SqlInt64)(-1), SqlInt64.MinValue | SqlInt64.MaxValue);
432
433                         //  ^ -operator
434                         AssertEquals("#S07", (SqlInt64)2546, (Test2550 ^ Test4));
435                         AssertEquals("#S08", (SqlInt64)6, (Test2 ^ Test4));
436                 }
437
438                 public void TestThanOrEqualOperators()
439                 {
440                         SqlInt64 Test165 = new SqlInt64 (165);
441                         SqlInt64 Test100 = new SqlInt64 (100);
442                         SqlInt64 Test100II = new SqlInt64 (100);
443                         SqlInt64 Test255 = new SqlInt64 (2550);
444
445                         // == -operator
446                         Assert ("#T01", (Test100 == Test100II).Value);
447                         Assert ("#T02", !(Test165 == Test100).Value);
448                         Assert ("#T03", (Test165 == SqlInt64.Null).IsNull);
449
450                         // != -operator
451                         Assert ("#T04", !(Test100 != Test100II).Value);
452                         Assert ("#T05", (Test100 != Test255).Value);
453                         Assert ("#T06", (Test165 != Test255).Value);
454                         Assert ("#T07", (Test165 != SqlInt64.Null).IsNull);
455
456                         // > -operator
457                         Assert ("#T08", (Test165 > Test100).Value);
458                         Assert ("#T09", !(Test165 > Test255).Value);
459                         Assert ("#T10", !(Test100 > Test100II).Value);
460                         Assert ("#T11", (Test165 > SqlInt64.Null).IsNull);
461
462                         // >=  -operator
463                         Assert ("#T12", !(Test165 >= Test255).Value);
464                         Assert ("#T13", (Test255 >= Test165).Value);
465                         Assert ("#T14", (Test100 >= Test100II).Value);
466                         Assert ("#T15", (Test165 >= SqlInt64.Null).IsNull);
467
468                         // < -operator
469                         Assert ("#T16", !(Test165 < Test100).Value);
470                         Assert ("#T17", (Test165 < Test255).Value);
471                         Assert ("#T18", !(Test100 < Test100II).Value);
472                         Assert ("#T19", (Test165 < SqlInt64.Null).IsNull);
473
474                         // <= -operator
475                         Assert ("#T20", (Test165 <= Test255).Value);
476                         Assert ("#T21", !(Test255 <= Test165).Value);
477                         Assert ("#T22", (Test100 <= Test100II).Value);
478                         Assert ("#T23", (Test165 <= SqlInt64.Null).IsNull);
479                 }
480
481                 public void TestOnesComplementOperator()
482                 {
483                         SqlInt64 Test12 = new SqlInt64 (12);
484                         SqlInt64 Test128 = new SqlInt64 (128);
485
486                         AssertEquals ("#V01", (SqlInt64)(-13), ~Test12);
487                         AssertEquals ("#V02", (SqlInt64)(-129), ~Test128);
488                         AssertEquals ("#V03", SqlInt64.Null, ~SqlInt64.Null);
489                 }
490
491                 public void TestUnaryNegation()
492                 {
493                         SqlInt64 Test = new SqlInt64 (2000);
494                         SqlInt64 TestNeg = new SqlInt64 (-3000);
495
496                         SqlInt64 Result = -Test;
497                         AssertEquals ("#W01", (long)(-2000), Result.Value);
498
499                         Result = -TestNeg;
500                         AssertEquals ("#W02", (long)3000, Result.Value);
501                 }
502
503                 public void TestSqlBooleanToSqlInt64()
504                 {
505                         SqlBoolean TestBoolean = new SqlBoolean (true);
506                         SqlInt64 Result;
507
508                         Result = (SqlInt64)TestBoolean;
509
510                         AssertEquals ("#X01", (long)1, Result.Value);
511
512                         Result = (SqlInt64)SqlBoolean.Null;
513                         Assert ("#X02", Result.IsNull);
514                 }
515
516                 public void TestSqlDecimalToSqlInt64()
517                 {
518                         SqlDecimal TestDecimal64 = new SqlDecimal (64);
519                         SqlDecimal TestDecimal900 = new SqlDecimal (90000);
520
521                         AssertEquals("#Y01", (long)64, ((SqlInt64)TestDecimal64).Value);
522                         AssertEquals("#Y02", SqlInt64.Null, ((SqlInt64)SqlDecimal.Null));
523
524                         try {
525                                 SqlInt64 test = (SqlInt64)SqlDecimal.MaxValue;
526                                 Fail("#Y03");
527                         } catch (Exception e) {
528                                 AssertEquals("#Y04", typeof(OverflowException), e.GetType());
529                         }
530                 }
531
532                 public void TestSqlDoubleToSqlInt64()
533                 {
534                         SqlDouble TestDouble64 = new SqlDouble (64);
535                         SqlDouble TestDouble900 = new SqlDouble (90000);
536
537                         AssertEquals ("#Z01", (long)64, ((SqlInt64)TestDouble64).Value);
538                         AssertEquals ("#Z02", SqlInt64.Null, ((SqlInt64)SqlDouble.Null));
539
540                         try {
541                                 SqlInt64 test = (SqlInt64)SqlDouble.MaxValue;
542                                 Fail ("#Z03");
543                         } catch (Exception e) {
544                                 AssertEquals("#Z04", typeof (OverflowException), e.GetType ());
545                         }
546                 }
547
548                 public void TestSql64IntToInt64()
549                 {
550                         SqlInt64 Test = new SqlInt64 (12);
551                         Int64 Result = (Int64)Test;
552                         AssertEquals ("#AA01", (long)12, Result);
553                 }
554
555                 public void TestSqlInt32ToSqlInt64()
556                 {
557                         SqlInt32 Test64 = new SqlInt32 (64);
558                         AssertEquals ("#AB01", (long)64, ((SqlInt64)Test64).Value);
559                 }
560
561                 public void TestSqlInt16ToSqlInt64()
562                 {
563                         SqlInt16 Test64 = new SqlInt16 (64);
564                         AssertEquals ("#AC01", (long)64, ((SqlInt64)Test64).Value);
565                 }
566
567                 public void TestSqlMoneyToSqlInt64()
568                 {
569                         SqlMoney TestMoney64 = new SqlMoney(64);
570                         AssertEquals ("#AD01", (long)64, ((SqlInt64)TestMoney64).Value);
571                 }
572
573                 public void TestSqlSingleToSqlInt64()
574                 {
575                         SqlSingle TestSingle64 = new SqlSingle (64);
576                         AssertEquals ("#AE01", (long)64, ((SqlInt64)TestSingle64).Value);
577                 }
578
579                 public void TestSqlStringToSqlInt64()
580                 {
581                         SqlString TestString = new SqlString ("Test string");
582                         SqlString TestString100 = new SqlString ("100");
583                         SqlString TestString1000 = new SqlString ("1000000000000000000000");
584
585                         AssertEquals ("#AF01", (long)100, ((SqlInt64)TestString100).Value);
586
587                         try {
588                                 SqlInt64 test = (SqlInt64)TestString1000;
589                                 Fail ("#AF02");
590                         } catch(Exception e) {
591                                 AssertEquals ("#AF03", typeof (OverflowException), e.GetType ());
592                         }
593
594                         try {
595                                 SqlInt64 test = (SqlInt64)TestString;
596                                 Fail ("#AF03");
597                         } catch(Exception e) {
598                                 AssertEquals ("#AF04", typeof (FormatException), e.GetType ());
599                         }
600                 }
601
602                 public void TestByteToSqlInt64()
603                 {
604                         short TestShort = 14;
605                         AssertEquals ("#G01", (long)14, ((SqlInt64)TestShort).Value);
606                 }
607         }
608 }
609