2003-06-02 Ville Palo <vi64pa@kolumbus.fi>
[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                         // SqlString (int, SqlCompareOptions, byte[], int, int, bool)
69                         TestString = new SqlString (2057, SqlCompareOptions.IgnoreCase, new byte [3] {100, 111, 50}, 1, 2, false);
70                         AssertEquals ("#A08", "o2", TestString.Value);
71                         TestString = new SqlString (2057, SqlCompareOptions.IgnoreCase, new byte [3] {123, 111, 222}, 1, 2, true);
72                         Assert ("#A09", !TestString.IsNull);                        
73                 }
74
75                 [Test]
76                 [ExpectedException(typeof (ArgumentOutOfRangeException))]
77                 public void CtorArgumentOutOfRangeException1 ()
78                 {
79                         SqlString TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, 2, 1);
80                 }
81
82                 [Test]
83                 [ExpectedException(typeof (ArgumentOutOfRangeException))]
84                 public void CtorArgumentOutOfRangeException2 ()
85                 {
86                         SqlString TestString = new SqlString (2057, SqlCompareOptions.BinarySort, new byte [2] {113, 100}, 0, 4);
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
138                 // PUBLIC METHODS
139
140                 [Test]
141                 [ExpectedException(typeof(ArgumentException))]
142                 public void CompareToArgumentException ()
143                 {
144                         SqlByte Test = new SqlByte (1);
145                         Test1.CompareTo (Test);
146                 }
147
148                 [Test]
149                 [ExpectedException(typeof(SqlTypeException))]
150                 public void CompareToSqlTypeException ()
151                 {
152                         SqlString T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
153                         SqlString T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
154                         T1.CompareTo (T2);
155                 }
156
157                 [Test]
158                 public void CompareTo()
159                 {
160                         SqlByte Test = new SqlByte (1);
161
162                         Assert ("#D01", Test1.CompareTo (Test3) < 0);
163                         Assert ("#D02", Test2.CompareTo (Test1) > 0);
164                         Assert ("#D03", Test2.CompareTo (Test3) == 0);
165                         Assert ("#D04", Test3.CompareTo (SqlString.Null) > 0);
166
167                         
168                         SqlString T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
169                         SqlString T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
170                                                 
171                         // IgnoreCase
172                         T1 = new SqlString ("test", 2057, SqlCompareOptions.IgnoreCase);
173                         T2 = new SqlString ("TEST", 2057, SqlCompareOptions.IgnoreCase);
174                         Assert ("#D09", T2.CompareTo (T1) == 0);
175                 
176                         T1 = new SqlString ("test", 2057);
177                         T2 = new SqlString ("TEST", 2057);
178                         Assert ("#D10", T2.CompareTo (T1) == 0);
179
180                         T1 = new SqlString ("test", 2057, SqlCompareOptions.None);
181                         T2 = new SqlString ("TEST", 2057, SqlCompareOptions.None);
182                         Assert ("#D11", T2.CompareTo (T1) != 0);
183
184                         // IgnoreNonSpace
185                         T1 = new SqlString ("TESTñ", 2057, SqlCompareOptions.IgnoreNonSpace);
186                         T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.IgnoreNonSpace);
187                         Assert ("#D12", T2.CompareTo (T1) == 0);
188                 
189                         T1 = new SqlString ("TESTñ", 2057, SqlCompareOptions.None);
190                         T2 = new SqlString ("TESTn", 2057, SqlCompareOptions.None);
191                         Assert ("#D13", T2.CompareTo (T1) != 0);
192
193                         // BinarySort
194                         T1 = new SqlString ("01_", 2057, SqlCompareOptions.BinarySort);
195                         T2 = new SqlString ("_01", 2057, SqlCompareOptions.BinarySort);
196                         Assert ("#D14", T1.CompareTo (T2) < 0);
197                         
198                         T1 = new SqlString ("01_", 2057, SqlCompareOptions.None);
199                         T2 = new SqlString ("_01", 2057, SqlCompareOptions.None);
200                         Assert ("#D15", T1.CompareTo (T2) > 0);                 
201                 }
202
203                 [Test]
204                 public void EqualsMethods()
205                 {
206                         Assert ("#E01", !Test1.Equals (Test2));
207                         Assert ("#E02", !Test3.Equals (Test1));
208                         Assert ("#E03", !Test2.Equals (new SqlString ("TEST")));
209                         Assert ("#E04", Test2.Equals (Test3));
210
211                         // Static Equals()-method
212                         Assert ("#E05", SqlString.Equals (Test2, Test3).Value);
213                         Assert ("#E06", !SqlString.Equals (Test1, Test2).Value);
214                 }
215
216                 [Test]
217                 public void GetHashCodeTest()
218                 {
219                         // FIXME: Better way to test HashCode
220                         AssertEquals ("#F01", Test1.GetHashCode (), 
221                                       Test1.GetHashCode ());
222                         Assert ("#F02", Test1.GetHashCode () != Test2.GetHashCode ());
223                         Assert ("#F03", Test2.GetHashCode () == Test2.GetHashCode ());
224                 }
225
226                 [Test]
227                 public void GetTypeTest()
228                 {
229                         AssertEquals ("#G01", "System.Data.SqlTypes.SqlString", 
230                                       Test1.GetType ().ToString ());
231                         AssertEquals ("#G02", "System.String", 
232                                       Test1.Value.GetType ().ToString ());
233                 }
234
235                 [Test]
236                 public void Greaters()
237                 {
238
239                         // GreateThan ()
240                         Assert ("#H01", !SqlString.GreaterThan (Test1, Test2).Value);
241                         Assert ("#H02", SqlString.GreaterThan (Test2, Test1).Value);
242                         Assert ("#H03", !SqlString.GreaterThan (Test2, Test3).Value);
243
244                         // GreaterTharOrEqual ()
245                         Assert ("#H04", !SqlString.GreaterThanOrEqual (Test1, Test2).Value);
246                         Assert ("#H05", SqlString.GreaterThanOrEqual (Test2, Test1).Value);
247                         Assert ("#H06", SqlString.GreaterThanOrEqual (Test2, Test3).Value);
248                 }
249
250                 [Test]
251                 public void Lessers()
252                 {
253                         // LessThan()
254                         Assert ("#I01", !SqlString.LessThan (Test2, Test3).Value);
255                         Assert ("#I02", !SqlString.LessThan (Test2, Test1).Value);
256                         Assert ("#I03", SqlString.LessThan (Test1, Test2).Value);
257
258                         // LessThanOrEqual ()
259                         Assert ("#I04", SqlString.LessThanOrEqual (Test1, Test2).Value);
260                         Assert ("#I05", !SqlString.LessThanOrEqual (Test2, Test1).Value);
261                         Assert ("#I06", SqlString.LessThanOrEqual (Test3, Test2).Value);
262                         Assert ("#I07", SqlString.LessThanOrEqual (Test2, SqlString.Null).IsNull);
263                 }
264
265                 [Test]
266                 public void NotEquals()
267                 {
268                         Assert ("#J01", SqlString.NotEquals (Test1, Test2).Value);
269                         Assert ("#J02", SqlString.NotEquals (Test2, Test1).Value);
270                         Assert ("#J03", SqlString.NotEquals (Test3, Test1).Value);
271                         Assert ("#J04", !SqlString.NotEquals (Test2, Test3).Value);
272
273                         Assert ("#J05", SqlString.NotEquals (SqlString.Null, Test3).IsNull);
274                 }
275
276                 [Test]
277                 public void Concat()
278                 {
279                         Test1 = new SqlString ("First TestString");
280                         Test2 = new SqlString ("This is just a test SqlString");
281                         Test3 = new SqlString ("This is just a test SqlString");
282
283                         AssertEquals ("#K01", 
284                               (SqlString)"First TestStringThis is just a test SqlString", 
285                               SqlString.Concat (Test1, Test2));
286
287                         AssertEquals ("#K02", SqlString.Null, 
288                                       SqlString.Concat (Test1, SqlString.Null));
289                 }
290
291                 [Test]
292                 public void Clone()
293                 {
294                         SqlString TestSqlString  = Test1.Clone ();
295                         AssertEquals ("#L01", Test1, TestSqlString);
296                 }
297
298                 [Test]
299                 public void CompareOptionsFromSqlCompareOptions()
300                 {
301                         AssertEquals ("#M01", CompareOptions.IgnoreCase,
302                                     SqlString.CompareOptionsFromSqlCompareOptions (
303                                     SqlCompareOptions.IgnoreCase));
304                         AssertEquals ("#M02", CompareOptions.IgnoreCase,
305                                     SqlString.CompareOptionsFromSqlCompareOptions (
306                                     SqlCompareOptions.IgnoreCase));
307                         try {
308                                 
309                                 CompareOptions test = SqlString.CompareOptionsFromSqlCompareOptions (
310                                     SqlCompareOptions.BinarySort);
311                                 Fail ("#M03");
312                         } catch (Exception e) {
313                                 AssertEquals ("#M04", typeof (ArgumentOutOfRangeException), e.GetType ());
314                         }
315                 }
316
317                 [Test]
318                 public void UnicodeBytes()
319                 {
320                         AssertEquals ("#N01", (byte)105, Test1.GetNonUnicodeBytes () [1]);
321                         AssertEquals ("#N02", (byte)32, Test1.GetNonUnicodeBytes () [5]);
322
323                         AssertEquals ("#N03", (byte)70, Test1.GetUnicodeBytes () [0]);
324                         AssertEquals ("#N03b", (byte)70, Test1.GetNonUnicodeBytes () [0]);
325                         AssertEquals ("#N03c", (byte)0, Test1.GetUnicodeBytes () [1]);
326                         AssertEquals ("#N03d", (byte)105, Test1.GetNonUnicodeBytes () [1]);
327                         AssertEquals ("#N03e", (byte)105, Test1.GetUnicodeBytes () [2]);
328                         AssertEquals ("#N03f", (byte)114, Test1.GetNonUnicodeBytes () [2]);
329                         AssertEquals ("#N03g", (byte)0, Test1.GetUnicodeBytes () [3]);
330                         AssertEquals ("#N03h", (byte)115, Test1.GetNonUnicodeBytes () [3]);
331                         AssertEquals ("#N03i", (byte)114, Test1.GetUnicodeBytes () [4]);
332                         AssertEquals ("#N03j", (byte)116, Test1.GetNonUnicodeBytes () [4]);
333
334                         AssertEquals ("#N04", (byte)105, Test1.GetUnicodeBytes () [2]);
335
336                         try {
337                                 byte test = Test1.GetUnicodeBytes () [105];
338                                 Fail ("#N05");
339                         } catch (Exception e) {
340                                 AssertEquals ("#N06", typeof (IndexOutOfRangeException), e.GetType());                                
341                         }
342                 }
343                       
344                 [Test]
345                 [ExpectedException(typeof (FormatException))]
346                 public void ConversionBoolFormatException1 ()
347                 {
348                         bool test = Test1.ToSqlBoolean ().Value;                              
349                 }
350
351                 [Test]
352                 [ExpectedException(typeof (FormatException))]
353                 public void ConversionByteFormatException ()
354                 {
355                         byte test = Test1.ToSqlByte ().Value;
356                 }
357
358                 [Test]
359                 [ExpectedException(typeof (FormatException))]
360                 public void ConversionDecimalFormatException1 ()
361                 {
362                         Decimal d = Test1.ToSqlDecimal ().Value;
363                 }
364
365                 [Test]
366                 [ExpectedException(typeof (FormatException))]
367                 public void ConversionDecimalFormatException2 ()
368                 {
369                         SqlString String9E300 = new SqlString ("9E+300");
370                         SqlDecimal test = String9E300.ToSqlDecimal ();
371                 }
372
373                 [Test]
374                 [ExpectedException(typeof (FormatException))]
375                 public void ConversionGuidFormatException ()
376                 {
377                         SqlString String9E300 = new SqlString ("9E+300");
378                         SqlGuid test = String9E300.ToSqlGuid ();
379                 }
380
381                 [Test]
382                 [ExpectedException(typeof (FormatException))]
383                 public void ConversionInt16FormatException ()
384                 {
385                         SqlString String9E300 = new SqlString ("9E+300");
386                         SqlInt16 test = String9E300.ToSqlInt16().Value;
387                 }
388
389                 [Test]
390                 [ExpectedException(typeof (FormatException))]
391                 public void ConversionInt32FormatException1 ()
392                 {
393                         SqlString String9E300 = new SqlString ("9E+300");
394                         SqlInt32 test = String9E300.ToSqlInt32 ().Value;
395                 }
396
397                 [Test]
398                 [ExpectedException(typeof (FormatException))]
399                 public void ConversionInt32FormatException2 ()
400                 {
401                         SqlInt32 test = Test1.ToSqlInt32 ().Value;
402                 }
403
404                 [Test]
405                 [ExpectedException(typeof (FormatException))]
406                 public void ConversionInt64FormatException ()
407                 {
408                         SqlString String9E300 = new SqlString ("9E+300");
409                         SqlInt64 test = String9E300.ToSqlInt64 ().Value;
410                 }
411
412                 [Test]
413                 [ExpectedException(typeof (FormatException))]
414                 public void ConversionIntMoneyFormatException2 ()
415                 {
416                         SqlString String9E300 = new SqlString ("9E+300");
417                         SqlMoney test = String9E300.ToSqlMoney ().Value;
418                 }
419
420                 [Test]
421                 [ExpectedException(typeof(OverflowException))]
422                 public void ConversionByteOverflowException ()
423                 {
424                         SqlByte b = (new SqlString ("2500")).ToSqlByte ();
425                 }
426
427                 [Test]
428                 [ExpectedException(typeof(OverflowException))]
429                 public void ConversionDoubleOverflowException ()
430                 {
431                         SqlDouble test = (new SqlString ("4e400")).ToSqlDouble ();
432                 }
433
434                 [Test]
435                 [ExpectedException(typeof(OverflowException))]
436                 public void ConversionSingleOverflowException ()
437                 {
438                         SqlString String9E300 = new SqlString ("9E+300");
439                         SqlSingle test = String9E300.ToSqlSingle().Value;
440                 }
441
442                 [Test]          
443                 public void Conversions()
444                 {
445
446                         SqlString String250 = new SqlString ("250");
447                         SqlString String9E300 = new SqlString ("9E+300");
448
449                         // ToSqlBoolean ()                                
450                         Assert ("#O02", (new SqlString("1")).ToSqlBoolean ().Value);
451                         Assert ("#O03", !(new SqlString("0")).ToSqlBoolean ().Value);
452                         Assert ("#O04", (new SqlString("True")).ToSqlBoolean ().Value);
453                         Assert ("#O05", !(new SqlString("FALSE")).ToSqlBoolean ().Value);
454                         Assert ("#O06", SqlString.Null.ToSqlBoolean ().IsNull);
455
456                         // ToSqlByte ()
457                         AssertEquals ("#O08", (byte)250, String250.ToSqlByte ().Value);    
458
459                         // ToSqlDateTime
460                         AssertEquals ("#O11", 10, 
461                                       (new SqlString ("2002-10-10")).ToSqlDateTime ().Value.Day);
462                         
463                         // ToSqlDecimal ()
464                         AssertEquals ("#O16", (decimal)250, String250.ToSqlDecimal ().Value);
465
466                         // ToSqlDouble
467                         AssertEquals ("#O19", (SqlDouble)9E+300, String9E300.ToSqlDouble ());
468
469                         // ToSqlGuid
470                         SqlString TestGuid = new SqlString("11111111-1111-1111-1111-111111111111");
471                         AssertEquals ("#O22", new SqlGuid("11111111-1111-1111-1111-111111111111"), TestGuid.ToSqlGuid ());
472
473                         // ToSqlInt16 ()
474                         AssertEquals ("#O24", (short)250, String250.ToSqlInt16 ().Value);
475
476                         // ToSqlInt32 ()
477                         AssertEquals ("#O27", (int)250, String250.ToSqlInt32 ().Value);
478
479                         // ToSqlInt64 ()
480                         AssertEquals ("#O32", (long)250, String250.ToSqlInt64 ().Value);
481
482                         // ToSqlMoney ()
483                         AssertEquals ("#O35", (decimal)250, String250.ToSqlMoney ().Value);
484
485
486                         // ToSqlSingle ()
487                         AssertEquals ("#O38", (float)250, String250.ToSqlSingle ().Value);
488
489                         // ToString ()
490                         AssertEquals ("#O41", "First TestString", Test1.ToString ());
491                 }
492
493                 // OPERATORS
494
495                 [Test]
496                 public void ArithmeticOperators()
497                 {
498                         SqlString TestString = new SqlString ("...Testing...");
499                         AssertEquals ("#P01", (SqlString)"First TestString...Testing...",
500                                       Test1 + TestString);
501                         AssertEquals ("#P02", SqlString.Null,
502                                       Test1 + SqlString.Null);
503                 }
504
505                 [Test]
506                 public void ThanOrEqualOperators()
507                 {
508                         // == -operator
509                         Assert ("#Q01", (Test2 == Test3).Value);
510                         Assert ("#Q02", !(Test1 == Test2).Value);
511                         Assert ("#Q03", (Test1 == SqlString.Null).IsNull);
512                         
513                         // != -operator
514                         Assert ("#Q04", !(Test3 != Test2).Value);
515                         Assert ("#Q05", !(Test2 != Test3).Value);
516                         Assert ("#Q06", (Test1 != Test3).Value);
517                         Assert ("#Q07", (Test1 != SqlString.Null).IsNull);
518
519                         // > -operator
520                         Assert ("#Q08", (Test2 > Test1).Value);
521                         Assert ("#Q09", !(Test1 > Test3).Value);
522                         Assert ("#Q10", !(Test2 > Test3).Value);
523                         Assert ("#Q11", (Test1 > SqlString.Null).IsNull);
524
525                         // >=  -operator
526                         Assert ("#Q12", !(Test1 >= Test3).Value);
527                         Assert ("#Q13", (Test3 >= Test1).Value);
528                         Assert ("#Q14", (Test2 >= Test3).Value);
529                         Assert ("#Q15", (Test1 >= SqlString.Null).IsNull);
530
531                         // < -operator
532                         Assert ("#Q16", (Test1 < Test2).Value);
533                         Assert ("#Q17", (Test1 < Test3).Value);
534                         Assert ("#Q18", !(Test2 < Test3).Value);
535                         Assert ("#Q19", (Test1 < SqlString.Null).IsNull);
536
537                         // <= -operator
538                         Assert ("#Q20", (Test1 <= Test3).Value);
539                         Assert ("#Q21", !(Test3 <= Test1).Value);
540                         Assert ("#Q22", (Test2 <= Test3).Value);
541                         Assert ("#Q23", (Test1 <= SqlString.Null).IsNull);
542                 }
543
544                 [Test]
545                 public void SqlBooleanToSqlString()
546                 {
547                         SqlBoolean TestBoolean = new SqlBoolean (true);
548                         SqlBoolean TestBoolean2 = new SqlBoolean (false);
549                         SqlString Result;
550
551                         Result = (SqlString)TestBoolean;
552                         AssertEquals ("#R01", "True", Result.Value);
553                         
554                         Result = (SqlString)TestBoolean2;
555                         AssertEquals ("#R02", "False", Result.Value);
556                         
557                         Result = (SqlString)SqlBoolean.Null;
558                         Assert ("#R03", Result.IsNull);
559                 }
560
561                 [Test]
562                 public void SqlByteToBoolean()
563                 {
564                         SqlByte TestByte = new SqlByte (250);
565                         AssertEquals ("#S01", "250", ((SqlString)TestByte).Value);
566                         try {
567                                 SqlString test = ((SqlString)SqlByte.Null).Value;
568                                 Fail ("#S02");
569                         } catch (Exception e) {
570                                 AssertEquals ("#S03", typeof (SqlNullValueException), e.GetType ());
571                         }
572                 }
573
574                 [Test]
575                 public void SqlDateTimeToSqlString()
576                 {                        
577                         Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-AU");
578                         SqlDateTime TestTime = new SqlDateTime(2002, 10, 22, 9, 52, 30);
579                         AssertEquals ("#T01", "22/10/2002 9:52:30 AM", ((SqlString)TestTime).Value);                        
580                 }
581                 
582                 [Test]
583                 public void SqlDecimalToSqlString()
584                 {
585                         SqlDecimal TestDecimal = new SqlDecimal (1000.2345);
586                         AssertEquals ("#U01", "1000.2345000000000", ((SqlString)TestDecimal).Value);
587                 }
588                 
589                 [Test]
590                 public void SqlDoubleToSqlString()
591                 {
592                         SqlDouble TestDouble = new SqlDouble (64E+64);
593                         AssertEquals ("#V01", "6.4E+65", ((SqlString)TestDouble).Value);
594                 }
595
596                 [Test]
597                 public void SqlGuidToSqlString()
598                 {
599                         byte [] b = new byte [16];
600                         b [0] = 100;
601                         b [1] = 64;
602                         SqlGuid TestGuid = new SqlGuid (b);
603                         
604                         AssertEquals ("#W01", "00004064-0000-0000-0000-000000000000", 
605                                       ((SqlString)TestGuid).Value);
606                         try {
607                                 SqlString test = ((SqlString)SqlGuid.Null).Value;
608                                 Fail ("#W02");
609                         } catch (Exception e) {
610                                 AssertEquals ("#W03", typeof (SqlNullValueException), e.GetType());
611                         }
612                 }
613                 
614                 [Test]
615                 public void SqlInt16ToSqlString()
616                 {
617                         SqlInt16 TestInt = new SqlInt16(20012);
618                         AssertEquals ("#X01", "20012", ((SqlString)TestInt).Value);
619                         try {
620                                 SqlString test = ((SqlString)SqlInt16.Null).Value;
621                                 Fail ("#X02");
622                         } catch (Exception e) {
623                                 AssertEquals ("#X03", typeof (SqlNullValueException), e.GetType ());                                
624                         }
625                 }
626                 
627                 [Test]
628                 public void SqlInt32ToSqlString()
629                 {
630                         SqlInt32 TestInt = new SqlInt32(-12456);
631                         AssertEquals ("#Y01", "-12456", ((SqlString)TestInt).Value);
632                         try {
633                                 SqlString test = ((SqlString)SqlInt32.Null).Value;
634                                 Fail ("#Y02");
635                         } catch (Exception e) {
636                                 AssertEquals ("#Y03", typeof (SqlNullValueException), e.GetType ());                                
637                         }
638                 }
639                 
640                 [Test]
641                 public void SqlInt64ToSqlString()
642                 {
643                         SqlInt64 TestInt = new SqlInt64(10101010);
644                         AssertEquals ("#Z01", "10101010", ((SqlString)TestInt).Value);
645                 }
646                 
647                 [Test]
648                 public void SqlMoneyToSqlString()
649                 {
650                         SqlMoney TestMoney = new SqlMoney (646464.6464);
651                         AssertEquals ("#AA01", "646464.6464", ((SqlString)TestMoney).Value);
652                 }
653                 
654                 [Test]
655                 public void SqlSingleToSqlString()
656                 {
657                         SqlSingle TestSingle = new SqlSingle (3E+20);
658                         AssertEquals ("#AB01", "3E+20", ((SqlString)TestSingle).Value);
659                 }
660                       
661                 [Test]                        
662                 public void SqlStringToString()
663                 {
664                         AssertEquals ("#AC01", "First TestString",(String)Test1);                        
665                 }
666
667                 [Test]
668                 public void StringToSqlString()
669                 {
670                         String TestString = "Test String";
671                         AssertEquals ("#AD01", "Test String", ((SqlString)TestString).Value);                        
672                 }                
673         }
674 }
675