2002-10-03 ville <vi64pa@koti.soon.fi>
[mono.git] / mcs / class / System.Data / Test / System.Data.SqlTypes / SqlByteTest.cs
1 //
2 // SqlByteTest.cs - NUnit Test Cases for System.Data.SqlTypes.SqlByte
3 //
4 // Ville Palo (vi64pa@koti.soon.fi)
5 //
6 // (C) Ville Palo 2002
7 // 
8
9 using NUnit.Framework;
10 using System;
11 using System.Data.SqlTypes;
12
13 namespace MonoTests.System.Data.SqlTypes
14 {
15         public class SqlByteTest : TestCase {
16
17                 private const string Error = " does not work correctly";
18
19                 public SqlByteTest() : base ("System.Data.SqlTypes.SqlByte") {}
20                 public SqlByteTest(string name) : base(name) {}
21
22                 protected override void TearDown() {}
23
24                 protected override void SetUp() {
25
26                 }
27
28                 public static ITest Suite {
29                         get {
30                                 return new TestSuite(typeof(SqlString));
31                         }
32                 }
33
34                 // Test constructor
35                 public void TestCreate()
36                 {
37                         byte b = 29;
38                         SqlByte TestByte = new SqlByte(b);
39                         AssertEquals("Constructor 1 does not work correctly", (byte)29, TestByte.Value);
40
41                 }
42
43                 // Test public fields
44                 public void TestPublicFields()
45                 {
46
47                         AssertEquals("MaxValue field" + Error, (SqlByte)255, SqlByte.MaxValue);
48                         AssertEquals("MinValue field" + Error, (SqlByte)0, SqlByte.MinValue);
49                         Assert("Null field" + Error, SqlByte.Null.IsNull);
50                         AssertEquals("Zero field" + Error, (byte)0, SqlByte.Zero.Value);
51                         
52                 }
53
54                 // Test properties
55                 public void TestProperties()
56                 {
57
58                         SqlByte TestByte = new SqlByte(54);
59                         SqlByte TestByte2 = new SqlByte(1);
60
61                         Assert("IsNull property" + Error, SqlByte.Null.IsNull);
62                         AssertEquals("Value property 1" + Error, (byte)54, TestByte.Value);
63                         AssertEquals("Value property 2" + Error, (byte)1, TestByte2.Value);
64
65                 }
66
67                 // PUBLIC STATIC METHODS
68
69                 public void TestAddMethod()
70                 {
71
72                         SqlByte TestByte64 = new SqlByte(64);
73                         SqlByte TestByte0 = new SqlByte(0);
74                         SqlByte TestByte164 = new SqlByte(164);
75                         SqlByte TestByte255 = new SqlByte(255);
76
77                         AssertEquals("AddMethod 1" + Error, (byte)64, SqlByte.Add(TestByte64, TestByte0).Value);
78                         AssertEquals("AddMethod 2" + Error, (byte)228, SqlByte.Add(TestByte64, TestByte164).Value);
79                         AssertEquals("AddMethod 3" + Error, (byte)164, SqlByte.Add(TestByte0, TestByte164).Value);
80                         AssertEquals("AddMethod 4" + Error, (byte)255, SqlByte.Add(TestByte255, TestByte0).Value);
81
82                         try {
83                                 SqlByte.Add(TestByte255, TestByte64);
84                                 Fail ("AddMethod 6" + Error);
85                         } catch (Exception e) {
86                                 AssertEquals("AddMethod 5" + Error, typeof(OverflowException), e.GetType());
87                         }
88
89                 }
90
91                 public void TestBitwiseAndMethod()
92                 {
93
94                         SqlByte TestByte2 = new SqlByte(2);
95                         SqlByte TestByte1 = new SqlByte(1);
96                         SqlByte TestByte62 = new SqlByte(62);
97                         SqlByte TestByte255 = new SqlByte(255);
98
99                         AssertEquals("BitwiseAnd method 1" + Error,
100                                      (byte)0, SqlByte.BitwiseAnd(TestByte2, TestByte1).Value);
101                         AssertEquals("BitwiseAnd method 2" + Error,
102                                      (byte)0, SqlByte.BitwiseAnd(TestByte1, TestByte62).Value);
103                         AssertEquals("BitwiseAnd method 3" + Error,
104                                      (byte)2, SqlByte.BitwiseAnd(TestByte62, TestByte2).Value);
105                         AssertEquals("BitwiseAnd method 4" + Error,
106                                      (byte)1, SqlByte.BitwiseAnd(TestByte1, TestByte255).Value);
107                         AssertEquals("BitwiseAnd method 5" + Error,
108                                      (byte)62, SqlByte.BitwiseAnd(TestByte62, TestByte255).Value);
109
110                 }
111
112                 public void TestBitwiseOrMethod()
113                 {
114
115                         SqlByte TestByte2 = new SqlByte(2);
116                         SqlByte TestByte1 = new SqlByte(1);
117                         SqlByte TestByte62 = new SqlByte(62);
118                         SqlByte TestByte255 = new SqlByte(255);
119
120                         AssertEquals("BitwiseOr method 1" + Error,
121                                      (byte)3, SqlByte.BitwiseOr(TestByte2, TestByte1).Value);
122                         AssertEquals("BitwiseOr method 2" + Error,
123                                      (byte)63, SqlByte.BitwiseOr(TestByte1, TestByte62).Value);
124                         AssertEquals("BitwiseOr method 3" + Error,
125                                      (byte)62, SqlByte.BitwiseOr(TestByte62, TestByte2).Value);
126                         AssertEquals("BitwiseOr method 4" + Error,
127                                      (byte)255, SqlByte.BitwiseOr(TestByte1, TestByte255).Value);
128                         AssertEquals("BitwiseOr method 5" + Error,
129                                      (byte)255, SqlByte.BitwiseOr(TestByte62, TestByte255).Value);
130
131                 }
132
133
134                 public void TestCompareTo()
135                 {
136
137                         SqlByte TestByte13 = new SqlByte(13);
138                         SqlByte TestByte10 = new SqlByte(10);
139                         SqlByte TestByte10II = new SqlByte(10);
140
141                         SqlString TestString = new SqlString("This is a test");
142                         
143                         Assert("CompareTo method 1" + Error, TestByte13.CompareTo(TestByte10) > 0);
144                         Assert("CompareTo method 2" + Error, TestByte10.CompareTo(TestByte13) < 0);
145                         Assert("CompareTo method 3" + Error, TestByte10.CompareTo(TestByte10II) == 0);
146                         
147                         try {
148                                 TestByte13.CompareTo(TestString);
149                                 Fail("CompareTo method 4" + Error);
150                         } catch(Exception e) {
151                                 AssertEquals("Parse method 5" + Error, typeof(ArgumentException), e.GetType());
152                         }
153                         
154                 }
155
156                 public void TestDivideMethod()
157                 {
158
159                         SqlByte TestByte13 = new SqlByte(13);
160                         SqlByte TestByte0 = new SqlByte(0);
161
162                         SqlByte TestByte2 = new SqlByte(2);
163                         SqlByte TestByte180 = new SqlByte(180);
164                         SqlByte TestByte3 = new SqlByte(3);
165
166                         AssertEquals("Divide method 1" + Error,
167                                      (byte)6, SqlByte.Divide(TestByte13, TestByte2).Value);
168                         AssertEquals("Divide method 2" + Error,
169                                      (byte)90, SqlByte.Divide(TestByte180, TestByte2).Value);
170                         AssertEquals("Divide method 3" + Error,
171                                      (byte)60, SqlByte.Divide(TestByte180, TestByte3).Value);
172                         AssertEquals("Divide method 4" + Error,
173                                      (byte)0, SqlByte.Divide(TestByte13, TestByte180).Value);
174                         AssertEquals("Divide method 5" + Error,
175                                      (byte)0, SqlByte.Divide(TestByte13, TestByte180).Value);
176
177                         try {
178                                 SqlByte.Divide(TestByte13, TestByte0);
179                                 Fail ("Divide method 6" + Error);
180                         } catch(Exception e) {
181                                 AssertEquals("DivideByZeroException", typeof(DivideByZeroException), e.GetType());
182
183                         }
184
185                 }
186
187                 public void TestEqualsMethod()
188                 {
189
190                         SqlByte TestByte0 = new SqlByte(0);
191                         SqlByte TestByte158 = new SqlByte(158);
192                         SqlByte TestByte180 = new SqlByte(180);
193                         SqlByte TestByte180II = new SqlByte(180);
194
195                         Assert("Equals method 1" + Error, !TestByte0.Equals(TestByte158));
196                         Assert("Equals method 2" + Error, !TestByte158.Equals(TestByte180));
197                         Assert("Equals method 3" + Error, !TestByte180.Equals(new SqlString("TEST")));
198                         Assert("Equals method 4" + Error, TestByte180.Equals(TestByte180II));
199
200                 }
201
202                 public void TestStaticEqualsMethod()
203                 {
204
205                         SqlByte TestByte34 = new SqlByte(34);
206                         SqlByte TestByte34II = new SqlByte(34);
207                         SqlByte TestByte15 = new SqlByte(15);
208                         
209                         Assert("static Equals method 1" + Error, SqlByte.Equals(TestByte34, TestByte34II).Value);
210                         Assert("static Equals method 2" + Error, !SqlByte.Equals(TestByte34, TestByte15).Value);
211                         Assert("static Equals method 3" + Error, !SqlByte.Equals(TestByte15, TestByte34II).Value);
212
213                 }
214
215                 public void TestGetHashCode()
216                 {
217
218                         SqlByte TestByte15 = new SqlByte(15);
219                         SqlByte TestByte216 = new SqlByte(216);
220                         
221                         AssertEquals("GetHashCode method 1" + Error, 15, TestByte15.GetHashCode());
222                         AssertEquals("GetHashCode method 2" + Error, 216, TestByte216.GetHashCode());
223
224                 }
225
226                 public void TestGetType()
227                 {
228
229                         SqlByte TestByte = new SqlByte(84);
230
231                         AssertEquals("GetType method" + Error,
232                                      "System.Data.SqlTypes.SqlByte", TestByte.GetType().ToString());
233                         
234                 }
235
236                 public void TestGreaterThan()
237                 {
238
239                         SqlByte TestByte10 = new SqlByte(10);
240                         SqlByte TestByte10II = new SqlByte(10);
241                         SqlByte TestByte110 = new SqlByte(110);
242
243                         Assert("GreaterThan method 1" + Error, !SqlByte.GreaterThan(TestByte10, TestByte110).Value);
244                         Assert("GreaterThan method 2" + Error, SqlByte.GreaterThan(TestByte110, TestByte10).Value);
245                         Assert("GreaterThan method 3" + Error, !SqlByte.GreaterThan(TestByte10II, TestByte10).Value);
246
247                 }
248
249                 public void TestGreaterThanOrEqual()
250                 {
251
252                         SqlByte TestByte10 = new SqlByte(10);
253                         SqlByte TestByte10II = new SqlByte(10);
254                         SqlByte TestByte110 = new SqlByte(110);
255
256                         Assert("GreaterThanOrEqual method 1" + Error,
257                                !SqlByte.GreaterThanOrEqual(TestByte10, TestByte110).Value);
258
259                         Assert("GreaterThanOrEqual method 2" + Error,
260                                SqlByte.GreaterThanOrEqual(TestByte110, TestByte10).Value);
261
262                         Assert("GreaterThanOrEqual method 3" + Error,
263                                SqlByte.GreaterThanOrEqual(TestByte10II, TestByte10).Value);
264
265                 }
266
267                 public void TestLessThan()
268                 {
269
270                         SqlByte TestByte10 = new SqlByte(10);
271                         SqlByte TestByte10II = new SqlByte(10);
272                         SqlByte TestByte110 = new SqlByte(110);
273
274                         Assert("LessThan method 1" + Error,
275                                SqlByte.LessThan(TestByte10, TestByte110).Value);
276
277                         Assert("LessThan method 2" + Error,
278                                !SqlByte.LessThan(TestByte110, TestByte10).Value);
279
280                         Assert("LessThan method 3" + Error,
281                                !SqlByte.LessThan(TestByte10II, TestByte10).Value);
282
283                 }
284
285                 public void TestLessThanOrEqual()
286                 {
287
288                         SqlByte TestByte10 = new SqlByte(10);
289                         SqlByte TestByte10II = new SqlByte(10);
290                         SqlByte TestByte110 = new SqlByte(110);
291
292                         Assert("LessThanOrEqual method 1" + Error,
293                                SqlByte.LessThanOrEqual(TestByte10, TestByte110).Value);
294
295                         Assert("LessThanOrEqual method 2" + Error,
296                                !SqlByte.LessThanOrEqual(TestByte110, TestByte10).Value);
297
298                         Assert("LessThanOrEqual method 3" + Error,
299                                SqlByte.LessThanOrEqual(TestByte10II, TestByte10).Value);
300
301                         Assert("LessThanOrEqual method 4" + Error,
302                                SqlByte.LessThanOrEqual(TestByte10II, SqlByte.Null).IsNull);
303                 }
304
305                 public void TestMod()
306                 {
307
308                         SqlByte TestByte132 = new SqlByte(132);
309                         SqlByte TestByte10 = new SqlByte(10);
310                         SqlByte TestByte200 = new SqlByte(200);
311
312                         AssertEquals("Mod method 1" + Error, (SqlByte)2, SqlByte.Mod(TestByte132, TestByte10));
313                         AssertEquals("Mod method 2" + Error,  (SqlByte)10, SqlByte.Mod(TestByte10, TestByte200));
314                         AssertEquals("Mod method 3" + Error,  (SqlByte)0, SqlByte.Mod(TestByte200, TestByte10));
315                         AssertEquals("Mod method 4" + Error,  (SqlByte)68, SqlByte.Mod(TestByte200, TestByte132));
316
317                 }
318
319                 public void TestMultiply()
320                 {
321
322                         SqlByte TestByte12 = new SqlByte (12);
323                         SqlByte TestByte2 = new SqlByte (2);
324                         SqlByte TestByte128 = new SqlByte (128);
325
326                         AssertEquals ("Multiply method 1" + Error,
327                                       (byte)24, SqlByte.Multiply(TestByte12, TestByte2).Value);
328                         AssertEquals ("Multiply method 2" + Error,
329                                       (byte)24, SqlByte.Multiply(TestByte2, TestByte12).Value);
330                         
331                         try {
332                                 SqlByte.Multiply(TestByte128, TestByte2);
333                                 Fail ("Multiply method 3");
334                         } catch(Exception e) {
335
336                                 AssertEquals("OverflowException" + Error, typeof(OverflowException), e.GetType());
337                         }
338
339                 }
340
341                 public void TestNotEquals()
342                 {
343                         SqlByte TestByte12 = new SqlByte(12);
344                         SqlByte TestByte128 = new SqlByte(128);
345                         SqlByte TestByte128II = new SqlByte(128);
346
347                         Assert("NotEquals method 1" + Error, SqlByte.NotEquals(TestByte12, TestByte128).Value);
348                         Assert("NotEquals method 2" + Error, SqlByte.NotEquals(TestByte128, TestByte12).Value);
349                         Assert("NotEquals method 3" + Error, SqlByte.NotEquals(TestByte128II, TestByte12).Value);
350                         Assert("NotEquals method 4" + Error, !SqlByte.NotEquals(TestByte128II, TestByte128).Value);
351                         Assert("NotEquals method 5" + Error, !SqlByte.NotEquals(TestByte128, TestByte128II).Value);
352
353                 }
354
355                 public void TestOnesComplement()
356                 {
357
358                         SqlByte TestByte12 = new SqlByte(12);
359                         SqlByte TestByte128 = new SqlByte(128);
360
361                         AssertEquals("OnesComplement method 1" + Error,
362                                      (SqlByte)243, SqlByte.OnesComplement(TestByte12));
363                         AssertEquals("OnesComplement method 2" + Error,
364                                      (SqlByte)127, SqlByte.OnesComplement(TestByte128));
365
366                 }
367
368                 public void TestParse()
369                 {
370                         try {
371                                 SqlByte.Parse(null);
372                                 Fail("Parse method 2" + Error);
373                         }
374                         catch (Exception e) {
375                                 AssertEquals("Parse method 3" + Error, typeof(ArgumentNullException), e.GetType());
376                         }
377
378                         try {
379                                 SqlByte.Parse("not-a-number");
380                                 Fail("Parse method 4" + Error);
381                         }
382                         catch (Exception e) {
383                                 AssertEquals("Parse method 5" + Error, typeof(FormatException), e.GetType());
384                         }
385
386                         try {
387                                 int OverInt = (int)SqlByte.MaxValue + 1;
388                                 SqlByte.Parse(OverInt.ToString());
389                                 Fail("Parse method 6" + Error);
390                         }
391                         catch (Exception e) {
392                                 AssertEquals("Parse method 7" + Error, typeof(OverflowException), e.GetType());
393                         }
394
395                         AssertEquals("Parse method 8" + Error, (byte)150, SqlByte.Parse("150").Value);
396
397                 }
398
399                 public void TestSubtract()
400                 {
401
402                         SqlByte TestByte12 = new SqlByte(12);
403                         SqlByte TestByte128 = new SqlByte(128);
404                         AssertEquals("Subtract method 1" + Error, (byte)116, SqlByte.Subtract(TestByte128, TestByte12).Value);
405
406                         try {
407                                 SqlByte.Subtract(TestByte12, TestByte128);
408                         } catch(Exception e) {
409
410                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
411                         }
412
413                 }
414
415                 public void TestToSqlBoolean()
416                 {
417
418                         SqlByte TestByte12 = new SqlByte(12);
419                         SqlByte TestByte0 = new SqlByte(0);
420                         SqlByte TestByteNull = SqlByte.Null;
421
422                         Assert("ToSqlBoolean method 1" + Error, TestByte12.ToSqlBoolean().Value);
423                         Assert("ToSqlBoolean method 2" + Error, !TestByte0.ToSqlBoolean().Value);
424                         Assert("ToSqlBoolean method 3" + Error, TestByteNull.ToSqlBoolean().IsNull);
425                 }
426
427                 public void TestToSqlDecimal()
428                 {
429                         SqlByte TestByte12 = new SqlByte(12);
430                         SqlByte TestByte0 = new SqlByte(0);
431                         SqlByte TestByte228 = new SqlByte(228);
432
433                         AssertEquals("ToSqlDecimal method 1" + Error,
434                                      (decimal)12, TestByte12.ToSqlDecimal().Value);
435                         AssertEquals("ToSqlDecimal method 2" + Error,
436                                      (decimal)0, TestByte0.ToSqlDecimal().Value);
437                         AssertEquals("ToSqlDecimal method 3" + Error,
438                                      (decimal)228, TestByte228.ToSqlDecimal().Value);
439                         
440                 }
441
442                 public void TestToSqlDouble()
443                 {
444                         SqlByte TestByte12 = new SqlByte(12);
445                         SqlByte TestByte0 = new SqlByte(0);
446                         SqlByte TestByte228 = new SqlByte(228);
447
448                         AssertEquals("ToSqlDouble method 1" + Error,
449                                      (double)12, TestByte12.ToSqlDouble().Value);
450                         AssertEquals("ToSqlDouble method 2" + Error,
451                                      (double)0, TestByte0.ToSqlDouble().Value);
452                         AssertEquals("ToSqlDouble method 3" + Error,
453                                      (double)228, TestByte228.ToSqlDouble().Value);
454
455                 }
456
457                 public void TestToSqlInt16()
458                 {
459
460                         SqlByte TestByte12 = new SqlByte(12);
461                         SqlByte TestByte0 = new SqlByte(0);
462                         SqlByte TestByte228 = new SqlByte(228);
463
464                         AssertEquals("ToSqInt16 method 1" + Error,
465                                      (short)12, TestByte12.ToSqlInt16().Value);
466                         AssertEquals("ToSqlInt16 method 2" + Error,
467                                      (short)0, TestByte0.ToSqlInt16().Value);
468                         AssertEquals("ToSqlInt16 method 3" + Error,
469                                      (short)228, TestByte228.ToSqlInt16().Value);
470                 }
471
472                 public void TestToSqlInt32()
473                 {
474
475                         SqlByte TestByte12 = new SqlByte(12);
476                         SqlByte TestByte0 = new SqlByte(0);
477                         SqlByte TestByte228 = new SqlByte(228);
478                         
479                         AssertEquals("ToSqInt32 method 1" + Error,
480                                      (int)12, TestByte12.ToSqlInt32().Value);
481                         AssertEquals("ToSqlInt32 method 2" + Error,
482                                      (int)0, TestByte0.ToSqlInt32().Value);
483                         AssertEquals("ToSqlInt32 method 3" + Error,
484                                      (int)228, TestByte228.ToSqlInt32().Value);
485
486                 }
487
488                 public void TestToSqlInt64()
489                 {
490                         SqlByte TestByte12 = new SqlByte(12);
491                         SqlByte TestByte0 = new SqlByte(0);
492                         SqlByte TestByte228 = new SqlByte(228);
493
494                         AssertEquals("ToSqInt64 method " + Error,
495                                      (long)12, TestByte12.ToSqlInt64().Value);
496                         AssertEquals("ToSqlInt64 method 2" + Error,
497                                      (long)0, TestByte0.ToSqlInt64().Value);
498                         AssertEquals("ToSqlInt64 method 3" + Error,
499                                      (long)228, TestByte228.ToSqlInt64().Value);
500
501                 }
502
503                 public void TestToSqlMoney()
504                 {
505
506                         SqlByte TestByte12 = new SqlByte(12);
507                         SqlByte TestByte0 = new SqlByte(0);
508                         SqlByte TestByte228 = new SqlByte(228);
509
510                         AssertEquals("ToSqMoney method 1" + Error,
511                                      (decimal)12, TestByte12.ToSqlMoney().Value);
512                         AssertEquals("ToSqlMoney method 2" + Error,
513                                      (decimal)0, TestByte0.ToSqlMoney().Value);
514                         AssertEquals("ToSqlMoney method 3" + Error,
515                                      (decimal)228, TestByte228.ToSqlMoney().Value);
516                 }
517
518                 public void TestToSqlSingle()
519                 {
520             
521                         SqlByte TestByte12 = new SqlByte(12);
522                         SqlByte TestByte0 = new SqlByte(0);
523                         SqlByte TestByte228 = new SqlByte(228);
524
525                         AssertEquals("ToSqlSingle method 1" + Error,
526                                      (float)12, TestByte12.ToSqlSingle().Value);
527                         AssertEquals("ToSqlSingle method 2" + Error,
528                                      (float)0, TestByte0.ToSqlSingle().Value);
529                         AssertEquals("ToSqlSingle method 3" + Error,
530                                      (float)228, TestByte228.ToSqlSingle().Value);
531
532                 }
533
534                 public void TestToSqlString()
535                 {
536
537                         SqlByte TestByte12 = new SqlByte(12);
538                         SqlByte TestByte0 = new SqlByte(0);
539                         SqlByte TestByte228 = new SqlByte(228);
540
541                         AssertEquals("ToSqlString method 1" + Error,
542                                      "12", TestByte12.ToSqlString().Value);
543                         AssertEquals("ToSqlString method 2" + Error,
544                                      "0", TestByte0.ToSqlString().Value);
545                         AssertEquals("ToSqlString method 3" + Error,
546                                      "228", TestByte228.ToSqlString().Value);
547
548                 }
549
550                 public void TestToString()
551                 {
552
553                         SqlByte TestByte12 = new SqlByte(12);
554                         SqlByte TestByte0 = new SqlByte(0);
555                         SqlByte TestByte228 = new SqlByte(228);
556                         
557                         AssertEquals("ToString method 1" + Error,
558                                      "12", TestByte12.ToString());
559                         AssertEquals("ToString method 2" + Error,
560                                      "0", TestByte0.ToString());
561                         AssertEquals("ToString method 3" + Error,
562                                      "228", TestByte228.ToString());
563                 }
564
565                 public void TestXor()
566                 {
567
568                         SqlByte TestByte14 = new SqlByte(14);
569                         SqlByte TestByte58 = new SqlByte(58);
570                         SqlByte TestByte130 = new SqlByte(130);
571
572                         AssertEquals("Xor method 1" + Error, (byte)52, SqlByte.Xor(TestByte14, TestByte58).Value);
573                         AssertEquals("Xor method 2" + Error, (byte)140, SqlByte.Xor(TestByte14, TestByte130).Value);
574                         AssertEquals("Xor method 3" + Error, (byte)184, SqlByte.Xor(TestByte58, TestByte130).Value);
575
576                 }
577
578                 // OPERATORS
579                 
580                 public void TestAdditionOperator()
581                 {
582
583                         SqlByte TestByte24 = new SqlByte(24);
584                         SqlByte TestByte64 = new SqlByte(64);
585                         SqlByte TestByte255 = new SqlByte(255);
586
587                         AssertEquals("Addition operator" + Error, (SqlByte)88,TestByte24 + TestByte64);
588
589                         try {
590                                 SqlByte result = TestByte64 + TestByte255;
591                                 Fail("Addition operator 1" + Error);
592                         } catch (Exception e) {
593                                 AssertEquals("Addition operator 2" + Error, typeof(OverflowException), e.GetType());
594                         }
595                         
596                 }
597
598                 public void TestBitwiseAndOperator()
599                 {
600
601                         SqlByte TestByte2 = new SqlByte(2);
602                         SqlByte TestByte4 = new SqlByte(4);
603                         SqlByte TestByte255 = new SqlByte(255);
604
605                         AssertEquals("Bitwise and operator 1" + Error, (SqlByte)0,TestByte2 & TestByte4);
606                         AssertEquals("Bitwise and operaror 2" + Error, (SqlByte)2, TestByte2 & TestByte255);
607                 }
608
609                 public void TestBitwiseOrOperator()
610                 {
611
612                         SqlByte TestByte2 = new SqlByte(2);
613                         SqlByte TestByte4 = new SqlByte(4);
614                         SqlByte TestByte255 = new SqlByte(255);
615
616                         AssertEquals("Bitwise or operator 1" + Error, (SqlByte)6,TestByte2 | TestByte4);
617                         AssertEquals("Bitwise or operaror 2" + Error, (SqlByte)255, TestByte2 | TestByte255);
618                 }
619
620                 public void TestDivisionOperator()
621                 {
622
623                         SqlByte TestByte2 = new SqlByte(2);
624                         SqlByte TestByte4 = new SqlByte(4);
625                         SqlByte TestByte255 = new SqlByte(255);
626                         SqlByte TestByte0 = new SqlByte(0);
627
628                         AssertEquals("Division operator 1" + Error, (SqlByte)2,TestByte4 / TestByte2);
629                         AssertEquals("Division operaror 2" + Error, (SqlByte)127, TestByte255 / TestByte2);
630
631                         try {
632                                 TestByte2 = TestByte255 / TestByte0;
633                                 Fail("Division operator 3" + Error);
634                         } catch (Exception e) {
635                                 AssertEquals("DivideByZeroException", typeof(DivideByZeroException), e.GetType());
636                         }
637
638                 }
639
640                 public void TestEqualityOperator()
641                 {
642
643                         SqlByte TestByte15 = new SqlByte(15);
644                         SqlByte TestByte15II = new SqlByte(15);
645                         SqlByte TestByte255 = new SqlByte(255);
646
647                         Assert("== operator" + Error, (TestByte15 == TestByte15II).Value);
648                         Assert("== operator 2" + Error, !(TestByte15 == TestByte255).Value);
649                         Assert("!= operator" + Error, !(TestByte15 != TestByte15II).Value);
650                         Assert("!= operator 2" + Error, (TestByte15 != TestByte255).Value);
651
652                 }
653
654                 public void TestExclusiveOrOperator()
655                 {
656
657                         SqlByte TestByte15 = new SqlByte(15);
658                         SqlByte TestByte10 = new SqlByte(10);
659                         SqlByte TestByte255 = new SqlByte(255);
660
661                         AssertEquals("Exclusive or operator 1" + Error, (SqlByte)5, (TestByte15 ^ TestByte10));
662                         AssertEquals("Exclusive or operator 2" + Error, (SqlByte)240, (TestByte15 ^ TestByte255));
663                 }
664
665                 public void TestThanOrEqualOperators()
666                 {
667
668                         SqlByte TestByte165 = new SqlByte(165);
669                         SqlByte TestByte100 = new SqlByte(100);
670                         SqlByte TestByte100II = new SqlByte(100);
671                         SqlByte TestByte255 = new SqlByte(255);
672
673                         Assert("> operator 1" + Error, (TestByte165 > TestByte100).Value);
674                         Assert("> operator 2" + Error, !(TestByte165 > TestByte255).Value);
675                         Assert("> operator 3" + Error, !(TestByte100 > TestByte100II).Value);
676                         Assert(">= operator 1" + Error, !(TestByte165 >= TestByte255).Value);
677                         Assert(">= operator 2" + Error, (TestByte255 >= TestByte165).Value);
678                         Assert(">= operator 3" + Error, (TestByte100 >= TestByte100II).Value);
679
680                         Assert("< operator 1" + Error, !(TestByte165 < TestByte100).Value);
681                         Assert("< operator 2" + Error, (TestByte165 < TestByte255).Value);
682                         Assert("< operator 3" + Error, !(TestByte100 < TestByte100II).Value);
683                         Assert("<= operator 1" + Error, (TestByte165 <= TestByte255).Value);
684                         Assert("<= operator 2" + Error, !(TestByte255 <= TestByte165).Value);
685                         Assert("<= operator 3" + Error, (TestByte100 <= TestByte100II).Value);
686                 }
687
688
689                 public void TestMultiplicationOperator()
690                 {
691
692                         SqlByte TestByte4 = new SqlByte(4);
693                         SqlByte TestByte12 = new SqlByte(12);
694                         SqlByte TestByte128 = new SqlByte(128);
695
696                         AssertEquals("Multiplication operator 1" + Error, (SqlByte)48, TestByte4 * TestByte12);
697                         try {
698                                 SqlByte test = (TestByte128 * TestByte4);
699                                 Fail("Multiplication operator 2" + Error);
700                         } catch (Exception e) {
701                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
702                         }
703
704                 }
705
706                 public void TestOnesComplementOperator()
707                 {
708
709                         SqlByte TestByte12 = new SqlByte(12);
710                         SqlByte TestByte128 = new SqlByte(128);
711
712                         AssertEquals("OnesComplement operator 1" + Error,
713                                      (SqlByte)243, ~TestByte12);
714                         AssertEquals("OnesComplement operator 2" + Error,
715                                      (SqlByte)127, ~TestByte128);
716
717                 }
718
719                 public void TestSubtractionOperator()
720                 {
721
722                         SqlByte TestByte4 = new SqlByte(4);
723                         SqlByte TestByte12 = new SqlByte(12);
724                         SqlByte TestByte128 = new SqlByte(128);
725
726                         AssertEquals("Subtraction operator 1" + Error, (SqlByte)8, TestByte12 - TestByte4);
727                         try {
728                                 
729                                 SqlByte test = TestByte4 - TestByte128;
730                                 Fail("Sybtraction operator 2" + Error);
731
732                         } catch (Exception e) {
733
734                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
735                         }
736
737                 }
738
739                 public void TestSqlBooleanToSqlByte()
740                 {
741                         SqlBoolean TestBoolean = new SqlBoolean(true);
742                         SqlByte TestByte;
743
744                         TestByte = (SqlByte)TestBoolean;
745                         
746                         AssertEquals("SqlBooleanToSqlByte op" + Error,
747                                      (byte)1, TestByte.Value);
748                 }
749
750                 public void TestSqlByteToByte()
751                 {
752                         SqlByte TestByte = new SqlByte(12);
753                         byte test = (byte)TestByte;
754                         AssertEquals("SqlByteToByte" + Error, (byte)12, test);
755                 }
756
757                 public void TestSqlDecimalToSqlByte()
758                 {
759                         SqlDecimal TestDecimal64 = new SqlDecimal(64);
760                         SqlDecimal TestDecimal900 = new SqlDecimal(900);
761
762                         AssertEquals("SqlDecimalToByte" + Error, (byte)64, ((SqlByte)TestDecimal64).Value);
763
764                         try {
765                                 SqlByte test = (SqlByte)TestDecimal900;
766                                 Fail("SqlDecimalToByte 2" + Error);
767                         } catch (Exception e) {
768
769                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
770                         }
771
772                 }
773
774                 public void TestSqlDoubleToSqlByte()
775                 {
776                         SqlDouble TestDouble64 = new SqlDouble(64);
777                         SqlDouble TestDouble900 = new SqlDouble(900);
778
779                         AssertEquals("SqlDecimalToByte" + Error, (byte)64, ((SqlByte)TestDouble64).Value);
780
781                         try {
782                                 SqlByte test = (SqlByte)TestDouble900;
783                                 Fail("SqlDoubleToByte 2" + Error);
784                         } catch (Exception e) {
785
786                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
787                         }
788
789                 }
790
791                 public void TestSqlInt16ToSqlByte()
792                 {
793                         SqlInt16 TestInt1664 = new SqlInt16(64);
794                         SqlInt16 TestInt16900 = new SqlInt16(900);
795                         
796                         AssertEquals("SqlInt16ToByte" + Error, (byte)64, ((SqlByte)TestInt1664).Value);
797
798                         try {
799                                 SqlByte test = (SqlByte)TestInt16900;
800                                 Fail("SqlInt16ToByte 2" + Error);
801                         } catch (Exception e) {
802
803                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
804                         }
805
806                 }
807
808                 public void TestSqlInt32ToSqlByte()
809                 {
810                         SqlInt32 TestInt3264 = new SqlInt32(64);
811                         SqlInt32 TestInt32900 = new SqlInt32(900);
812
813                         AssertEquals("SqlInt32ToByte" + Error, (byte)64, ((SqlByte)TestInt3264).Value);
814
815                         try {
816                                 SqlByte test = (SqlByte)TestInt32900;
817                                 Fail("SqlInt32ToByte 2" + Error);
818                         } catch (Exception e) {
819
820                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
821                         }
822
823                 }
824
825                 public void TestSqlInt64ToSqlByte()
826                 {
827                         SqlInt64 TestInt6464 = new SqlInt64(64);
828                         SqlInt64 TestInt64900 = new SqlInt64(900);
829
830                         AssertEquals("SqlInt64ToByte" + Error, (byte)64, ((SqlByte)TestInt6464).Value);
831
832                         try {
833                                 SqlByte test = (SqlByte)TestInt64900;
834                                 Fail("SqlInt64ToByte 2" + Error);
835                         } catch (Exception e) {
836
837                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
838                         }
839
840                 }
841
842                 public void TestSqlMoneyToSqlByte()
843                 {
844                         SqlMoney TestMoney64 = new SqlMoney(64);
845                         SqlMoney TestMoney900 = new SqlMoney(900);
846
847                         AssertEquals("SqlMoneyToByte" + Error, (byte)64, ((SqlByte)TestMoney64).Value);
848
849                         try {
850                                 SqlByte test = (SqlByte)TestMoney900;
851                                 Fail("SqlMoneyToByte 2" + Error);
852                         } catch (Exception e) {
853
854                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
855                         }
856
857                 }
858
859                 public void TestSqlSingleToSqlByte()
860                 {
861                         SqlSingle TestSingle64 = new SqlSingle(64);
862                         SqlSingle TestSingle900 = new SqlSingle(900);
863
864                         AssertEquals("SqlSingleToByte" + Error, (byte)64, ((SqlByte)TestSingle64).Value);
865
866                         try {
867                                 SqlByte test = (SqlByte)TestSingle900;
868                                 Fail("SqlSingleToByte 2" + Error);
869                         } catch (Exception e) {
870
871                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
872                         }
873
874                 }
875
876                 public void TestSqlStringToSqlByte()
877                 {
878                         SqlString TestString = new SqlString("Test string");
879                         SqlString TestString100 = new SqlString("100");
880                         SqlString TestString1000 = new SqlString("1000");
881
882                         AssertEquals ("SqlStringToByte 1" + Error, (byte)100, ((SqlByte)TestString100).Value);
883
884                         try {
885                                 SqlByte test = (SqlByte)TestString1000;
886                         } catch(Exception e) {
887
888                                 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
889                         }
890
891                         try {
892                                 SqlByte test = (SqlByte)TestString;
893                                 Fail("SqlStringToByte 2" + Error);
894                                 
895                         } catch(Exception e) {
896                                 AssertEquals("FormatException", typeof(FormatException), e.GetType());
897                         }
898                 }
899
900                 public void TestByteToSqlByte()
901                 {
902                         byte TestByte = 14;
903                         AssertEquals ("ByteToSqlByte" + Error,
904                                       (byte)14, ((SqlByte)TestByte).Value);
905                 }
906         }
907 }
908