[bcl] Remove more NET_2_0 checks from class libs
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlSingleTest.cs
1 //
2 // SqlSingleTest.cs - NUnit Test Cases for System.Data.SqlTypes.SqlSingle
3 //
4 // Authors:
5 //   Ville Palo (vi64pa@koti.soon.fi)
6 //   Martin Willemoes Hansen (mwh@sysrq.dk)
7 //
8 // (C) 2002 Ville Palo
9 // (C) 2003 Martin Willemoes Hansen
10 // 
11
12 //
13 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
22 // 
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
25 // 
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 //
34
35 using NUnit.Framework;
36 using System;
37 using System.Xml;
38 using System.Data.SqlTypes;
39 using System.Threading;
40 using System.Globalization;
41
42 namespace MonoTests.System.Data.SqlTypes
43 {
44         [TestFixture]
45         public class SqlSingleTest
46         {
47
48                 [SetUp]
49                 public void GetReady() 
50                 {
51                         Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
52                 }
53
54                 // Test constructor
55                 [Test]
56                 public void Create()
57                 {
58                         SqlSingle Test= new SqlSingle ((float)34.87);
59                         SqlSingle Test2 = 45.2f;
60                         
61                         Assert.AreEqual (34.87f, Test.Value, "#A01");
62                         Assert.AreEqual (45.2f, Test2.Value, "#A02");
63
64                         Test = new SqlSingle (-9000.6543);
65                         Assert.AreEqual (-9000.6543f, Test.Value, "#A03");
66                 }
67
68                 // Test public fields
69                 [Test]
70                 public void PublicFields()
71                 {
72                         Assert.AreEqual (3.40282346638528859E+38f, 
73                                       SqlSingle.MaxValue.Value, "#B01");
74                         Assert.AreEqual (-3.40282346638528859E+38f, 
75                                       SqlSingle.MinValue.Value, "#B02");
76                         Assert.IsTrue (SqlSingle.Null.IsNull, "#B03");
77                         Assert.AreEqual (0f, SqlSingle.Zero.Value, "#B04");
78                 }
79
80                 // Test properties
81                 [Test]
82                 public void Properties()
83                 {
84                         SqlSingle Test = new SqlSingle (5443e12f);
85                         SqlSingle Test1 = new SqlSingle (1);
86
87                         Assert.IsTrue (SqlSingle.Null.IsNull, "#C01");
88                         Assert.AreEqual (5443e12f, Test.Value, "#C02");
89                         Assert.AreEqual ((float)1, Test1.Value, "#C03");
90                 }
91
92                 // PUBLIC METHODS
93
94                 [Test]
95                 public void ArithmeticMethods()
96                 {
97                         SqlSingle Test0 = new SqlSingle (0);
98                         SqlSingle Test1 = new SqlSingle (15E+18);
99                         SqlSingle Test2 = new SqlSingle (-65E+6);
100                         SqlSingle Test3 = new SqlSingle (5E+30);
101                         SqlSingle Test4 = new SqlSingle (5E+18);
102                         SqlSingle TestMax = new SqlSingle (SqlSingle.MaxValue.Value);
103
104                         // Add()
105                         Assert.AreEqual (15E+18f, SqlSingle.Add (Test1, Test0).Value, "#D01A");
106                         Assert.AreEqual (1.5E+19f, SqlSingle.Add (Test1, Test2).Value, "#D02A");
107
108                         try {                     
109                                 SqlSingle test = SqlSingle.Add (SqlSingle.MaxValue, 
110                                                          SqlSingle.MaxValue);
111                                 Assert.Fail ("#D03A");
112                         } catch (Exception e) {
113                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D04A");
114                         }
115                         
116                         // Divide()
117                         Assert.AreEqual ((SqlSingle)3, SqlSingle.Divide (Test1, Test4), "#D01B");
118                         Assert.AreEqual (-1.3E-23f, SqlSingle.Divide (Test2, Test3).Value, "#D02B");
119
120                         try {
121                                 SqlSingle test = SqlSingle.Divide(Test1, Test0).Value;
122                                 Assert.Fail ("#D03B");
123                         } catch(Exception e) {
124                                 Assert.AreEqual (typeof (DivideByZeroException), 
125                                               e.GetType (), "#D04B");
126                         }
127
128                         // Multiply()
129                         Assert.AreEqual ((float)(7.5E+37), 
130                                       SqlSingle.Multiply (Test1, Test4).Value, "#D01D");
131                         Assert.AreEqual ((float)0, SqlSingle.Multiply (Test1, Test0).Value, "#D02D");
132
133                         try {
134                                 SqlSingle test = SqlSingle.Multiply (TestMax, Test1);
135                                 Assert.Fail ("#D03D");
136                         } catch (Exception e) {
137                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D04D");
138                         }
139                                 
140
141                         // Subtract()
142                         Assert.AreEqual ((float)(-5E+30), 
143                                       SqlSingle.Subtract (Test1, Test3).Value, "#D01F");
144
145                         try {
146                                 SqlSingle test = SqlSingle.Subtract(
147                                         SqlSingle.MinValue, SqlSingle.MaxValue);
148                                 Assert.Fail ("D02F");
149                         } catch (Exception e) {                 
150                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#D03F");
151                         }                      
152                 }
153
154                 [Test]
155                 public void CompareTo()
156                 {
157                         SqlSingle Test1 = new SqlSingle (4E+30);
158                         SqlSingle Test11 = new SqlSingle (4E+30);
159                         SqlSingle Test2 = new SqlSingle (-9E+30);
160                         SqlSingle Test3 = new SqlSingle (10000);
161                         SqlString TestString = new SqlString ("This is a test");
162
163                         Assert.IsTrue (Test1.CompareTo (Test3) > 0, "#E01");
164                         Assert.IsTrue (Test2.CompareTo (Test3) < 0, "#E02");
165                         Assert.IsTrue (Test1.CompareTo (Test11) == 0, "#E03");
166                         Assert.IsTrue (Test11.CompareTo (SqlSingle.Null) > 0, "#E04");
167
168                         try {
169                                 Test1.CompareTo (TestString);
170                                 Assert.Fail("#E05");
171                         } catch(Exception e) {
172                                 Assert.AreEqual (typeof (ArgumentException), e.GetType (), "#E06");
173                         }
174                 }
175
176                 [Test]
177                 public void EqualsMethods()
178                 {
179                         SqlSingle Test0 = new SqlSingle (0);
180                         SqlSingle Test1 = new SqlSingle (1.58e30);
181                         SqlSingle Test2 = new SqlSingle (1.8e32);
182                         SqlSingle Test22 = new SqlSingle (1.8e32);
183
184                         Assert.IsTrue (!Test0.Equals (Test1), "#F01");
185                         Assert.IsTrue (!Test1.Equals (Test2), "#F02");
186                         Assert.IsTrue (!Test2.Equals (new SqlString ("TEST")), "#F03");
187                         Assert.IsTrue (Test2.Equals (Test22), "#F04");
188
189                         // Static Equals()-method
190                         Assert.IsTrue (SqlSingle.Equals (Test2, Test22).Value, "#F05");
191                         Assert.IsTrue (!SqlSingle.Equals (Test1, Test2).Value, "#F06");
192                 }
193
194                 [Test]
195                 public void GetHashCodeTest()
196                 {
197                         SqlSingle Test15 = new SqlSingle (15);
198
199                         // FIXME: Better way to test HashCode
200                         Assert.AreEqual (Test15.GetHashCode (), Test15.GetHashCode (), "#G01");
201                 }
202
203                 [Test]
204                 public void GetTypeTest()
205                 {
206                         SqlSingle Test = new SqlSingle (84);
207                         Assert.AreEqual ("System.Data.SqlTypes.SqlSingle", 
208                                       Test.GetType ().ToString (), "#H01");
209                         Assert.AreEqual ("System.Single", Test.Value.GetType ().ToString (), "#H02");
210                 }
211
212                 [Test]
213                 public void Greaters()
214                 {
215                         SqlSingle Test1 = new SqlSingle (1e10);
216                         SqlSingle Test11 = new SqlSingle (1e10);
217                         SqlSingle Test2 = new SqlSingle (64e14);
218
219                         // GreateThan ()
220                         Assert.IsTrue (!SqlSingle.GreaterThan (Test1, Test2).Value, "#I01");
221                         Assert.IsTrue (SqlSingle.GreaterThan (Test2, Test1).Value, "#I02");
222                         Assert.IsTrue (!SqlSingle.GreaterThan (Test1, Test11).Value, "#I03");
223
224                         // GreaterTharOrEqual ()
225                         Assert.IsTrue (!SqlSingle.GreaterThanOrEqual (Test1, Test2).Value, "#I04");
226                         Assert.IsTrue (SqlSingle.GreaterThanOrEqual (Test2, Test1).Value, "#I05");
227                         Assert.IsTrue (SqlSingle.GreaterThanOrEqual (Test1, Test11).Value, "#I06");
228                 }
229
230                 [Test]
231                 public void Lessers()
232                 {
233                         SqlSingle Test1 = new SqlSingle(1.8e10);
234                         SqlSingle Test11 = new SqlSingle (1.8e10);
235                         SqlSingle Test2 = new SqlSingle (64e14);
236
237                         // LessThan()
238                         Assert.IsTrue (!SqlSingle.LessThan (Test1, Test11).Value, "#J01");
239                         Assert.IsTrue (!SqlSingle.LessThan (Test2, Test1).Value, "#J02");
240                         Assert.IsTrue (SqlSingle.LessThan (Test11, Test2).Value, "#J03");
241
242                         // LessThanOrEqual ()
243                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test1, Test2).Value, "#J04");
244                         Assert.IsTrue (!SqlSingle.LessThanOrEqual (Test2, Test1).Value, "#J05");
245                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test11, Test1).Value, "#J06");
246                         Assert.IsTrue (SqlSingle.LessThanOrEqual (Test11, SqlSingle.Null).IsNull, "#J07");
247                 }
248
249                 [Test]
250                 public void NotEquals()
251                 {
252                         SqlSingle Test1 = new SqlSingle (12800000000001);
253                         SqlSingle Test2 = new SqlSingle (128e10);
254                         SqlSingle Test22 = new SqlSingle (128e10);
255
256                         Assert.IsTrue (SqlSingle.NotEquals (Test1, Test2).Value, "#K01");
257                         Assert.IsTrue (SqlSingle.NotEquals (Test2, Test1).Value, "#K02");
258                         Assert.IsTrue (SqlSingle.NotEquals (Test22, Test1).Value, "#K03");
259                         Assert.IsTrue (!SqlSingle.NotEquals (Test22, Test2).Value, "#K04");
260                         Assert.IsTrue (!SqlSingle.NotEquals (Test2, Test22).Value, "#K05");
261                         Assert.IsTrue (SqlSingle.NotEquals (SqlSingle.Null, Test22).IsNull, "#K06");
262                         Assert.IsTrue (SqlSingle.NotEquals (SqlSingle.Null, Test22).IsNull, "#K07");
263                 }
264
265                 [Test]
266                 public void Parse()
267                 {
268                         try {
269                                 SqlSingle.Parse (null);
270                                 Assert.Fail ("#L01");
271                         } catch (Exception e) {
272                                 Assert.AreEqual (typeof (ArgumentNullException), e.GetType (), "#L02");
273                         }
274
275                         try {
276                                 SqlSingle.Parse ("not-a-number");
277                                 Assert.Fail ("#L03");
278                         } catch (Exception e) {
279                                 Assert.AreEqual (typeof (FormatException), e.GetType (), "#L04");
280                         }
281
282                          try {
283                                 SqlSingle.Parse ("9e44");
284                                 Assert.Fail ("#L05");
285                         } catch (Exception e) {
286                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#L06");
287                         }
288
289                         Assert.AreEqual((float)150, SqlSingle.Parse ("150").Value, "#L07");
290                 }
291
292                 [Test]
293                 public void Conversions()
294                 {
295                         SqlSingle Test0 = new SqlSingle (0);
296                         SqlSingle Test1 = new SqlSingle (250);
297                         SqlSingle Test2 = new SqlSingle (64E+16);
298                         SqlSingle Test3 = new SqlSingle (64E+30);
299                         SqlSingle TestNull = SqlSingle.Null;
300
301                         // ToSqlBoolean ()
302                         Assert.IsTrue (Test1.ToSqlBoolean ().Value, "#M01A");
303                         Assert.IsTrue (!Test0.ToSqlBoolean ().Value, "#M02A");
304                         Assert.IsTrue (TestNull.ToSqlBoolean ().IsNull, "#M03A");
305
306                         // ToSqlByte ()
307                         Assert.AreEqual ((byte)250, Test1.ToSqlByte ().Value, "#M01B");
308                         Assert.AreEqual ((byte)0, Test0.ToSqlByte ().Value, "#M02B");
309
310                         try {
311                                 SqlByte b = (byte)Test2.ToSqlByte ();
312                                 Assert.Fail ("#M03B");
313                         } catch (Exception e) {
314                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04B");
315                         }
316
317                         // ToSqlDecimal ()
318                         Assert.AreEqual (250.00000000000000M, Test1.ToSqlDecimal ().Value, "#M01C");
319                         Assert.AreEqual ((decimal)0, Test0.ToSqlDecimal ().Value, "#M02C");
320
321                         try {
322                                 SqlDecimal test = Test3.ToSqlDecimal ().Value;
323                                 Assert.Fail ("#M03C");
324                         } catch (Exception e) {
325                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04C");
326                         }      
327
328                         // ToSqlInt16 ()
329                         Assert.AreEqual ((short)250, Test1.ToSqlInt16 ().Value, "#M01D");
330                         Assert.AreEqual ((short)0, Test0.ToSqlInt16 ().Value, "#M02D");
331
332                         try {
333                                 SqlInt16 test = Test2.ToSqlInt16().Value;
334                                 Assert.Fail ("#M03D");
335                         } catch (Exception e) {
336                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04D");
337                         }        
338
339                         // ToSqlInt32 ()
340                         Assert.AreEqual ((int)250, Test1.ToSqlInt32 ().Value, "#M01E");
341                         Assert.AreEqual ((int)0, Test0.ToSqlInt32 ().Value, "#M02E");
342
343                         try {
344                                 SqlInt32 test = Test2.ToSqlInt32 ().Value;
345                                 Assert.Fail ("#M03E");
346                         } catch (Exception e) { 
347                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04E");
348                         }
349
350                         // ToSqlInt64 ()
351                         Assert.AreEqual ((long)250, Test1.ToSqlInt64 ().Value, "#M01F");
352                         Assert.AreEqual ((long)0, Test0.ToSqlInt64 ().Value, "#M02F");
353
354                         try {        
355                                 SqlInt64 test = Test3.ToSqlInt64 ().Value;
356                                 Assert.Fail ("#M03F");
357                         } catch (Exception e) {
358                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04F");
359                         }        
360
361                         // ToSqlMoney ()
362                         Assert.AreEqual (250.0000M, Test1.ToSqlMoney ().Value, "#M01G");
363                         Assert.AreEqual ((decimal)0, Test0.ToSqlMoney ().Value, "#M02G");
364
365                         try {
366                                 SqlMoney test = Test3.ToSqlMoney ().Value;
367                                 Assert.Fail ("#M03G");
368                         } catch (Exception e) {
369                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#M04G");
370                         }        
371
372
373                         // ToSqlString ()
374                         Assert.AreEqual ("250", Test1.ToSqlString ().Value, "#M01H");
375                         Assert.AreEqual ("0", Test0.ToSqlString ().Value, "#M02H");
376                         Assert.AreEqual ("6.4E+17", Test2.ToSqlString ().Value, "#M03H");
377
378                         // ToString ()
379                         Assert.AreEqual ("250", Test1.ToString (), "#M01I");
380                         Assert.AreEqual ("0", Test0.ToString (), "#M02I");
381                         Assert.AreEqual ("6.4E+17", Test2.ToString (), "#M03I");
382                 }
383
384                 // OPERATORS
385
386                 [Test]
387                 public void ArithmeticOperators()
388                 {
389                         SqlSingle Test0 = new SqlSingle (0);
390                         SqlSingle Test1 = new SqlSingle (24E+11);
391                         SqlSingle Test2 = new SqlSingle (64E+32);
392                         SqlSingle Test3 = new SqlSingle (12E+11);
393                         SqlSingle Test4 = new SqlSingle (1E+10);
394                         SqlSingle Test5 = new SqlSingle (2E+10);
395
396                         // "+"-operator
397                         Assert.AreEqual ((SqlSingle)3E+10, Test4 + Test5, "#N01");
398      
399                         try {
400                                 SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
401                                 Assert.Fail ("#N02");
402                         } catch (Exception e) {
403                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N03");
404                         }
405
406                         try {
407                                 SqlSingle test = SqlSingle.MaxValue + SqlSingle.MaxValue;
408                         } catch (Exception e) {
409                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N03a");
410                         }
411
412                         // "/"-operator
413                         Assert.AreEqual ((SqlSingle)2, Test1 / Test3, "#N04");
414
415                         try {
416                                 SqlSingle test = Test3 / Test0;
417                                 Assert.Fail ("#N05");
418                         } catch (Exception e) {
419                                 Assert.AreEqual (typeof (DivideByZeroException), e.GetType (), "#N06");
420                         }
421
422                         // "*"-operator
423                         Assert.AreEqual ((SqlSingle)2E+20, Test4 * Test5, "#N07");
424
425                         try {
426                                 SqlSingle test = SqlSingle.MaxValue * Test1;
427                                 Assert.Fail ("#N08");
428                         } catch (Exception e) {
429                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N09");
430                         }
431
432                         // "-"-operator
433                         Assert.AreEqual ((SqlSingle)12e11, Test1 - Test3, "#N10");
434
435                         try {
436                                 SqlSingle test = SqlSingle.MinValue - SqlSingle.MaxValue;
437                                 Assert.Fail ("#N11");
438                         } catch  (Exception e) {
439                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#N12");
440                         }
441                 }
442
443                 [Test]
444                 public void ThanOrEqualOperators()
445                 {
446                         SqlSingle Test1 = new SqlSingle (1.0E+14f);
447                         SqlSingle Test2 = new SqlSingle (9.7E+11);
448                         SqlSingle Test22 = new SqlSingle (9.7E+11);
449                         SqlSingle Test3 = new SqlSingle (2.0E+22f);
450
451                         // == -operator
452                         Assert.IsTrue ((Test2 == Test22).Value, "#O01");
453                         Assert.IsTrue (!(Test1 == Test2).Value, "#O02");
454                         Assert.IsTrue ((Test1 == SqlSingle.Null).IsNull, "#O03");
455                         
456                         // != -operator
457                         Assert.IsTrue (!(Test2 != Test22).Value, "#O04");
458                         Assert.IsTrue ((Test2 != Test3).Value, "#O05");
459                         Assert.IsTrue ((Test1 != Test3).Value, "#O06");
460                         Assert.IsTrue ((Test1 != SqlSingle.Null).IsNull, "#O07");
461
462                         // > -operator
463                         Assert.IsTrue ((Test1 > Test2).Value, "#O08");
464                         Assert.IsTrue (!(Test1 > Test3).Value, "#O09");
465                         Assert.IsTrue (!(Test2 > Test22).Value, "#O10");
466                         Assert.IsTrue ((Test1 > SqlSingle.Null).IsNull, "#O11");
467
468                         // >=  -operator
469                         Assert.IsTrue (!(Test1 >= Test3).Value, "#O12");
470                         Assert.IsTrue ((Test3 >= Test1).Value, "#O13");
471                         Assert.IsTrue ((Test2 >= Test22).Value, "#O14");
472                         Assert.IsTrue ((Test1 >= SqlSingle.Null).IsNull, "#O15");
473
474                         // < -operator
475                         Assert.IsTrue (!(Test1 < Test2).Value, "#O16");
476                         Assert.IsTrue ((Test1 < Test3).Value, "#O17");
477                         Assert.IsTrue (!(Test2 < Test22).Value, "#O18");
478                         Assert.IsTrue ((Test1 < SqlSingle.Null).IsNull, "#O19");
479
480                         // <= -operator
481                         Assert.IsTrue ((Test1 <= Test3).Value, "#O20");
482                         Assert.IsTrue (!(Test3 <= Test1).Value, "#O21");
483                         Assert.IsTrue ((Test2 <= Test22).Value, "#O22");
484                         Assert.IsTrue ((Test1 <= SqlSingle.Null).IsNull, "#O23");
485                 }
486
487                 [Test]
488                 public void UnaryNegation()
489                 {
490                         SqlSingle Test = new SqlSingle (2000000001);
491                         SqlSingle TestNeg = new SqlSingle (-3000);
492
493                         SqlSingle Result = -Test;
494                         Assert.AreEqual ((float)(-2000000001), Result.Value, "#P01");
495
496                         Result = -TestNeg;
497                         Assert.AreEqual ((float)3000, Result.Value, "#P02");
498                 }
499
500                 [Test]
501                 public void SqlBooleanToSqlSingle()
502                 {
503                         SqlBoolean TestBoolean = new SqlBoolean (true);
504                         SqlSingle Result;
505
506                         Result = (SqlSingle)TestBoolean;
507
508                         Assert.AreEqual ((float)1, Result.Value, "#Q01");
509
510                         Result = (SqlSingle)SqlBoolean.Null;
511                         Assert.IsTrue (Result.IsNull, "#Q02");
512                 }
513
514                 [Test]
515                 public void SqlDoubleToSqlSingle()
516                 {
517                         SqlDouble Test = new SqlDouble (12e12);
518                         SqlSingle TestSqlSingle = (SqlSingle)Test;
519                         Assert.AreEqual (12e12f, TestSqlSingle.Value, "R01");
520                 }
521
522                 [Test]
523                 public void SqlSingleToSingle()
524                 {
525                         SqlSingle Test = new SqlSingle (12e12);
526                         Single Result = (Single)Test;
527                         Assert.AreEqual (12e12f, Result, "#S01");
528                 }
529
530                 [Test]
531                 public void SqlStringToSqlSingle()
532                 {
533                         SqlString TestString = new SqlString ("Test string");
534                         SqlString TestString100 = new SqlString ("100");
535
536                         Assert.AreEqual ((float)100, ((SqlSingle)TestString100).Value, "#T01");
537
538                         try {
539                                 SqlSingle test = (SqlSingle)TestString;
540                                 Assert.Fail ("#T02");
541                         } catch(Exception e) {
542                                 Assert.AreEqual (typeof (FormatException), e.GetType (), "#T03");
543                         }
544                 }
545
546                 [Test]
547                 public void ByteToSqlSingle()
548                 {
549                         short TestShort = 14;
550                         Assert.AreEqual ((float)14, ((SqlSingle)TestShort).Value, "#U01");
551                 }
552                 
553                 [Test]
554                 public void SqlDecimalToSqlSingle()
555                 {
556                         SqlDecimal TestDecimal64 = new SqlDecimal (64);
557
558                         Assert.AreEqual ((float)64, ((SqlSingle)TestDecimal64).Value, "#V01");
559                         Assert.AreEqual (SqlSingle.Null, ((SqlSingle)SqlDecimal.Null), "#V02");
560                 }
561
562                 [Test]
563                 public void SqlIntToSqlSingle()
564                 {
565                         SqlInt16 Test64 = new SqlInt16 (64);
566                         SqlInt32 Test640 = new SqlInt32 (640);
567                         SqlInt64 Test64000 = new SqlInt64 (64000);
568                         Assert.AreEqual ((float)64, ((SqlSingle)Test64).Value, "#W01");
569                         Assert.AreEqual ((float)640, ((SqlSingle)Test640).Value, "#W02");
570                         Assert.AreEqual ((float)64000, ((SqlSingle)Test64000).Value, "#W03");
571                 }
572
573                 [Test]
574                 public void SqlMoneyToSqlSingle()
575                 {
576                         SqlMoney TestMoney64 = new SqlMoney(64);
577                         Assert.AreEqual ((float)64, ((SqlSingle)TestMoney64).Value, "#X01");
578                 }
579
580                 [Test]
581                 public void SingleToSqlSingle()
582                 {
583                         Single TestSingle64 = 64;
584                         Assert.AreEqual ((float)64, ((SqlSingle)TestSingle64).Value, "#Y01");
585                 }
586                 [Test]
587                 public void GetXsdTypeTest ()
588                 {
589                         XmlQualifiedName qualifiedName = SqlSingle.GetXsdType (null);
590                         NUnit.Framework.Assert.AreEqual ("float", qualifiedName.Name, "#A01");
591                 }
592         }
593 }
594