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