2 // SqlInt64Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt64
5 // Ville Palo (vi64pa@koti.soon.fi)
6 // Martin Willemoes Hansen (mwh@sysrq.dk)
9 // (C) 2003 Martin Willemoes Hansen
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
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.
36 using System.Data.SqlTypes;
39 using System.Xml.Serialization;
43 using NUnit.Framework;
45 namespace MonoTests.System.Data.SqlTypes
48 public class SqlInt64Test
54 SqlInt64 TestLong = new SqlInt64 (29);
55 Assert.AreEqual ((long) 29, TestLong.Value, "#A01");
57 TestLong = new SqlInt64 (-9000);
58 Assert.AreEqual ((long) -9000, TestLong.Value, "#A02");
63 public void PublicFields ()
65 Assert.AreEqual ((long) 9223372036854775807, SqlInt64.MaxValue.Value, "#B01");
66 Assert.AreEqual ((long) (-9223372036854775808), SqlInt64.MinValue.Value, "#B02");
67 Assert.IsTrue (SqlInt64.Null.IsNull, "#B03");
68 Assert.AreEqual ((long) 0, SqlInt64.Zero.Value, "#B04");
73 public void Properties ()
75 SqlInt64 Test5443 = new SqlInt64 (5443);
76 SqlInt64 Test1 = new SqlInt64 (1);
78 Assert.IsTrue (SqlInt64.Null.IsNull, "#C01");
79 Assert.AreEqual ((long) 5443, Test5443.Value, "#C02");
80 Assert.AreEqual ((long) 1, Test1.Value, "#C03");
86 public void ArithmeticMethods ()
88 SqlInt64 Test64 = new SqlInt64 (64);
89 SqlInt64 Test0 = new SqlInt64 (0);
90 SqlInt64 Test164 = new SqlInt64 (164);
91 SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
94 Assert.AreEqual ((long) 64, SqlInt64.Add (Test64, Test0).Value, "#D01");
95 Assert.AreEqual ((long) 228, SqlInt64.Add (Test64, Test164).Value, "#D02");
96 Assert.AreEqual ((long) 164, SqlInt64.Add (Test0, Test164).Value, "#D03");
97 Assert.AreEqual ((long) SqlInt64.MaxValue, SqlInt64.Add (TestMax, Test0).Value, "#D04");
100 SqlInt64.Add (TestMax, Test64);
101 Assert.Fail ("#D05");
102 } catch (OverflowException e) {
103 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D06");
107 Assert.AreEqual ((long) 2, SqlInt64.Divide (Test164, Test64).Value, "#D07");
108 Assert.AreEqual ((long) 0, SqlInt64.Divide (Test64, Test164).Value, "#D08");
111 SqlInt64.Divide (Test64, Test0);
112 Assert.Fail ("#D09");
113 } catch (DivideByZeroException e) {
114 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#D10");
118 Assert.AreEqual ((SqlInt64) 36, SqlInt64.Mod (Test164, Test64), "#D11");
119 Assert.AreEqual ((SqlInt64) 64, SqlInt64.Mod (Test64, Test164), "#D12");
122 Assert.AreEqual ((long) 10496, SqlInt64.Multiply (Test64, Test164).Value, "#D13");
123 Assert.AreEqual ((long) 0, SqlInt64.Multiply (Test64, Test0).Value, "#D14");
126 SqlInt64.Multiply (TestMax, Test64);
127 Assert.Fail ("#D15");
128 } catch (OverflowException e) {
129 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D16");
133 Assert.AreEqual ((long) 100, SqlInt64.Subtract (Test164, Test64).Value, "#D17");
136 SqlInt64.Subtract (SqlInt64.MinValue, Test164);
137 Assert.Fail ("#D18");
138 } catch (OverflowException e) {
139 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D19");
144 Assert.AreEqual ((SqlInt64)36, SqlInt64.Modulus (Test164, Test64), "#D20");
145 Assert.AreEqual ((SqlInt64)64, SqlInt64.Modulus (Test64, Test164), "#D21");
150 public void BitwiseMethods ()
152 long MaxValue = SqlInt64.MaxValue.Value;
153 SqlInt64 TestInt = new SqlInt64 (0);
154 SqlInt64 TestIntMax = new SqlInt64 (MaxValue);
155 SqlInt64 TestInt2 = new SqlInt64 (10922);
156 SqlInt64 TestInt3 = new SqlInt64 (21845);
159 Assert.AreEqual ((long) 21845, SqlInt64.BitwiseAnd (TestInt3, TestIntMax).Value, "#E01");
160 Assert.AreEqual ((long) 0, SqlInt64.BitwiseAnd (TestInt2, TestInt3).Value, "#E02");
161 Assert.AreEqual ((long) 10922, SqlInt64.BitwiseAnd (TestInt2, TestIntMax).Value, "#E03");
164 Assert.AreEqual ((long) 21845, SqlInt64.BitwiseOr (TestInt, TestInt3).Value, "#E04");
165 Assert.AreEqual ((long) MaxValue, SqlInt64.BitwiseOr (TestIntMax, TestInt2).Value, "#E05");
169 public void CompareTo ()
171 SqlInt64 TestInt4000 = new SqlInt64 (4000);
172 SqlInt64 TestInt4000II = new SqlInt64 (4000);
173 SqlInt64 TestInt10 = new SqlInt64 (10);
174 SqlInt64 TestInt10000 = new SqlInt64 (10000);
175 SqlString TestString = new SqlString ("This is a test");
177 Assert.IsTrue (TestInt4000.CompareTo (TestInt10) > 0, "#F01");
178 Assert.IsTrue (TestInt10.CompareTo (TestInt4000) < 0, "#F02");
179 Assert.IsTrue (TestInt4000II.CompareTo (TestInt4000) == 0, "#F03");
180 Assert.IsTrue (TestInt4000II.CompareTo (SqlInt64.Null) > 0, "#F04");
183 TestInt10.CompareTo (TestString);
184 Assert.Fail ("#F05");
185 } catch (ArgumentException e) {
186 Assert.AreEqual (typeof (ArgumentException), e.GetType (), "#F06");
191 public void EqualsMethod ()
193 SqlInt64 Test0 = new SqlInt64 (0);
194 SqlInt64 Test158 = new SqlInt64 (158);
195 SqlInt64 Test180 = new SqlInt64 (180);
196 SqlInt64 Test180II = new SqlInt64 (180);
198 Assert.IsTrue (!Test0.Equals (Test158), "#G01");
199 Assert.IsTrue (!Test158.Equals (Test180), "#G01");
200 Assert.IsTrue (!Test180.Equals (new SqlString ("TEST")), "#G03");
201 Assert.IsTrue (Test180.Equals (Test180II), "#G04");
205 public void StaticEqualsMethod ()
207 SqlInt64 Test34 = new SqlInt64 (34);
208 SqlInt64 Test34II = new SqlInt64 (34);
209 SqlInt64 Test15 = new SqlInt64 (15);
211 Assert.IsTrue (SqlInt64.Equals (Test34, Test34II).Value, "#H01");
212 Assert.IsTrue (!SqlInt64.Equals (Test34, Test15).Value, "#H02");
213 Assert.IsTrue (!SqlInt64.Equals (Test15, Test34II).Value, "#H03");
217 public void GetHashCodeTest ()
219 SqlInt64 Test15 = new SqlInt64 (15);
221 // FIXME: Better way to test HashCode
222 Assert.AreEqual ((int) 15, Test15.GetHashCode (), "#I01");
226 public void GetTypeTest ()
228 SqlInt64 Test = new SqlInt64 (84);
229 Assert.AreEqual ("System.Data.SqlTypes.SqlInt64", Test.GetType ().ToString (), "#J01");
233 public void Greaters ()
235 SqlInt64 Test10 = new SqlInt64 (10);
236 SqlInt64 Test10II = new SqlInt64 (10);
237 SqlInt64 Test110 = new SqlInt64 (110);
240 Assert.IsTrue (!SqlInt64.GreaterThan (Test10, Test110).Value, "#K01");
241 Assert.IsTrue (SqlInt64.GreaterThan (Test110, Test10).Value, "#K02");
242 Assert.IsTrue (!SqlInt64.GreaterThan (Test10II, Test10).Value, "#K03");
244 // GreaterTharOrEqual ()
245 Assert.IsTrue (!SqlInt64.GreaterThanOrEqual (Test10, Test110).Value, "#K04");
246 Assert.IsTrue (SqlInt64.GreaterThanOrEqual (Test110, Test10).Value, "#K05");
247 Assert.IsTrue (SqlInt64.GreaterThanOrEqual (Test10II, Test10).Value, "#K06");
251 public void Lessers ()
253 SqlInt64 Test10 = new SqlInt64 (10);
254 SqlInt64 Test10II = new SqlInt64 (10);
255 SqlInt64 Test110 = new SqlInt64 (110);
258 Assert.IsTrue (SqlInt64.LessThan (Test10, Test110).Value, "#L01");
259 Assert.IsTrue (!SqlInt64.LessThan (Test110, Test10).Value, "#L02");
260 Assert.IsTrue (!SqlInt64.LessThan (Test10II, Test10).Value, "#L03");
262 // LessThanOrEqual ()
263 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10, Test110).Value, "#L04");
264 Assert.IsTrue (!SqlInt64.LessThanOrEqual (Test110, Test10).Value, "#L05");
265 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10II, Test10).Value, "#L06");
266 Assert.IsTrue (SqlInt64.LessThanOrEqual (Test10II, SqlInt64.Null).IsNull, "#L07");
270 public void NotEquals ()
272 SqlInt64 Test12 = new SqlInt64 (12);
273 SqlInt64 Test128 = new SqlInt64 (128);
274 SqlInt64 Test128II = new SqlInt64 (128);
276 Assert.IsTrue (SqlInt64.NotEquals (Test12, Test128).Value, "#M01");
277 Assert.IsTrue (SqlInt64.NotEquals (Test128, Test12).Value, "#M02");
278 Assert.IsTrue (SqlInt64.NotEquals (Test128II, Test12).Value, "#M03");
279 Assert.IsTrue (!SqlInt64.NotEquals (Test128II, Test128).Value, "#M04");
280 Assert.IsTrue (!SqlInt64.NotEquals (Test128, Test128II).Value, "#M05");
281 Assert.IsTrue (SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull, "#M06");
282 Assert.IsTrue (SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull, "#M07");
286 public void OnesComplement ()
288 SqlInt64 Test12 = new SqlInt64 (12);
289 SqlInt64 Test128 = new SqlInt64 (128);
291 Assert.AreEqual ((SqlInt64) (-13), SqlInt64.OnesComplement (Test12), "#N01");
292 Assert.AreEqual ((SqlInt64) (-129), SqlInt64.OnesComplement (Test128), "#N02");
299 SqlInt64.Parse (null);
300 Assert.Fail ("#O01");
301 } catch (ArgumentNullException e) {
302 Assert.AreEqual (typeof (ArgumentNullException), e.GetType (), "#O02");
306 SqlInt64.Parse ("not-a-number");
307 Assert.Fail ("#O03");
308 } catch (FormatException e) {
309 Assert.AreEqual (typeof (FormatException), e.GetType (), "#O04");
313 SqlInt64.Parse ("1000000000000000000000000000");
314 Assert.Fail ("#O05");
315 } catch (OverflowException e) {
316 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#O06");
319 Assert.AreEqual ((long) 150, SqlInt64.Parse ("150").Value, "#O07");
323 public void Conversions ()
325 SqlInt64 Test12 = new SqlInt64 (12);
326 SqlInt64 Test0 = new SqlInt64 (0);
327 SqlInt64 TestNull = SqlInt64.Null;
328 SqlInt64 Test1000 = new SqlInt64 (1000);
329 SqlInt64 Test288 = new SqlInt64 (288);
332 Assert.IsTrue (Test12.ToSqlBoolean ().Value, "#P01");
333 Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "#P02");
334 Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "#P03");
337 Assert.AreEqual ((byte) 12, Test12.ToSqlByte ().Value, "#P04");
338 Assert.AreEqual ((byte) 0, Test0.ToSqlByte ().Value, "#P05");
341 SqlByte b = (byte) Test1000.ToSqlByte ();
342 Assert.Fail ("#P06");
343 } catch (OverflowException e) {
344 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#P07");
348 Assert.AreEqual ((decimal) 12, Test12.ToSqlDecimal ().Value, "#P08");
349 Assert.AreEqual ((decimal) 0, Test0.ToSqlDecimal ().Value, "#P09");
350 Assert.AreEqual ((decimal) 288, Test288.ToSqlDecimal ().Value, "#P10");
353 Assert.AreEqual ((double) 12, Test12.ToSqlDouble ().Value, "#P11");
354 Assert.AreEqual ((double) 0, Test0.ToSqlDouble ().Value, "#P12");
355 Assert.AreEqual ((double) 1000, Test1000.ToSqlDouble ().Value, "#P13");
358 Assert.AreEqual ((int) 12, Test12.ToSqlInt32 ().Value, "#P14");
359 Assert.AreEqual ((int) 0, Test0.ToSqlInt32 ().Value, "#P15");
360 Assert.AreEqual ((int) 288, Test288.ToSqlInt32 ().Value, "#P16");
363 Assert.AreEqual ((short) 12, Test12.ToSqlInt16 ().Value, "#P17");
364 Assert.AreEqual ((short) 0, Test0.ToSqlInt16 ().Value, "#P18");
365 Assert.AreEqual ((short) 288, Test288.ToSqlInt16 ().Value, "#P19");
368 Assert.AreEqual (12.0000M, Test12.ToSqlMoney ().Value, "#P20");
369 Assert.AreEqual ((decimal) 0, Test0.ToSqlMoney ().Value, "#P21");
370 Assert.AreEqual (288.0000M, Test288.ToSqlMoney ().Value, "#P22");
373 Assert.AreEqual ((float) 12, Test12.ToSqlSingle ().Value, "#P23");
374 Assert.AreEqual ((float) 0, Test0.ToSqlSingle ().Value, "#P24");
375 Assert.AreEqual ((float) 288, Test288.ToSqlSingle ().Value, "#P25");
378 Assert.AreEqual ("12", Test12.ToSqlString ().Value, "#P26");
379 Assert.AreEqual ("0", Test0.ToSqlString ().Value, "#P27");
380 Assert.AreEqual ("288", Test288.ToSqlString ().Value, "#P28");
383 Assert.AreEqual ("12", Test12.ToString (), "#P29");
384 Assert.AreEqual ("0", Test0.ToString (), "#P30");
385 Assert.AreEqual ("288", Test288.ToString (), "#P31");
391 SqlInt64 Test14 = new SqlInt64 (14);
392 SqlInt64 Test58 = new SqlInt64 (58);
393 SqlInt64 Test130 = new SqlInt64 (130);
394 SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
395 SqlInt64 Test0 = new SqlInt64 (0);
397 Assert.AreEqual ((long) 52, SqlInt64.Xor (Test14, Test58).Value, "#Q01");
398 Assert.AreEqual ((long) 140, SqlInt64.Xor (Test14, Test130).Value, "#Q02");
399 Assert.AreEqual ((long) 184, SqlInt64.Xor (Test58, Test130).Value, "#Q03");
400 Assert.AreEqual ((long) 0, SqlInt64.Xor (TestMax, TestMax).Value, "#Q04");
401 Assert.AreEqual (TestMax.Value, SqlInt64.Xor (TestMax, Test0).Value, "#Q05");
407 public void ArithmeticOperators ()
409 SqlInt64 Test24 = new SqlInt64 (24);
410 SqlInt64 Test64 = new SqlInt64 (64);
411 SqlInt64 Test2550 = new SqlInt64 (2550);
412 SqlInt64 Test0 = new SqlInt64 (0);
415 Assert.AreEqual ((SqlInt64) 2614, Test2550 + Test64, "#R01");
417 SqlInt64 result = Test64 + SqlInt64.MaxValue;
418 Assert.Fail ("#R02");
419 } catch (OverflowException e) {
420 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R03");
424 Assert.AreEqual ((SqlInt64) 39, Test2550 / Test64, "#R04");
425 Assert.AreEqual ((SqlInt64) 0, Test24 / Test64, "#R05");
428 SqlInt64 result = Test2550 / Test0;
429 Assert.Fail ("#R06");
430 } catch (DivideByZeroException e) {
431 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#R07");
435 Assert.AreEqual ((SqlInt64) 1536, Test64 * Test24, "#R08");
438 SqlInt64 test = (SqlInt64.MaxValue * Test64);
439 Assert.Fail ("TestC#2");
440 } catch (OverflowException e) {
441 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R08");
445 Assert.AreEqual ((SqlInt64) 2526, Test2550 - Test24, "#R09");
448 SqlInt64 test = SqlInt64.MinValue - Test64;
449 Assert.Fail ("#R10");
450 } catch (OverflowException e) {
451 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#R11");
455 Assert.AreEqual ((SqlInt64) 54, Test2550 % Test64, "#R12");
456 Assert.AreEqual ((SqlInt64) 24, Test24 % Test64, "#R13");
457 Assert.AreEqual ((SqlInt64) 0, new SqlInt64 (100) % new SqlInt64 (10), "#R14");
461 public void BitwiseOperators ()
463 SqlInt64 Test2 = new SqlInt64 (2);
464 SqlInt64 Test4 = new SqlInt64 (4);
466 SqlInt64 Test2550 = new SqlInt64 (2550);
469 Assert.AreEqual ((SqlInt64) 0, Test2 & Test4, "#S01");
470 Assert.AreEqual ((SqlInt64) 2, Test2 & Test2550, "#S02");
471 Assert.AreEqual ((SqlInt64) 0, SqlInt64.MaxValue & SqlInt64.MinValue, "#S03");
474 Assert.AreEqual ((SqlInt64) 6, Test2 | Test4, "#S04");
475 Assert.AreEqual ((SqlInt64) 2550, Test2 | Test2550, "#S05");
476 Assert.AreEqual ((SqlInt64) (-1), SqlInt64.MinValue | SqlInt64.MaxValue, "#S06");
479 Assert.AreEqual ((SqlInt64) 2546, (Test2550 ^ Test4), "#S07");
480 Assert.AreEqual ((SqlInt64) 6, (Test2 ^ Test4), "#S08");
484 public void ThanOrEqualOperators ()
486 SqlInt64 Test165 = new SqlInt64 (165);
487 SqlInt64 Test100 = new SqlInt64 (100);
488 SqlInt64 Test100II = new SqlInt64 (100);
489 SqlInt64 Test255 = new SqlInt64 (2550);
492 Assert.IsTrue ((Test100 == Test100II).Value, "#T01");
493 Assert.IsTrue (!(Test165 == Test100).Value, "#T02");
494 Assert.IsTrue ((Test165 == SqlInt64.Null).IsNull, "#T03");
497 Assert.IsTrue (!(Test100 != Test100II).Value, "#T04");
498 Assert.IsTrue ((Test100 != Test255).Value, "#T05");
499 Assert.IsTrue ((Test165 != Test255).Value, "#T06");
500 Assert.IsTrue ((Test165 != SqlInt64.Null).IsNull, "#T07");
503 Assert.IsTrue ((Test165 > Test100).Value, "#T08");
504 Assert.IsTrue (!(Test165 > Test255).Value, "#T09");
505 Assert.IsTrue (!(Test100 > Test100II).Value, "#T10");
506 Assert.IsTrue ((Test165 > SqlInt64.Null).IsNull, "#T11");
509 Assert.IsTrue (!(Test165 >= Test255).Value, "#T12");
510 Assert.IsTrue ((Test255 >= Test165).Value, "#T13");
511 Assert.IsTrue ((Test100 >= Test100II).Value, "#T14");
512 Assert.IsTrue ((Test165 >= SqlInt64.Null).IsNull, "#T15");
515 Assert.IsTrue (!(Test165 < Test100).Value, "#T16");
516 Assert.IsTrue ((Test165 < Test255).Value, "#T17");
517 Assert.IsTrue (!(Test100 < Test100II).Value, "#T18");
518 Assert.IsTrue ((Test165 < SqlInt64.Null).IsNull, "#T19");
521 Assert.IsTrue ((Test165 <= Test255).Value, "#T20");
522 Assert.IsTrue (!(Test255 <= Test165).Value, "#T21");
523 Assert.IsTrue ((Test100 <= Test100II).Value, "#T22");
524 Assert.IsTrue ((Test165 <= SqlInt64.Null).IsNull, "#T23");
528 public void OnesComplementOperator ()
530 SqlInt64 Test12 = new SqlInt64 (12);
531 SqlInt64 Test128 = new SqlInt64 (128);
533 Assert.AreEqual ((SqlInt64) (-13), ~Test12, "#V01");
534 Assert.AreEqual ((SqlInt64) (-129), ~Test128, "#V02");
535 Assert.AreEqual (SqlInt64.Null, ~SqlInt64.Null, "#V03");
539 public void UnaryNegation ()
541 SqlInt64 Test = new SqlInt64 (2000);
542 SqlInt64 TestNeg = new SqlInt64 (-3000);
544 SqlInt64 Result = -Test;
545 Assert.AreEqual ((long) (-2000), Result.Value, "#W01");
548 Assert.AreEqual ((long) 3000, Result.Value, "#W02");
552 public void SqlBooleanToSqlInt64 ()
554 SqlBoolean TestBoolean = new SqlBoolean (true);
557 Result = (SqlInt64) TestBoolean;
559 Assert.AreEqual ((long) 1, Result.Value, "#X01");
561 Result = (SqlInt64) SqlBoolean.Null;
562 Assert.IsTrue (Result.IsNull, "#X02");
566 public void SqlDecimalToSqlInt64 ()
568 SqlDecimal TestDecimal64 = new SqlDecimal (64);
569 SqlDecimal TestDecimal900 = new SqlDecimal (90000);
571 Assert.AreEqual ((long) 64, ((SqlInt64) TestDecimal64).Value, "#Y01");
572 Assert.AreEqual (SqlInt64.Null, ((SqlInt64) SqlDecimal.Null), "#Y02");
575 SqlInt64 test = (SqlInt64) SqlDecimal.MaxValue;
576 Assert.Fail ("#Y03");
577 } catch (OverflowException e) {
578 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#Y04");
583 public void SqlDoubleToSqlInt64 ()
585 SqlDouble TestDouble64 = new SqlDouble (64);
586 SqlDouble TestDouble900 = new SqlDouble (90000);
588 Assert.AreEqual ((long) 64, ((SqlInt64) TestDouble64).Value, "#Z01");
589 Assert.AreEqual (SqlInt64.Null, ((SqlInt64) SqlDouble.Null), "#Z02");
592 SqlInt64 test = (SqlInt64) SqlDouble.MaxValue;
593 Assert.Fail ("#Z03");
594 } catch (OverflowException e) {
595 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#Z04");
600 public void Sql64IntToInt64 ()
602 SqlInt64 Test = new SqlInt64 (12);
603 Int64 Result = (Int64) Test;
604 Assert.AreEqual ((long) 12, Result, "#AA01");
608 public void SqlInt32ToSqlInt64 ()
610 SqlInt32 Test64 = new SqlInt32 (64);
611 Assert.AreEqual ((long) 64, ((SqlInt64) Test64).Value, "#AB01");
615 public void SqlInt16ToSqlInt64 ()
617 SqlInt16 Test64 = new SqlInt16 (64);
618 Assert.AreEqual ((long) 64, ((SqlInt64) Test64).Value, "#AC01");
622 public void SqlMoneyToSqlInt64 ()
624 SqlMoney TestMoney64 = new SqlMoney (64);
625 Assert.AreEqual ((long) 64, ((SqlInt64) TestMoney64).Value, "#AD01");
629 public void SqlSingleToSqlInt64 ()
631 SqlSingle TestSingle64 = new SqlSingle (64);
632 Assert.AreEqual ((long) 64, ((SqlInt64) TestSingle64).Value, "#AE01");
636 public void SqlStringToSqlInt64 ()
638 SqlString TestString = new SqlString ("Test string");
639 SqlString TestString100 = new SqlString ("100");
640 SqlString TestString1000 = new SqlString ("1000000000000000000000");
642 Assert.AreEqual ((long) 100, ((SqlInt64) TestString100).Value, "#AF01");
645 SqlInt64 test = (SqlInt64) TestString1000;
646 Assert.Fail ("#AF02");
647 } catch (OverflowException e) {
648 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#AF03");
652 SqlInt64 test = (SqlInt64) TestString;
653 Assert.Fail ("#AF03");
654 } catch (FormatException e) {
655 Assert.AreEqual (typeof (FormatException), e.GetType (), "#AF04");
660 public void ByteToSqlInt64 ()
662 short TestShort = 14;
663 Assert.AreEqual ((long) 14, ((SqlInt64) TestShort).Value, "#G01");
667 public void GetXsdTypeTest ()
669 XmlQualifiedName qualifiedName = SqlInt64.GetXsdType (null);
670 NUnit.Framework.Assert.AreEqual ("long", qualifiedName.Name, "#A01");
673 internal void ReadWriteXmlTestInternal (string xml,
685 test = new SqlInt64 (testval);
686 ser = new XmlSerializer(typeof(SqlInt64));
687 sw = new StringWriter ();
688 xw = new XmlTextWriter (sw);
690 ser.Serialize (xw, test);
692 // Assert.AreEqual (xml, sw.ToString (), unit_test_id);
694 sr = new StringReader (xml);
695 xr = new XmlTextReader (sr);
696 test1 = (SqlInt64)ser.Deserialize (xr);
698 Assert.AreEqual (testval, test1.Value, unit_test_id);
702 public void ReadWriteXmlTest ()
704 string xml1 = "<?xml version=\"1.0\" encoding=\"utf-16\"?><long>4556</long>";
705 string xml2 = "<?xml version=\"1.0\" encoding=\"utf-16\"?><long>-6445</long>";
706 string xml3 = "<?xml version=\"1.0\" encoding=\"utf-16\"?><long>0x455687AB3E4D56F</long>";
707 long lngtest1 = 4556;
708 long lngtest2 = -6445;
709 long lngtest3 = 0x455687AB3E4D56F;
711 ReadWriteXmlTestInternal (xml1, lngtest1, "BA01");
712 ReadWriteXmlTestInternal (xml2, lngtest2, "BA02");
715 ReadWriteXmlTestInternal (xml3, lngtest3, "BA03");
716 Assert.Fail ("BA03");
717 } catch (FormatException e) {
718 Assert.AreEqual (typeof (FormatException), e.GetType (), "#BA03");