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