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