* All tests inherits from Assertion, and
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlStringTest.cs
1 // SqlStringTest.cs - NUnit Test Cases for System.Data.SqlTypes.SqlString
2 //
3 // Authors:
4 //   Ville Palo (vi64pa@koti.soon.fi)
5 //   Martin Willemoes Hansen (mwh@sysrq.dk)
6 //
7 // (C) 2002 Ville Palo
8 // (C) 2003 Martin Willemoes Hansen
9 // 
10
11 using NUnit.Framework;
12 using System;
13 using System.Data.SqlTypes;
14 using System.Globalization;
15 using System.Threading;
16
17 namespace MonoTests.System.Data.SqlTypes
18 {
19         [TestFixture]
20         public class SqlStringTest : Assertion {
21
22                 private SqlString Test1 = null;
23                 private SqlString Test2 = null;
24                 private SqlString Test3 = null;
25
26                 [SetUp]
27                 public void GetReady()
28                 {
29                         Test1 = new SqlString ("First TestString");
30                         Test2 = new SqlString ("This is just a test SqlString");
31                         Test3 = new SqlString ("This is just a test SqlString");
32                         Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-AU");
33                 }
34
35                 // Test constructor
36                 [Test]
37                 public void Create()
38                 {
39
40                         // SqlString (String)
41                         SqlString  TestString = new SqlString ("Test");
42                         AssertEquals ("#A01", "Test", TestString.Value);
43
44                         // SqlString (String, int)
45                         TestString = new SqlString ("Test", 2057);
46                         AssertEquals ("#A02", 2057, TestString.LCID);
47
48                         // SqlString (int, SqlCompareOptions, byte[])
49                         TestString = new SqlString (2057,
50                                                     SqlCompareOptions.BinarySort|SqlCompareOptions.IgnoreCase,
51                                                     new byte [2] {123, 221});
52                         AssertEquals ("#A03", 2057, TestString.CompareInfo.LCID);
53                         
54                         // SqlString(string, int, SqlCompareOptions)
55                         TestString = new SqlString ("Test", 2057, SqlCompareOptions.IgnoreNonSpace);
56                         Assert ("#A04", !TestString.IsNull);
57                         
58                         // SqlString (int, SqlCompareOptions, byte[], bool)
59                         TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [4] {100, 100, 200, 45}, true);
60                         AssertEquals ("#A05", (byte)63, TestString.GetNonUnicodeBytes () [0]);
61                         TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, false);
62                         AssertEquals ("#A06", (String)"qd", TestString.Value);
63                         
64                         // SqlString (int, SqlCompareOptions, byte[], int, int)
65                         TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, 0, 2);
66                         Assert ("#A07", !TestString.IsNull);
67
68                         try {
69                                 TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, 2, 1);
70                                 Fail ("#A07b");
71                         } catch (Exception e) {
72                                 AssertEquals ("#A07c", typeof (ArgumentOutOfRangeException), e.GetType ());
73                         }
74
75                         try {
76                                 TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, 0, 4);
77                                 Fail ("#A07d");
78                         } catch (Exception e) {
79                                 AssertEquals ("#A07e", typeof (ArgumentOutOfRangeException), e.GetType ());
80                         }
81
82                         // SqlString (int, SqlCompareOptions, byte[], int, int, bool)
83                         TestString = new SqlString (2057, SqlCompareOptions.IgnoreCase, new byte [3] {100, 111, 50}, 1, 2, false);
84                         AssertEquals ("#A08", "o2", TestString.Value);
85                         TestString = new SqlString (2057, SqlCompareOptions.IgnoreCase, new byte [3] {123, 111, 222}, 1, 2, true);
86                         Assert ("#A09", !TestString.IsNull);                        
87                 }
88
89                 // Test public fields
90                 [Test]
91                 public void PublicFields()
92                 {
93                         // BinarySort
94                         AssertEquals ("#B01", 32768, SqlString.BinarySort);
95                         
96                         // IgnoreCase
97                         AssertEquals ("#B02", 1, SqlString.IgnoreCase);
98                                       
99                         // IgnoreKanaType
100                         AssertEquals ("#B03", 8, SqlString.IgnoreKanaType);
101
102                         // IgnoreNonSpace
103                         AssertEquals ("#B04", 2, SqlString.IgnoreNonSpace);
104                         
105                         // IgnoreWidth
106                         AssertEquals ("#B05", 16, SqlString.IgnoreWidth);
107                         
108                         // Null
109                         Assert ("#B06", SqlString.Null.IsNull);
110                 }
111
112                 // Test properties
113                 [Test]
114                 public void Properties()
115                 {
116                         // CompareInfo
117                         AssertEquals ("#C01", 3081, Test1.CompareInfo.LCID);
118
119                         // CultureInfo
120                         AssertEquals ("#C02", 3081, Test1.CultureInfo.LCID);                
121                         
122                         // IsNull
123                         Assert ("#C03", !Test1.IsNull);
124                         Assert ("#C04", SqlString.Null.IsNull);
125                         
126                         // LCID
127                         AssertEquals ("#C05", 3081, Test1.LCID);
128                         
129                         // SqlCompareOptions
130                         AssertEquals ("#C06", "IgnoreCase, IgnoreKanaType, IgnoreWidth", 
131                                       Test1.SqlCompareOptions.ToString ());
132
133                         // Value
134                         AssertEquals ("#C07", "First TestString", Test1.Value);
135                 }
136
137                 // PUBLIC METHODS
138
139                 [Test]
140                 public void CompareTo()
141                 {
142                         SqlByte Test = new SqlByte (1);
143
144                         Assert ("#D01", Test1.CompareTo (Test3) < 0);
145                         Assert ("#D02", Test2.CompareTo (Test1) > 0);
146                         Assert ("#D03", Test2.CompareTo (Test3) == 0);
147                         Assert ("#D04", Test3.CompareTo (SqlString.Null) > 0);
148
149                         try {
150                                 Test1.CompareTo (Test);
151                                 Fail("#D05");
152                         } catch(Exception e) {                        
153                                 AssertEquals ("#D06", typeof (ArgumentException), e.GetType ());
154                         }
155                         
156                         SqlString T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
157                         SqlString T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
158                         
159                         try {
160                                 T1.CompareTo (T2);
161                                 Fail ("#D07");
162                         } catch (Exception e) {
163                                 AssertEquals ("#D08", typeof (SqlTypeException), e.GetType ());
164                         }
165                         
166                         // IgnoreCase
167                         T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
168                         T2 = new SqlString ("TEST", 2057, SqlCompareOptions.IgnoreCase);
169                         Assert ("#D09", T2.CompareTo (T1) == 0);
170                 
171                         T1 = new SqlString ("test", 2057);
172                         T2 = new SqlString ("TEST", 2057);
173                         Assert ("#D10", T2.CompareTo (T1) == 0);
174
175                         T1 = new SqlString ("test", 2057, SqlCompareOptions.None);
176                         T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
177                         Assert ("#D11", T2.CompareTo (T1) != 0);
178
179                         // IgnoreNonSpace
180                         T1 = new SqlString ("TESTñ", 2057, SqlCompareOptions.IgnoreNonSpace);
181                         T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace);
182                         Assert ("#D12", T2.CompareTo (T1) == 0);
183                 
184                         T1 = new SqlString ("TESTñ", 2057, SqlCompareOptions.None);
185                         T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.None);
186                         Assert ("#D13", T2.CompareTo (T1) != 0);
187
188                         // BinarySort
189                         T1 = new SqlString ("01_", 2057, SqlCompareOptions.BinarySort);
190                         T2 = new SqlString ("_01", 2057, SqlCompareOptions.BinarySort);
191                         Assert ("#D14", T1.CompareTo (T2) < 0);
192                         
193                         T1 = new SqlString ("01_", 2057, SqlCompareOptions.None);
194                         T2 = new SqlString ("_01", 2057, SqlCompareOptions.None);
195                         Assert ("#D15", T1.CompareTo (T2) > 0);                 
196                 }
197
198                 [Test]
199                 public void EqualsMethods()
200                 {
201                         Assert ("#E01", !Test1.Equals (Test2));
202                         Assert ("#E02", !Test3.Equals (Test1));
203                         Assert ("#E03", !Test2.Equals (new SqlString ("TEST")));
204                         Assert ("#E04", Test2.Equals (Test3));
205
206                         // Static Equals()-method
207                         Assert ("#E05", SqlString.Equals (Test2, Test3).Value);
208                         Assert ("#E06", !SqlString.Equals (Test1, Test2).Value);
209                 }
210
211                 [Test]
212                 public void GetHashCodeTest()
213                 {
214                         // FIXME: Better way to test HashCode
215                         AssertEquals ("#F01", Test1.GetHashCode (), 
216                                       Test1.GetHashCode ());
217                         Assert ("#F02", Test1.GetHashCode () != Test2.GetHashCode ());
218                         Assert ("#F03", Test2.GetHashCode () == Test2.GetHashCode ());
219                 }
220
221                 [Test]
222                 public void GetTypeTest()
223                 {
224                         AssertEquals ("#G01", "System.Data.SqlTypes.SqlString", 
225                                       Test1.GetType ().ToString ());
226                         AssertEquals ("#G02", "System.String", 
227                                       Test1.Value.GetType ().ToString ());
228                 }
229
230                 [Test]
231                 public void Greaters()
232                 {
233
234                         // GreateThan ()
235                         Assert ("#H01", !SqlString.GreaterThan (Test1, Test2).Value);
236                         Assert ("#H02", SqlString.GreaterThan (Test2, Test1).Value);
237                         Assert ("#H03", !SqlString.GreaterThan (Test2, Test3).Value);
238
239                         // GreaterTharOrEqual ()
240                         Assert ("#H04", !SqlString.GreaterThanOrEqual (Test1, Test2).Value);
241                         Assert ("#H05", SqlString.GreaterThanOrEqual (Test2, Test1).Value);
242                         Assert ("#H06", SqlString.GreaterThanOrEqual (Test2, Test3).Value);
243                 }
244
245                 [Test]
246                 public void Lessers()
247                 {
248                         // LessThan()
249                         Assert ("#I01", !SqlString.LessThan (Test2, Test3).Value);
250                         Assert ("#I02", !SqlString.LessThan (Test2, Test1).Value);
251                         Assert ("#I03", SqlString.LessThan (Test1, Test2).Value);
252
253                         // LessThanOrEqual ()
254                         Assert ("#I04", SqlString.LessThanOrEqual (Test1, Test2).Value);
255                         Assert ("#I05", !SqlString.LessThanOrEqual (Test2, Test1).Value);
256                         Assert ("#I06", SqlString.LessThanOrEqual (Test3, Test2).Value);
257                         Assert ("#I07", SqlString.LessThanOrEqual (Test2, SqlString.Null).IsNull);
258                 }
259
260                 [Test]
261                 public void NotEquals()
262                 {
263                         Assert ("#J01", SqlString.NotEquals (Test1, Test2).Value);
264                         Assert ("#J02", SqlString.NotEquals (Test2, Test1).Value);
265                         Assert ("#J03", SqlString.NotEquals (Test3, Test1).Value);
266                         Assert ("#J04", !SqlString.NotEquals (Test2, Test3).Value);
267
268                         Assert ("#J05", SqlString.NotEquals (SqlString.Null, Test3).IsNull);
269                 }
270
271                 [Test]
272                 public void Concat()
273                 {
274                         Test1 = new SqlString ("First TestString");
275                         Test2 = new SqlString ("This is just a test SqlString");
276                         Test3 = new SqlString ("This is just a test SqlString");
277
278                         AssertEquals ("#K01", 
279                               (SqlString)"First TestStringThis is just a test SqlString", 
280                               SqlString.Concat (Test1, Test2));
281
282                         AssertEquals ("#K02", SqlString.Null, 
283                                       SqlString.Concat (Test1, SqlString.Null));
284                 }
285
286                 [Test]
287                 public void Clone()
288                 {
289                         SqlString TestSqlString  = Test1.Clone ();
290                         AssertEquals ("#L01", Test1, TestSqlString);
291                 }
292
293                 [Test]
294                 public void CompareOptionsFromSqlCompareOptions()
295                 {
296                         AssertEquals ("#M01", CompareOptions.IgnoreCase,
297                                     SqlString.CompareOptionsFromSqlCompareOptions (
298                                     SqlCompareOptions.IgnoreCase));
299                         AssertEquals ("#M02", CompareOptions.IgnoreCase,
300                                     SqlString.CompareOptionsFromSqlCompareOptions (
301                                     SqlCompareOptions.IgnoreCase));
302                         try {
303                                 
304                                 CompareOptions test = SqlString.CompareOptionsFromSqlCompareOptions (
305                                     SqlCompareOptions.BinarySort);
306                                 Fail ("#M03");
307                         } catch (Exception e) {
308                                 AssertEquals ("#M04", typeof (ArgumentOutOfRangeException), e.GetType ());
309                         }
310                 }
311
312                 [Test]
313                 public void UnicodeBytes()
314                 {
315                         AssertEquals ("#N01", (byte)105, Test1.GetNonUnicodeBytes () [1]);
316                         AssertEquals ("#N02", (byte)32, Test1.GetNonUnicodeBytes () [5]);
317
318                         AssertEquals ("#N03", (byte)70, Test1.GetUnicodeBytes () [0]);
319                         AssertEquals ("#N03b", (byte)70, Test1.GetNonUnicodeBytes () [0]);
320                         AssertEquals ("#N03c", (byte)0, Test1.GetUnicodeBytes () [1]);
321                         AssertEquals ("#N03d", (byte)105, Test1.GetNonUnicodeBytes () [1]);
322                         AssertEquals ("#N03e", (byte)105, Test1.GetUnicodeBytes () [2]);
323                         AssertEquals ("#N03f", (byte)114, Test1.GetNonUnicodeBytes () [2]);
324                         AssertEquals ("#N03g", (byte)0, Test1.GetUnicodeBytes () [3]);
325                         AssertEquals ("#N03h", (byte)115, Test1.GetNonUnicodeBytes () [3]);
326                         AssertEquals ("#N03i", (byte)114, Test1.GetUnicodeBytes () [4]);
327                         AssertEquals ("#N03j", (byte)116, Test1.GetNonUnicodeBytes () [4]);
328
329                         AssertEquals ("#N04", (byte)105, Test1.GetUnicodeBytes () [2]);
330
331                         try {
332                                 byte test = Test1.GetUnicodeBytes () [105];
333                                 Fail ("#N05");
334                         } catch (Exception e) {
335                                 AssertEquals ("#N06", typeof (IndexOutOfRangeException), e.GetType());                                
336                         }
337                 }
338                       
339                 [Test]          
340                 public void Conversions()
341                 {
342
343                         SqlString String250 = new SqlString ("250");
344                         SqlString String9E300 = new SqlString ("9E+300");
345
346                         // ToSqlBoolean ()
347         
348                         try {
349                                 bool test = Test1.ToSqlBoolean ().Value;                              
350                                 Fail ("#01");
351                         } catch (Exception e) {
352                                 AssertEquals ("#01.5", typeof (FormatException), e.GetType());                                                                
353                         }
354                         
355                         Assert ("#O02", (new SqlString("1")).ToSqlBoolean ().Value);
356                         Assert ("#O03", !(new SqlString("0")).ToSqlBoolean ().Value);
357                         Assert ("#O04", (new SqlString("True")).ToSqlBoolean ().Value);
358                         Assert ("#O05", !(new SqlString("FALSE")).ToSqlBoolean ().Value);
359                         Assert ("#O06", SqlString.Null.ToSqlBoolean ().IsNull);
360
361                         // ToSqlByte ()
362                         try {
363                                 byte test = Test1.ToSqlByte ().Value;
364                                 Fail ("#07");
365                         } catch (Exception e) {
366                                 AssertEquals ("#O07.5", typeof (FormatException), e.GetType());    
367                         }
368
369                         AssertEquals ("#O08", (byte)250, String250.ToSqlByte ().Value);    
370                         try {
371                                 SqlByte b = (byte)(new SqlString ("2500")).ToSqlByte ();
372                                 Fail ("#O09");
373                         } catch (Exception e) {
374                                 AssertEquals ("#O10", typeof (OverflowException), e.GetType ());
375                         }
376
377                         // ToSqlDateTime
378                         AssertEquals ("#O11", 10, 
379                                       (new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day);
380                         
381                         // ToSqlDecimal ()
382                         try {
383                                 AssertEquals ("#O13", (decimal)250, Test1.ToSqlDecimal ().Value);
384                                 Fail ("#O14");
385                         } catch (Exception e) {
386                                 AssertEquals ("#O15", typeof (FormatException), e.GetType ());
387                         }
388
389                         AssertEquals ("#O16", (decimal)250, String250.ToSqlDecimal ().Value);
390
391                         try {
392                                 SqlDecimal test = String9E300.ToSqlDecimal ().Value;
393                                 Fail ("#O17");
394                         } catch (Exception e) {
395                                 AssertEquals ("#O18", typeof (FormatException), e.GetType ());
396                         }      
397
398                         // ToSqlDouble
399                         AssertEquals ("#O19", (SqlDouble)9E+300, String9E300.ToSqlDouble ());
400
401                         try {
402                                 SqlDouble test = (new SqlString ("4e400")).ToSqlDouble ();
403                                 Fail ("#O20");
404                         } catch (Exception e) {
405                                 AssertEquals ("#O21", typeof (OverflowException), e.GetType ());
406                         }
407
408                         // ToSqlGuid
409                         SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
410                         AssertEquals ("#O22", new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid ());
411
412                         try {
413                                 SqlGuid test = String9E300.ToSqlGuid ();
414                         } catch (Exception e) {
415                                 AssertEquals ("#O23", typeof (FormatException), e.GetType ());
416                         }
417                         
418                         // ToSqlInt16 ()
419                         AssertEquals ("#O24", (short)250, String250.ToSqlInt16 ().Value);
420
421                         try {
422                                 SqlInt16 test = String9E300.ToSqlInt16().Value;
423                                 Fail ("#O25");
424                         } catch (Exception e) {
425                                 AssertEquals ("#O26", typeof (FormatException), e.GetType ());
426                         }        
427
428                         // ToSqlInt32 ()
429                         AssertEquals ("#O27", (int)250, String250.ToSqlInt32 ().Value);
430
431                         try {
432                                 SqlInt32 test = String9E300.ToSqlInt32 ().Value;
433                                 Fail ("#O28");
434                         } catch (Exception e) { 
435                                 AssertEquals ("#O29", typeof (FormatException), e.GetType ());
436                         }
437
438                         try {
439                                 SqlInt32 test = Test1.ToSqlInt32 ().Value;
440                                 Fail ("#O30");
441                         } catch (Exception e) { 
442                                 AssertEquals ("#O31", typeof (FormatException), e.GetType ());
443                         }
444
445                         // ToSqlInt64 ()
446                         AssertEquals ("#O32", (long)250, String250.ToSqlInt64 ().Value);
447
448                         try {        
449                                 SqlInt64 test = String9E300.ToSqlInt64 ().Value;
450                                 Fail ("#O33");
451                         } catch (Exception e) {
452                                 AssertEquals ("#O34", typeof (FormatException), e.GetType ());
453                         }        
454
455                         // ToSqlMoney ()
456                         AssertEquals ("#O35", (decimal)250, String250.ToSqlMoney ().Value);
457
458                         try {
459                                 SqlMoney test = String9E300.ToSqlMoney ().Value;
460                                 Fail ("#O36");
461                         } catch (Exception e) {
462                                 AssertEquals ("#O37", typeof (FormatException), e.GetType ());
463                         }        
464
465                         // ToSqlSingle ()
466                         AssertEquals ("#O38", (float)250, String250.ToSqlSingle ().Value);
467
468                         try {
469                                 SqlSingle test = String9E300.ToSqlSingle().Value;
470                                 Fail ("#O39");
471                         } catch (Exception e) {
472                                 AssertEquals ("#O40", typeof (OverflowException), e.GetType ());
473                         }        
474
475                         // ToString ()
476                         AssertEquals ("#O41", "First TestString", Test1.ToString ());
477                 }
478
479                 // OPERATORS
480
481                 [Test]
482                 public void ArithmeticOperators()
483                 {
484                         SqlString TestString = new SqlString ("...Testing...");
485                         AssertEquals ("#P01", (SqlString)"First TestString...Testing...",
486                                       Test1 + TestString);
487                         AssertEquals ("#P02", SqlString.Null,
488                                       Test1 + SqlString.Null);
489                 }
490
491                 [Test]
492                 public void ThanOrEqualOperators()
493                 {
494                         // == -operator
495                         Assert ("#Q01", (Test2 == Test3).Value);
496                         Assert ("#Q02", !(Test1 == Test2).Value);
497                         Assert ("#Q03", (Test1 == SqlString.Null).IsNull);
498                         
499                         // != -operator
500                         Assert ("#Q04", !(Test3 != Test2).Value);
501                         Assert ("#Q05", !(Test2 != Test3).Value);
502                         Assert ("#Q06", (Test1 != Test3).Value);
503                         Assert ("#Q07", (Test1 != SqlString.Null).IsNull);
504
505                         // > -operator
506                         Assert ("#Q08", (Test2 > Test1).Value);
507                         Assert ("#Q09", !(Test1 > Test3).Value);
508                         Assert ("#Q10", !(Test2 > Test3).Value);
509                         Assert ("#Q11", (Test1 > SqlString.Null).IsNull);
510
511                         // >=  -operator
512                         Assert ("#Q12", !(Test1 >= Test3).Value);
513                         Assert ("#Q13", (Test3 >= Test1).Value);
514                         Assert ("#Q14", (Test2 >= Test3).Value);
515                         Assert ("#Q15", (Test1 >= SqlString.Null).IsNull);
516
517                         // < -operator
518                         Assert ("#Q16", (Test1 < Test2).Value);
519                         Assert ("#Q17", (Test1 < Test3).Value);
520                         Assert ("#Q18", !(Test2 < Test3).Value);
521                         Assert ("#Q19", (Test1 < SqlString.Null).IsNull);
522
523                         // <= -operator
524                         Assert ("#Q20", (Test1 <= Test3).Value);
525                         Assert ("#Q21", !(Test3 <= Test1).Value);
526                         Assert ("#Q22", (Test2 <= Test3).Value);
527                         Assert ("#Q23", (Test1 <= SqlString.Null).IsNull);
528                 }
529
530                 [Test]
531                 public void SqlBooleanToSqlString()
532                 {
533                         SqlBoolean TestBoolean = new SqlBoolean (true);
534                         SqlBoolean TestBoolean2 = new SqlBoolean (false);
535                         SqlString Result;
536
537                         Result = (SqlString)TestBoolean;
538                         AssertEquals ("#R01", "True", Result.Value);
539                         
540                         Result = (SqlString)TestBoolean2;
541                         AssertEquals ("#R02", "False", Result.Value);
542                         
543                         Result = (SqlString)SqlBoolean.Null;
544                         Assert ("#R03", Result.IsNull);
545                 }
546
547                 [Test]
548                 public void SqlByteToBoolean()
549                 {
550                         SqlByte TestByte = new SqlByte (250);
551                         AssertEquals ("#S01", "250", ((SqlString)TestByte).Value);
552                         try {
553                                 SqlString test = ((SqlString)SqlByte.Null).Value;
554                                 Fail ("#S02");
555                         } catch (Exception e) {
556                                 AssertEquals ("#S03", typeof (SqlNullValueException), e.GetType ());
557                         }
558                 }
559
560                 [Test]
561                 public void SqlDateTimeToSqlString()
562                 {                        
563                         Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-AU");
564                         SqlDateTime TestTime = new SqlDateTime(2002, 10, 22, 9, 52, 30);
565                         AssertEquals ("#T01", "22/10/2002 9:52:30 AM", ((SqlString)TestTime).Value);                        
566                 }
567                 
568                 [Test]
569                 public void SqlDecimalToSqlString()
570                 {
571                         SqlDecimal TestDecimal = new SqlDecimal (1000.2345);
572                         AssertEquals ("#U01", "1000.2345000000000", ((SqlString)TestDecimal).Value);
573                 }
574                 
575                 [Test]
576                 public void SqlDoubleToSqlString()
577                 {
578                         SqlDouble TestDouble = new SqlDouble (64E+64);
579                         AssertEquals ("#V01", "6.4E+65", ((SqlString)TestDouble).Value);
580                 }
581
582                 [Test]
583                 public void SqlGuidToSqlString()
584                 {
585                         byte [] b = new byte [16];
586                         b [0] = 100;
587                         b [1] = 64;
588                         SqlGuid TestGuid = new SqlGuid (b);
589                         
590                         AssertEquals ("#W01", "00004064-0000-0000-0000-000000000000", 
591                                       ((SqlString)TestGuid).Value);
592                         try {
593                                 SqlString test = ((SqlString)SqlGuid.Null).Value;
594                                 Fail ("#W02");
595                         } catch (Exception e) {
596                                 AssertEquals ("#W03", typeof (SqlNullValueException), e.GetType());
597                         }
598                 }
599                 
600                 [Test]
601                 public void SqlInt16ToSqlString()
602                 {
603                         SqlInt16 TestInt = new SqlInt16(20012);
604                         AssertEquals ("#X01", "20012", ((SqlString)TestInt).Value);
605                         try {
606                                 SqlString test = ((SqlString)SqlInt16.Null).Value;
607                                 Fail ("#X02");
608                         } catch (Exception e) {
609                                 AssertEquals ("#X03", typeof (SqlNullValueException), e.GetType ());                                
610                         }
611                 }
612                 
613                 [Test]
614                 public void SqlInt32ToSqlString()
615                 {
616                         SqlInt32 TestInt = new SqlInt32(-12456);
617                         AssertEquals ("#Y01", "-12456", ((SqlString)TestInt).Value);
618                         try {
619                                 SqlString test = ((SqlString)SqlInt32.Null).Value;
620                                 Fail ("#Y02");
621                         } catch (Exception e) {
622                                 AssertEquals ("#Y03", typeof (SqlNullValueException), e.GetType ());                                
623                         }
624                 }
625                 
626                 [Test]
627                 public void SqlInt64ToSqlString()
628                 {
629                         SqlInt64 TestInt = new SqlInt64(10101010);
630                         AssertEquals ("#Z01", "10101010", ((SqlString)TestInt).Value);
631                 }
632                 
633                 [Test]
634                 public void SqlMoneyToSqlString()
635                 {
636                         SqlMoney TestMoney = new SqlMoney (646464.6464);
637                         AssertEquals ("#AA01", "646464.6464", ((SqlString)TestMoney).Value);
638                 }
639                 
640                 [Test]
641                 public void SqlSingleToSqlString()
642                 {
643                         SqlSingle TestSingle = new SqlSingle (3E+20);
644                         AssertEquals ("#AB01", "3E+20", ((SqlString)TestSingle).Value);
645                 }
646                       
647                 [Test]                        
648                 public void SqlStringToString()
649                 {
650                         AssertEquals ("#AC01", "First TestString",(String)Test1);                        
651                 }
652
653                 [Test]
654                 public void StringToSqlString()
655                 {
656                         String TestString = "Test String";
657                         AssertEquals ("#AD01", "Test String", ((SqlString)TestString).Value);                        
658                 }                
659         }
660 }
661