2 // SqlByteTest.cs - NUnit Test Cases for System.Data.SqlTypes.SqlByte
4 // Ville Palo (vi64pa@koti.soon.fi)
11 using System.Data.SqlTypes;
13 namespace MonoTests.System.Data.SqlTypes
15 public class SqlByteTest : TestCase {
17 private const string Error = " does not work correctly";
19 public SqlByteTest() : base ("System.Data.SqlTypes.SqlByte") {}
20 public SqlByteTest(string name) : base(name) {}
22 protected override void TearDown() {}
24 protected override void SetUp() {
28 public static ITest Suite {
30 return new TestSuite(typeof(SqlString));
35 public void TestCreate()
38 SqlByte TestByte = new SqlByte(b);
39 AssertEquals("Constructor 1 does not work correctly", (byte)29, TestByte.Value);
44 public void TestPublicFields()
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);
55 public void TestProperties()
58 SqlByte TestByte = new SqlByte(54);
59 SqlByte TestByte2 = new SqlByte(1);
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);
67 // PUBLIC STATIC METHODS
69 public void TestAddMethod()
72 SqlByte TestByte64 = new SqlByte(64);
73 SqlByte TestByte0 = new SqlByte(0);
74 SqlByte TestByte164 = new SqlByte(164);
75 SqlByte TestByte255 = new SqlByte(255);
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);
83 SqlByte.Add(TestByte255, TestByte64);
84 Fail ("AddMethod 6" + Error);
85 } catch (Exception e) {
86 AssertEquals("AddMethod 5" + Error, typeof(OverflowException), e.GetType());
91 public void TestBitwiseAndMethod()
94 SqlByte TestByte2 = new SqlByte(2);
95 SqlByte TestByte1 = new SqlByte(1);
96 SqlByte TestByte62 = new SqlByte(62);
97 SqlByte TestByte255 = new SqlByte(255);
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);
112 public void TestBitwiseOrMethod()
115 SqlByte TestByte2 = new SqlByte(2);
116 SqlByte TestByte1 = new SqlByte(1);
117 SqlByte TestByte62 = new SqlByte(62);
118 SqlByte TestByte255 = new SqlByte(255);
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);
134 public void TestCompareTo()
137 SqlByte TestByte13 = new SqlByte(13);
138 SqlByte TestByte10 = new SqlByte(10);
139 SqlByte TestByte10II = new SqlByte(10);
141 SqlString TestString = new SqlString("This is a test");
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);
148 TestByte13.CompareTo(TestString);
149 Fail("CompareTo method 4" + Error);
150 } catch(Exception e) {
151 AssertEquals("Parse method 5" + Error, typeof(ArgumentException), e.GetType());
156 public void TestDivideMethod()
159 SqlByte TestByte13 = new SqlByte(13);
160 SqlByte TestByte0 = new SqlByte(0);
162 SqlByte TestByte2 = new SqlByte(2);
163 SqlByte TestByte180 = new SqlByte(180);
164 SqlByte TestByte3 = new SqlByte(3);
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);
178 SqlByte.Divide(TestByte13, TestByte0);
179 Fail ("Divide method 6" + Error);
180 } catch(Exception e) {
181 AssertEquals("DivideByZeroException", typeof(DivideByZeroException), e.GetType());
187 public void TestEqualsMethod()
190 SqlByte TestByte0 = new SqlByte(0);
191 SqlByte TestByte158 = new SqlByte(158);
192 SqlByte TestByte180 = new SqlByte(180);
193 SqlByte TestByte180II = new SqlByte(180);
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));
202 public void TestStaticEqualsMethod()
205 SqlByte TestByte34 = new SqlByte(34);
206 SqlByte TestByte34II = new SqlByte(34);
207 SqlByte TestByte15 = new SqlByte(15);
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);
215 public void TestGetHashCode()
218 SqlByte TestByte15 = new SqlByte(15);
219 SqlByte TestByte216 = new SqlByte(216);
221 AssertEquals("GetHashCode method 1" + Error, 15, TestByte15.GetHashCode());
222 AssertEquals("GetHashCode method 2" + Error, 216, TestByte216.GetHashCode());
226 public void TestGetType()
229 SqlByte TestByte = new SqlByte(84);
231 AssertEquals("GetType method" + Error,
232 "System.Data.SqlTypes.SqlByte", TestByte.GetType().ToString());
236 public void TestGreaterThan()
239 SqlByte TestByte10 = new SqlByte(10);
240 SqlByte TestByte10II = new SqlByte(10);
241 SqlByte TestByte110 = new SqlByte(110);
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);
249 public void TestGreaterThanOrEqual()
252 SqlByte TestByte10 = new SqlByte(10);
253 SqlByte TestByte10II = new SqlByte(10);
254 SqlByte TestByte110 = new SqlByte(110);
256 Assert("GreaterThanOrEqual method 1" + Error,
257 !SqlByte.GreaterThanOrEqual(TestByte10, TestByte110).Value);
259 Assert("GreaterThanOrEqual method 2" + Error,
260 SqlByte.GreaterThanOrEqual(TestByte110, TestByte10).Value);
262 Assert("GreaterThanOrEqual method 3" + Error,
263 SqlByte.GreaterThanOrEqual(TestByte10II, TestByte10).Value);
267 public void TestLessThan()
270 SqlByte TestByte10 = new SqlByte(10);
271 SqlByte TestByte10II = new SqlByte(10);
272 SqlByte TestByte110 = new SqlByte(110);
274 Assert("LessThan method 1" + Error,
275 SqlByte.LessThan(TestByte10, TestByte110).Value);
277 Assert("LessThan method 2" + Error,
278 !SqlByte.LessThan(TestByte110, TestByte10).Value);
280 Assert("LessThan method 3" + Error,
281 !SqlByte.LessThan(TestByte10II, TestByte10).Value);
285 public void TestLessThanOrEqual()
288 SqlByte TestByte10 = new SqlByte(10);
289 SqlByte TestByte10II = new SqlByte(10);
290 SqlByte TestByte110 = new SqlByte(110);
292 Assert("LessThanOrEqual method 1" + Error,
293 SqlByte.LessThanOrEqual(TestByte10, TestByte110).Value);
295 Assert("LessThanOrEqual method 2" + Error,
296 !SqlByte.LessThanOrEqual(TestByte110, TestByte10).Value);
298 Assert("LessThanOrEqual method 3" + Error,
299 SqlByte.LessThanOrEqual(TestByte10II, TestByte10).Value);
301 Assert("LessThanOrEqual method 4" + Error,
302 SqlByte.LessThanOrEqual(TestByte10II, SqlByte.Null).IsNull);
305 public void TestMod()
308 SqlByte TestByte132 = new SqlByte(132);
309 SqlByte TestByte10 = new SqlByte(10);
310 SqlByte TestByte200 = new SqlByte(200);
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));
319 public void TestMultiply()
322 SqlByte TestByte12 = new SqlByte (12);
323 SqlByte TestByte2 = new SqlByte (2);
324 SqlByte TestByte128 = new SqlByte (128);
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);
332 SqlByte.Multiply(TestByte128, TestByte2);
333 Fail ("Multiply method 3");
334 } catch(Exception e) {
336 AssertEquals("OverflowException" + Error, typeof(OverflowException), e.GetType());
341 public void TestNotEquals()
343 SqlByte TestByte12 = new SqlByte(12);
344 SqlByte TestByte128 = new SqlByte(128);
345 SqlByte TestByte128II = new SqlByte(128);
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);
355 public void TestOnesComplement()
358 SqlByte TestByte12 = new SqlByte(12);
359 SqlByte TestByte128 = new SqlByte(128);
361 AssertEquals("OnesComplement method 1" + Error,
362 (SqlByte)243, SqlByte.OnesComplement(TestByte12));
363 AssertEquals("OnesComplement method 2" + Error,
364 (SqlByte)127, SqlByte.OnesComplement(TestByte128));
368 public void TestParse()
372 Fail("Parse method 2" + Error);
374 catch (Exception e) {
375 AssertEquals("Parse method 3" + Error, typeof(ArgumentNullException), e.GetType());
379 SqlByte.Parse("not-a-number");
380 Fail("Parse method 4" + Error);
382 catch (Exception e) {
383 AssertEquals("Parse method 5" + Error, typeof(FormatException), e.GetType());
387 int OverInt = (int)SqlByte.MaxValue + 1;
388 SqlByte.Parse(OverInt.ToString());
389 Fail("Parse method 6" + Error);
391 catch (Exception e) {
392 AssertEquals("Parse method 7" + Error, typeof(OverflowException), e.GetType());
395 AssertEquals("Parse method 8" + Error, (byte)150, SqlByte.Parse("150").Value);
399 public void TestSubtract()
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);
407 SqlByte.Subtract(TestByte12, TestByte128);
408 } catch(Exception e) {
410 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
415 public void TestToSqlBoolean()
418 SqlByte TestByte12 = new SqlByte(12);
419 SqlByte TestByte0 = new SqlByte(0);
420 SqlByte TestByteNull = SqlByte.Null;
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);
427 public void TestToSqlDecimal()
429 SqlByte TestByte12 = new SqlByte(12);
430 SqlByte TestByte0 = new SqlByte(0);
431 SqlByte TestByte228 = new SqlByte(228);
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);
442 public void TestToSqlDouble()
444 SqlByte TestByte12 = new SqlByte(12);
445 SqlByte TestByte0 = new SqlByte(0);
446 SqlByte TestByte228 = new SqlByte(228);
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);
457 public void TestToSqlInt16()
460 SqlByte TestByte12 = new SqlByte(12);
461 SqlByte TestByte0 = new SqlByte(0);
462 SqlByte TestByte228 = new SqlByte(228);
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);
472 public void TestToSqlInt32()
475 SqlByte TestByte12 = new SqlByte(12);
476 SqlByte TestByte0 = new SqlByte(0);
477 SqlByte TestByte228 = new SqlByte(228);
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);
488 public void TestToSqlInt64()
490 SqlByte TestByte12 = new SqlByte(12);
491 SqlByte TestByte0 = new SqlByte(0);
492 SqlByte TestByte228 = new SqlByte(228);
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);
503 public void TestToSqlMoney()
506 SqlByte TestByte12 = new SqlByte(12);
507 SqlByte TestByte0 = new SqlByte(0);
508 SqlByte TestByte228 = new SqlByte(228);
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);
518 public void TestToSqlSingle()
521 SqlByte TestByte12 = new SqlByte(12);
522 SqlByte TestByte0 = new SqlByte(0);
523 SqlByte TestByte228 = new SqlByte(228);
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);
534 public void TestToSqlString()
537 SqlByte TestByte12 = new SqlByte(12);
538 SqlByte TestByte0 = new SqlByte(0);
539 SqlByte TestByte228 = new SqlByte(228);
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);
550 public void TestToString()
553 SqlByte TestByte12 = new SqlByte(12);
554 SqlByte TestByte0 = new SqlByte(0);
555 SqlByte TestByte228 = new SqlByte(228);
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());
565 public void TestXor()
568 SqlByte TestByte14 = new SqlByte(14);
569 SqlByte TestByte58 = new SqlByte(58);
570 SqlByte TestByte130 = new SqlByte(130);
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);
580 public void TestAdditionOperator()
583 SqlByte TestByte24 = new SqlByte(24);
584 SqlByte TestByte64 = new SqlByte(64);
585 SqlByte TestByte255 = new SqlByte(255);
587 AssertEquals("Addition operator" + Error, (SqlByte)88,TestByte24 + TestByte64);
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());
598 public void TestBitwiseAndOperator()
601 SqlByte TestByte2 = new SqlByte(2);
602 SqlByte TestByte4 = new SqlByte(4);
603 SqlByte TestByte255 = new SqlByte(255);
605 AssertEquals("Bitwise and operator 1" + Error, (SqlByte)0,TestByte2 & TestByte4);
606 AssertEquals("Bitwise and operaror 2" + Error, (SqlByte)2, TestByte2 & TestByte255);
609 public void TestBitwiseOrOperator()
612 SqlByte TestByte2 = new SqlByte(2);
613 SqlByte TestByte4 = new SqlByte(4);
614 SqlByte TestByte255 = new SqlByte(255);
616 AssertEquals("Bitwise or operator 1" + Error, (SqlByte)6,TestByte2 | TestByte4);
617 AssertEquals("Bitwise or operaror 2" + Error, (SqlByte)255, TestByte2 | TestByte255);
620 public void TestDivisionOperator()
623 SqlByte TestByte2 = new SqlByte(2);
624 SqlByte TestByte4 = new SqlByte(4);
625 SqlByte TestByte255 = new SqlByte(255);
626 SqlByte TestByte0 = new SqlByte(0);
628 AssertEquals("Division operator 1" + Error, (SqlByte)2,TestByte4 / TestByte2);
629 AssertEquals("Division operaror 2" + Error, (SqlByte)127, TestByte255 / TestByte2);
632 TestByte2 = TestByte255 / TestByte0;
633 Fail("Division operator 3" + Error);
634 } catch (Exception e) {
635 AssertEquals("DivideByZeroException", typeof(DivideByZeroException), e.GetType());
640 public void TestEqualityOperator()
643 SqlByte TestByte15 = new SqlByte(15);
644 SqlByte TestByte15II = new SqlByte(15);
645 SqlByte TestByte255 = new SqlByte(255);
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);
654 public void TestExclusiveOrOperator()
657 SqlByte TestByte15 = new SqlByte(15);
658 SqlByte TestByte10 = new SqlByte(10);
659 SqlByte TestByte255 = new SqlByte(255);
661 AssertEquals("Exclusive or operator 1" + Error, (SqlByte)5, (TestByte15 ^ TestByte10));
662 AssertEquals("Exclusive or operator 2" + Error, (SqlByte)240, (TestByte15 ^ TestByte255));
665 public void TestThanOrEqualOperators()
668 SqlByte TestByte165 = new SqlByte(165);
669 SqlByte TestByte100 = new SqlByte(100);
670 SqlByte TestByte100II = new SqlByte(100);
671 SqlByte TestByte255 = new SqlByte(255);
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);
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);
689 public void TestMultiplicationOperator()
692 SqlByte TestByte4 = new SqlByte(4);
693 SqlByte TestByte12 = new SqlByte(12);
694 SqlByte TestByte128 = new SqlByte(128);
696 AssertEquals("Multiplication operator 1" + Error, (SqlByte)48, TestByte4 * TestByte12);
698 SqlByte test = (TestByte128 * TestByte4);
699 Fail("Multiplication operator 2" + Error);
700 } catch (Exception e) {
701 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
706 public void TestOnesComplementOperator()
709 SqlByte TestByte12 = new SqlByte(12);
710 SqlByte TestByte128 = new SqlByte(128);
712 AssertEquals("OnesComplement operator 1" + Error,
713 (SqlByte)243, ~TestByte12);
714 AssertEquals("OnesComplement operator 2" + Error,
715 (SqlByte)127, ~TestByte128);
719 public void TestSubtractionOperator()
722 SqlByte TestByte4 = new SqlByte(4);
723 SqlByte TestByte12 = new SqlByte(12);
724 SqlByte TestByte128 = new SqlByte(128);
726 AssertEquals("Subtraction operator 1" + Error, (SqlByte)8, TestByte12 - TestByte4);
729 SqlByte test = TestByte4 - TestByte128;
730 Fail("Sybtraction operator 2" + Error);
732 } catch (Exception e) {
734 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
739 public void TestSqlBooleanToSqlByte()
741 SqlBoolean TestBoolean = new SqlBoolean(true);
744 TestByte = (SqlByte)TestBoolean;
746 AssertEquals("SqlBooleanToSqlByte op" + Error,
747 (byte)1, TestByte.Value);
750 public void TestSqlByteToByte()
752 SqlByte TestByte = new SqlByte(12);
753 byte test = (byte)TestByte;
754 AssertEquals("SqlByteToByte" + Error, (byte)12, test);
757 public void TestSqlDecimalToSqlByte()
759 SqlDecimal TestDecimal64 = new SqlDecimal(64);
760 SqlDecimal TestDecimal900 = new SqlDecimal(900);
762 AssertEquals("SqlDecimalToByte" + Error, (byte)64, ((SqlByte)TestDecimal64).Value);
765 SqlByte test = (SqlByte)TestDecimal900;
766 Fail("SqlDecimalToByte 2" + Error);
767 } catch (Exception e) {
769 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
774 public void TestSqlDoubleToSqlByte()
776 SqlDouble TestDouble64 = new SqlDouble(64);
777 SqlDouble TestDouble900 = new SqlDouble(900);
779 AssertEquals("SqlDecimalToByte" + Error, (byte)64, ((SqlByte)TestDouble64).Value);
782 SqlByte test = (SqlByte)TestDouble900;
783 Fail("SqlDoubleToByte 2" + Error);
784 } catch (Exception e) {
786 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
791 public void TestSqlInt16ToSqlByte()
793 SqlInt16 TestInt1664 = new SqlInt16(64);
794 SqlInt16 TestInt16900 = new SqlInt16(900);
796 AssertEquals("SqlInt16ToByte" + Error, (byte)64, ((SqlByte)TestInt1664).Value);
799 SqlByte test = (SqlByte)TestInt16900;
800 Fail("SqlInt16ToByte 2" + Error);
801 } catch (Exception e) {
803 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
808 public void TestSqlInt32ToSqlByte()
810 SqlInt32 TestInt3264 = new SqlInt32(64);
811 SqlInt32 TestInt32900 = new SqlInt32(900);
813 AssertEquals("SqlInt32ToByte" + Error, (byte)64, ((SqlByte)TestInt3264).Value);
816 SqlByte test = (SqlByte)TestInt32900;
817 Fail("SqlInt32ToByte 2" + Error);
818 } catch (Exception e) {
820 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
825 public void TestSqlInt64ToSqlByte()
827 SqlInt64 TestInt6464 = new SqlInt64(64);
828 SqlInt64 TestInt64900 = new SqlInt64(900);
830 AssertEquals("SqlInt64ToByte" + Error, (byte)64, ((SqlByte)TestInt6464).Value);
833 SqlByte test = (SqlByte)TestInt64900;
834 Fail("SqlInt64ToByte 2" + Error);
835 } catch (Exception e) {
837 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
842 public void TestSqlMoneyToSqlByte()
844 SqlMoney TestMoney64 = new SqlMoney(64);
845 SqlMoney TestMoney900 = new SqlMoney(900);
847 AssertEquals("SqlMoneyToByte" + Error, (byte)64, ((SqlByte)TestMoney64).Value);
850 SqlByte test = (SqlByte)TestMoney900;
851 Fail("SqlMoneyToByte 2" + Error);
852 } catch (Exception e) {
854 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
859 public void TestSqlSingleToSqlByte()
861 SqlSingle TestSingle64 = new SqlSingle(64);
862 SqlSingle TestSingle900 = new SqlSingle(900);
864 AssertEquals("SqlSingleToByte" + Error, (byte)64, ((SqlByte)TestSingle64).Value);
867 SqlByte test = (SqlByte)TestSingle900;
868 Fail("SqlSingleToByte 2" + Error);
869 } catch (Exception e) {
871 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
876 public void TestSqlStringToSqlByte()
878 SqlString TestString = new SqlString("Test string");
879 SqlString TestString100 = new SqlString("100");
880 SqlString TestString1000 = new SqlString("1000");
882 AssertEquals ("SqlStringToByte 1" + Error, (byte)100, ((SqlByte)TestString100).Value);
885 SqlByte test = (SqlByte)TestString1000;
886 } catch(Exception e) {
888 AssertEquals("OverflowException", typeof(OverflowException), e.GetType());
892 SqlByte test = (SqlByte)TestString;
893 Fail("SqlStringToByte 2" + Error);
895 } catch(Exception e) {
896 AssertEquals("FormatException", typeof(FormatException), e.GetType());
900 public void TestByteToSqlByte()
903 AssertEquals ("ByteToSqlByte" + Error,
904 (byte)14, ((SqlByte)TestByte).Value);