--- /dev/null
+//
+// SqlInt16Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt16
+//
+// Ville Palo (vi64pa@koti.soon.fi)
+//
+// (C) Ville Palo 2002
+//
+
+using NUnit.Framework;
+using System;
+using System.Data.SqlTypes;
+
+namespace MonoTests.System.Data.SqlTypes
+{
+ public class SqlInt16Test : TestCase {
+
+ public SqlInt16Test() : base ("System.Data.SqlTypes.SqlInt64") {}
+ public SqlInt16Test(string name) : base(name) {}
+
+ protected override void TearDown() {}
+
+ protected override void SetUp() {}
+
+ public static ITest Suite {
+ get {
+ return new TestSuite(typeof(SqlInt32));
+ }
+ }
+
+ // Test constructor
+ public void TestCreate()
+ {
+ SqlInt16 TestShort = new SqlInt16 (29);
+ AssertEquals ("Test#1", (short)29, TestShort.Value);
+
+ TestShort = new SqlInt16 (-9000);
+ AssertEquals ("Test#2", (short)-9000, TestShort.Value);
+ }
+
+ // Test public fields
+ public void TestPublicFields()
+ {
+ AssertEquals ("Test#1", (SqlInt16)32767, SqlInt16.MaxValue);
+ AssertEquals ("Test#2", (SqlInt16)(-32768), SqlInt16.MinValue);
+ Assert ("Test#3", SqlInt16.Null.IsNull);
+ AssertEquals ("Test#4", (short)0, SqlInt16.Zero.Value);
+ }
+
+ // Test properties
+ public void TestProperties()
+ {
+ SqlInt16 Test5443 = new SqlInt16 (5443);
+ SqlInt16 Test1 = new SqlInt16 (1);
+ Assert ("Test#1", SqlInt16.Null.IsNull);
+ AssertEquals ("Test#2", (short)5443, Test5443.Value);
+ AssertEquals ("Test#3", (short)1, Test1.Value);
+ }
+
+ // PUBLIC METHODS
+
+ public void TestArithmeticMethods()
+ {
+ SqlInt16 Test64 = new SqlInt16 (64);
+ SqlInt16 Test0 = new SqlInt16 (0);
+ SqlInt16 Test164 = new SqlInt16 (164);
+ SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);
+
+ // Add()
+ AssertEquals ("Test#1", (short)64, SqlInt16.Add (Test64, Test0).Value);
+ AssertEquals ("Test#2", (short)228, SqlInt16.Add (Test64, Test164).Value);
+ AssertEquals ("Test#3", (short)164, SqlInt16.Add (Test0, Test164).Value);
+ AssertEquals ("Test#4", (short)SqlInt16.MaxValue, SqlInt16.Add (TestMax, Test0).Value);
+
+ try {
+ SqlInt16.Add (TestMax, Test64);
+ Fail ("Test#5");
+ } catch (Exception e) {
+ AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
+ }
+
+ // Divide()
+ AssertEquals ("Test#7", (short)2, SqlInt16.Divide (Test164, Test64).Value);
+ AssertEquals ("Test#8", (short)0, SqlInt16.Divide (Test64, Test164).Value);
+ try {
+ SqlInt16.Divide(Test64, Test0);
+ Fail ("Test#9");
+ } catch(Exception e) {
+ AssertEquals ("Test#10", typeof (DivideByZeroException), e.GetType ());
+ }
+
+ // Mod()
+ AssertEquals ("Test#11", (SqlInt16)36, SqlInt16.Mod (Test164, Test64));
+ AssertEquals ("Test#12", (SqlInt16)64, SqlInt16.Mod (Test64, Test164));
+
+ // Multiply()
+ AssertEquals ("Test#13", (short)10496, SqlInt16.Multiply (Test64, Test164).Value);
+ AssertEquals ("Test#14", (short)0, SqlInt16.Multiply (Test64, Test0).Value);
+
+ try {
+ SqlInt16.Multiply (TestMax, Test64);
+ Fail ("Test#15");
+ } catch(Exception e) {
+ AssertEquals ("Test#16", typeof (OverflowException), e.GetType ());
+ }
+
+ // Subtract()
+ AssertEquals ("Test#17", (short)100, SqlInt16.Subtract (Test164, Test64).Value);
+
+ try {
+ SqlInt16.Subtract (SqlInt16.MinValue, Test164);
+ Fail("Test#18");
+ } catch(Exception e) {
+ AssertEquals ("Test#19", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestBitwiseMethods()
+ {
+ short MaxValue = SqlInt16.MaxValue.Value;
+ SqlInt16 TestInt = new SqlInt16 (0);
+ SqlInt16 TestIntMax = new SqlInt16 (MaxValue);
+ SqlInt16 TestInt2 = new SqlInt16 (10922);
+ SqlInt16 TestInt3 = new SqlInt16 (21845);
+
+ // BitwiseAnd
+ AssertEquals ("Test#1", (short)21845, SqlInt16.BitwiseAnd (TestInt3, TestIntMax).Value);
+ AssertEquals ("Test#2", (short)0, SqlInt16.BitwiseAnd (TestInt2, TestInt3).Value);
+ AssertEquals ("Test#3", (short)10922, SqlInt16.BitwiseAnd (TestInt2, TestIntMax).Value);
+
+ //BitwiseOr
+ AssertEquals ("Test#4", (short)MaxValue, SqlInt16.BitwiseOr (TestInt2, TestInt3).Value);
+ AssertEquals ("Test#5", (short)21845, SqlInt16.BitwiseOr (TestInt, TestInt3).Value);
+ AssertEquals ("Test#6", (short)MaxValue, SqlInt16.BitwiseOr (TestIntMax, TestInt2).Value);
+ }
+
+ public void TestCompareTo()
+ {
+ SqlInt16 TestInt4000 = new SqlInt16 (4000);
+ SqlInt16 TestInt4000II = new SqlInt16 (4000);
+ SqlInt16 TestInt10 = new SqlInt16 (10);
+ SqlInt16 TestInt10000 = new SqlInt16 (10000);
+ SqlString TestString = new SqlString ("This is a test");
+
+ Assert ("Test#1", TestInt4000.CompareTo (TestInt10) > 0);
+ Assert ("Test#2", TestInt10.CompareTo (TestInt4000) < 0);
+ Assert ("Test#3", TestInt4000II.CompareTo (TestInt4000) == 0);
+ Assert ("Test#4", TestInt4000II.CompareTo (SqlInt16.Null) > 0);
+
+ try {
+ TestInt10.CompareTo (TestString);
+ Fail ("Test#5");
+ } catch(Exception e) {
+ AssertEquals ("Test#6", typeof (ArgumentException), e.GetType ());
+ }
+ }
+
+ public void TestEqualsMethod()
+ {
+ SqlInt16 Test0 = new SqlInt16 (0);
+ SqlInt16 Test158 = new SqlInt16 (158);
+ SqlInt16 Test180 = new SqlInt16 (180);
+ SqlInt16 Test180II = new SqlInt16 (180);
+
+ Assert ("Test#1", !Test0.Equals (Test158));
+ Assert ("Test#2", !Test158.Equals (Test180));
+ Assert ("Test#3", !Test180.Equals (new SqlString ("TEST")));
+ Assert ("Test#4", Test180.Equals (Test180II));
+ }
+
+ public void TestStaticEqualsMethod()
+ {
+ SqlInt16 Test34 = new SqlInt16 (34);
+ SqlInt16 Test34II = new SqlInt16 (34);
+ SqlInt16 Test15 = new SqlInt16 (15);
+
+ Assert ("Test#1", SqlInt16.Equals (Test34, Test34II).Value);
+ Assert ("Test#2", !SqlInt16.Equals (Test34, Test15).Value);
+ Assert ("Test#3", !SqlInt16.Equals (Test15, Test34II).Value);
+ }
+
+ public void TestGetHashCode()
+ {
+ SqlInt16 Test15 = new SqlInt16 (15);
+
+ // FIXME: Better way to test GetHashCode()-methods
+ AssertEquals ("Test#1", Test15.GetHashCode (), Test15.GetHashCode ());
+ }
+
+ public void TestGetType()
+ {
+ SqlInt16 Test = new SqlInt16 (84);
+ AssertEquals ("Test#1", "System.Data.SqlTypes.SqlInt16", Test.GetType ().ToString ());
+ }
+
+ public void TestGreaters()
+ {
+ SqlInt16 Test10 = new SqlInt16 (10);
+ SqlInt16 Test10II = new SqlInt16 (10);
+ SqlInt16 Test110 = new SqlInt16 (110);
+
+ // GreateThan ()
+ Assert ("Test#1", !SqlInt16.GreaterThan (Test10, Test110).Value);
+ Assert ("Test#2", SqlInt16.GreaterThan (Test110, Test10).Value);
+ Assert ("Test#3", !SqlInt16.GreaterThan (Test10II, Test10).Value);
+
+ // GreaterTharOrEqual ()
+ Assert ("Test#4", !SqlInt16.GreaterThanOrEqual (Test10, Test110).Value);
+ Assert ("Test#5", SqlInt16.GreaterThanOrEqual (Test110, Test10).Value);
+ Assert ("Test#6", SqlInt16.GreaterThanOrEqual (Test10II, Test10).Value);
+ }
+
+ public void TestLessers()
+ {
+ SqlInt16 Test10 = new SqlInt16 (10);
+ SqlInt16 Test10II = new SqlInt16 (10);
+ SqlInt16 Test110 = new SqlInt16 (110);
+
+ // LessThan()
+ Assert ("Test#1", SqlInt16.LessThan (Test10, Test110).Value);
+ Assert ("Test#2", !SqlInt16.LessThan (Test110, Test10).Value);
+ Assert ("Test#3", !SqlInt16.LessThan (Test10II, Test10).Value);
+
+ // LessThanOrEqual ()
+ Assert ("Test#4", SqlInt16.LessThanOrEqual (Test10, Test110).Value);
+ Assert ("Test#5", !SqlInt16.LessThanOrEqual (Test110, Test10).Value);
+ Assert ("Test#6", SqlInt16.LessThanOrEqual (Test10II, Test10).Value);
+ Assert ("Test#7", SqlInt16.LessThanOrEqual (Test10II, SqlInt16.Null).IsNull);
+ }
+
+ public void TestNotEquals()
+ {
+ SqlInt16 Test12 = new SqlInt16 (12);
+ SqlInt16 Test128 = new SqlInt16 (128);
+ SqlInt16 Test128II = new SqlInt16 (128);
+
+ Assert ("Test#1", SqlInt16.NotEquals (Test12, Test128).Value);
+ Assert ("Test#2", SqlInt16.NotEquals (Test128, Test12).Value);
+ Assert ("Test#3", SqlInt16.NotEquals (Test128II, Test12).Value);
+ Assert ("Test#4", !SqlInt16.NotEquals (Test128II, Test128).Value);
+ Assert ("Test#5", !SqlInt16.NotEquals (Test128, Test128II).Value);
+ Assert ("Test#6", SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull);
+ Assert ("Test#7", SqlInt16.NotEquals (SqlInt16.Null, Test128II).IsNull);
+ }
+
+ public void TestOnesComplement()
+ {
+ SqlInt16 Test12 = new SqlInt16(12);
+ SqlInt16 Test128 = new SqlInt16(128);
+
+ AssertEquals ("Test#1", (SqlInt16)(-13), SqlInt16.OnesComplement (Test12));
+ AssertEquals ("Test#2", (SqlInt16)(-129), SqlInt16.OnesComplement (Test128));
+ }
+
+ public void TestParse()
+ {
+ try {
+ SqlInt16.Parse (null);
+ Fail ("Test#1");
+ } catch (Exception e) {
+ AssertEquals ("Test#2", typeof (ArgumentNullException), e.GetType ());
+ }
+
+ try {
+ SqlInt16.Parse ("not-a-number");
+ Fail ("Test#3");
+ } catch (Exception e) {
+ AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
+ }
+
+ try {
+ int OverInt = (int)SqlInt16.MaxValue + 1;
+ SqlInt16.Parse (OverInt.ToString ());
+ Fail ("Test#5");
+ } catch (Exception e) {
+ AssertEquals ("Test#6", typeof (OverflowException), e.GetType ());
+ }
+
+ AssertEquals("Test#7", (short)150, SqlInt16.Parse ("150").Value);
+ }
+
+ public void TestConversions()
+ {
+ SqlInt16 Test12 = new SqlInt16 (12);
+ SqlInt16 Test0 = new SqlInt16 (0);
+ SqlInt16 TestNull = SqlInt16.Null;
+ SqlInt16 Test1000 = new SqlInt16 (1000);
+ SqlInt16 Test288 = new SqlInt16(288);
+
+ // ToSqlBoolean ()
+ Assert ("TestA#1", Test12.ToSqlBoolean ().Value);
+ Assert ("TestA#2", !Test0.ToSqlBoolean ().Value);
+ Assert ("TestA#3", TestNull.ToSqlBoolean ().IsNull);
+
+ // ToSqlByte ()
+ AssertEquals ("TestB#1", (byte)12, Test12.ToSqlByte ().Value);
+ AssertEquals ("TestB#2", (byte)0, Test0.ToSqlByte ().Value);
+
+ try {
+ SqlByte b = (byte)Test1000.ToSqlByte ();
+ Fail ("TestB#4");
+ } catch (Exception e) {
+ AssertEquals ("TestB#5", typeof (OverflowException), e.GetType ());
+ }
+
+ // ToSqlDecimal ()
+ AssertEquals ("TestC#1", (decimal)12, Test12.ToSqlDecimal ().Value);
+ AssertEquals ("TestC#2", (decimal)0, Test0.ToSqlDecimal ().Value);
+ AssertEquals ("TestC#3", (decimal)288, Test288.ToSqlDecimal ().Value);
+
+ // ToSqlDouble ()
+ AssertEquals ("TestD#1", (double)12, Test12.ToSqlDouble ().Value);
+ AssertEquals ("TestD#2", (double)0, Test0.ToSqlDouble ().Value);
+ AssertEquals ("TestD#3", (double)1000, Test1000.ToSqlDouble ().Value);
+
+ // ToSqlInt32 ()
+ AssertEquals ("TestE#1", (int)12, Test12.ToSqlInt32 ().Value);
+ AssertEquals ("TestE#2", (int)0, Test0.ToSqlInt32 ().Value);
+ AssertEquals ("TestE#3", (int)288, Test288.ToSqlInt32().Value);
+
+ // ToSqlInt64 ()
+ AssertEquals ("TestF#1", (long)12, Test12.ToSqlInt64 ().Value);
+ AssertEquals ("TestF#2", (long)0, Test0.ToSqlInt64 ().Value);
+ AssertEquals ("TestF#3", (long)288, Test288.ToSqlInt64 ().Value);
+
+ // ToSqlMoney ()
+ AssertEquals ("TestG#1", (decimal)12, Test12.ToSqlMoney ().Value);
+ AssertEquals ("TestG#2", (decimal)0, Test0.ToSqlMoney ().Value);
+ AssertEquals ("TestG#3", (decimal)288, Test288.ToSqlMoney ().Value);
+
+ // ToSqlSingle ()
+ AssertEquals ("TestH#1", (float)12, Test12.ToSqlSingle ().Value);
+ AssertEquals ("TestH#2", (float)0, Test0.ToSqlSingle ().Value);
+ AssertEquals ("TestH#3", (float)288, Test288.ToSqlSingle().Value);
+
+ // ToSqlString ()
+ AssertEquals ("TestI#1", "12", Test12.ToSqlString ().Value);
+ AssertEquals ("TestI#2", "0", Test0.ToSqlString ().Value);
+ AssertEquals ("TestI#3", "288", Test288.ToSqlString ().Value);
+
+ // ToString ()
+ AssertEquals ("TestJ#1", "12", Test12.ToString ());
+ AssertEquals ("TestJ#2", "0", Test0.ToString ());
+ AssertEquals ("TestJ#3", "288", Test288.ToString ());
+ }
+
+
+ public void TestXor()
+ {
+ SqlInt16 Test14 = new SqlInt16 (14);
+ SqlInt16 Test58 = new SqlInt16 (58);
+ SqlInt16 Test130 = new SqlInt16 (130);
+ SqlInt16 TestMax = new SqlInt16 (SqlInt16.MaxValue.Value);
+ SqlInt16 Test0 = new SqlInt16 (0);
+
+ AssertEquals ("Test#1", (short)52, SqlInt16.Xor (Test14, Test58).Value);
+ AssertEquals ("Test#2", (short)140, SqlInt16.Xor (Test14, Test130).Value);
+ AssertEquals ("Test#3", (short)184, SqlInt16.Xor (Test58, Test130).Value);
+ AssertEquals ("Test#4", (short)0, SqlInt16.Xor (TestMax, TestMax).Value);
+ AssertEquals ("Test#5", TestMax.Value, SqlInt16.Xor (TestMax, Test0).Value);
+ }
+
+ // OPERATORS
+
+ public void TestArithmeticOperators()
+ {
+ SqlInt16 Test24 = new SqlInt16 (24);
+ SqlInt16 Test64 = new SqlInt16 (64);
+ SqlInt16 Test2550 = new SqlInt16 (2550);
+ SqlInt16 Test0 = new SqlInt16 (0);
+
+ // "+"-operator
+ AssertEquals ("TestA#1", (SqlInt16)2614,Test2550 + Test64);
+ try {
+ SqlInt16 result = Test64 + SqlInt16.MaxValue;
+ Fail ("TestA#2");
+ } catch (Exception e) {
+ AssertEquals ("TestA#3", typeof (OverflowException), e.GetType ());
+ }
+
+ // "/"-operator
+ AssertEquals ("TestB#1", (SqlInt16)39, Test2550 / Test64);
+ AssertEquals ("TestB#2", (SqlInt16)0, Test24 / Test64);
+
+ try {
+ SqlInt16 result = Test2550 / Test0;
+ Fail ("TestB#3");
+ } catch (Exception e) {
+ AssertEquals ("TestB#4", typeof (DivideByZeroException), e.GetType ());
+ }
+
+ // "*"-operator
+ AssertEquals ("TestC#1", (SqlInt16)1536, Test64 * Test24);
+
+ try {
+ SqlInt16 test = (SqlInt16.MaxValue * Test64);
+ Fail ("TestC#2");
+ } catch (Exception e) {
+ AssertEquals ("TestC#3", typeof (OverflowException), e.GetType ());
+ }
+
+ // "-"-operator
+ AssertEquals ("TestD#1", (SqlInt16)2526, Test2550 - Test24);
+
+ try {
+ SqlInt16 test = SqlInt16.MinValue - Test64;
+ Fail ("TestD#2");
+ } catch (Exception e) {
+ AssertEquals ("OverflowException", typeof (OverflowException), e.GetType ());
+ }
+
+ // "%"-operator
+ AssertEquals ("TestE#1", (SqlInt16)54, Test2550 % Test64);
+ AssertEquals ("TestE#2", (SqlInt16)24, Test24 % Test64);
+ AssertEquals ("TestE#1", (SqlInt16)0, new SqlInt16 (100) % new SqlInt16 (10));
+ }
+
+ public void TestBitwiseOperators()
+ {
+ SqlInt16 Test2 = new SqlInt16 (2);
+ SqlInt16 Test4 = new SqlInt16 (4);
+ SqlInt16 Test2550 = new SqlInt16 (2550);
+
+ // & -operator
+ AssertEquals ("TestA#1", (SqlInt16)0, Test2 & Test4);
+ AssertEquals ("TestA#2", (SqlInt16)2, Test2 & Test2550);
+ AssertEquals ("TestA#3", (SqlInt16)0, SqlInt16.MaxValue & SqlInt16.MinValue);
+
+ // | -operator
+ AssertEquals ("TestB#1", (SqlInt16)6,Test2 | Test4);
+ AssertEquals ("TestB#2", (SqlInt16)2550, Test2 | Test2550);
+ AssertEquals ("TestB#3", (SqlInt16)(-1), SqlInt16.MinValue | SqlInt16.MaxValue);
+
+ // ^ -operator
+ AssertEquals("TestC#1", (SqlInt16)2546, (Test2550 ^ Test4));
+ AssertEquals("TestC#2", (SqlInt16)6, (Test2 ^ Test4));
+ }
+
+ public void TestThanOrEqualOperators()
+ {
+ SqlInt16 Test165 = new SqlInt16 (165);
+ SqlInt16 Test100 = new SqlInt16 (100);
+ SqlInt16 Test100II = new SqlInt16 (100);
+ SqlInt16 Test255 = new SqlInt16 (2550);
+
+ // == -operator
+ Assert ("TestA#1", (Test100 == Test100II).Value);
+ Assert ("TestA#2", !(Test165 == Test100).Value);
+ Assert ("TestA#3", (Test165 == SqlInt16.Null).IsNull);
+
+ // != -operator
+ Assert ("TestB#1", !(Test100 != Test100II).Value);
+ Assert ("TestB#2", (Test100 != Test255).Value);
+ Assert ("TestB#3", (Test165 != Test255).Value);
+ Assert ("TestB#4", (Test165 != SqlInt16.Null).IsNull);
+
+ // > -operator
+ Assert ("TestC#1", (Test165 > Test100).Value);
+ Assert ("TestC#2", !(Test165 > Test255).Value);
+ Assert ("TestC#3", !(Test100 > Test100II).Value);
+ Assert ("TestC#4", (Test165 > SqlInt16.Null).IsNull);
+
+ // >= -operator
+ Assert ("TestD#1", !(Test165 >= Test255).Value);
+ Assert ("TestD#2", (Test255 >= Test165).Value);
+ Assert ("TestD#3", (Test100 >= Test100II).Value);
+ Assert ("TestD#4", (Test165 >= SqlInt16.Null).IsNull);
+
+ // < -operator
+ Assert ("TestE#1", !(Test165 < Test100).Value);
+ Assert ("TestE#2", (Test165 < Test255).Value);
+ Assert ("TestE#3", !(Test100 < Test100II).Value);
+ Assert ("TestE#4", (Test165 < SqlInt16.Null).IsNull);
+
+ // <= -operator
+ Assert ("TestF#1", (Test165 <= Test255).Value);
+ Assert ("TestF#2", !(Test255 <= Test165).Value);
+ Assert ("TestF#3", (Test100 <= Test100II).Value);
+ Assert ("TestF#4", (Test165 <= SqlInt16.Null).IsNull);
+ }
+
+ public void TestOnesComplementOperator()
+ {
+ SqlInt16 Test12 = new SqlInt16 (12);
+ SqlInt16 Test128 = new SqlInt16 (128);
+
+ AssertEquals ("Test#1", (SqlInt16)(-13), ~Test12);
+ AssertEquals ("Test#2", (SqlInt16)(-129), ~Test128);
+ AssertEquals ("Test#3", SqlInt16.Null, ~SqlInt16.Null);
+ }
+
+ public void TestUnaryNegation()
+ {
+ SqlInt16 Test = new SqlInt16 (2000);
+ SqlInt16 TestNeg = new SqlInt16 (-3000);
+
+ SqlInt16 Result = -Test;
+ AssertEquals ("Test#1", (short)(-2000), Result.Value);
+
+ Result = -TestNeg;
+ AssertEquals ("Test#2", (short)3000, Result.Value);
+ }
+
+ public void TestSqlBooleanToSqlInt16()
+ {
+ SqlBoolean TestBoolean = new SqlBoolean (true);
+ SqlInt16 Result;
+
+ Result = (SqlInt16)TestBoolean;
+
+ AssertEquals ("Test#1", (short)1, Result.Value);
+
+ Result = (SqlInt16)SqlBoolean.Null;
+ Assert ("Test#2", Result.IsNull);
+ }
+
+ public void TestSqlDecimalToSqlInt16()
+ {
+ SqlDecimal TestDecimal64 = new SqlDecimal (64);
+ SqlDecimal TestDecimal900 = new SqlDecimal (90000);
+
+ AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDecimal64).Value);
+ AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDecimal.Null));
+
+ try {
+ SqlInt16 test = (SqlInt16)TestDecimal900;
+ Fail ("Test#3");
+ } catch (Exception e) {
+ AssertEquals("Test#4", typeof(OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlDoubleToSqlInt16()
+ {
+ SqlDouble TestDouble64 = new SqlDouble (64);
+ SqlDouble TestDouble900 = new SqlDouble (90000);
+
+ AssertEquals ("Test#1", (short)64, ((SqlInt16)TestDouble64).Value);
+ AssertEquals ("Test#2", SqlInt16.Null, ((SqlInt16)SqlDouble.Null));
+
+ try {
+ SqlInt16 test = (SqlInt16)TestDouble900;
+ Fail ("Test#3");
+ } catch (Exception e) {
+ AssertEquals("Test#4", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlIntToInt16()
+ {
+ SqlInt16 Test = new SqlInt16(12);
+ Int16 Result = (Int16)Test;
+ AssertEquals("Test#1", (short)12, Result);
+ }
+
+ public void TestSqlInt32ToSqlInt16()
+ {
+ SqlInt32 Test64 = new SqlInt32 (64);
+ SqlInt32 Test900 = new SqlInt32 (90000);
+
+ AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
+
+ try {
+ SqlInt16 test = (SqlInt16)Test900;
+ Fail ("Test#2");
+ } catch (Exception e) {
+ AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlInt64ToSqlInt16()
+ {
+ SqlInt64 Test64 = new SqlInt64 (64);
+ SqlInt64 Test900 = new SqlInt64 (90000);
+
+ AssertEquals ("Test#1", (short)64, ((SqlInt16)Test64).Value);
+
+ try {
+ SqlInt16 test = (SqlInt16)Test900;
+ Fail ("Test#2");
+ } catch (Exception e) {
+ AssertEquals("Test#3", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlMoneyToSqlInt16()
+ {
+ SqlMoney TestMoney64 = new SqlMoney(64);
+ SqlMoney TestMoney900 = new SqlMoney(90000);
+
+ AssertEquals ("Test#1", (short)64, ((SqlInt16)TestMoney64).Value);
+
+ try {
+ SqlInt16 test = (SqlInt16)TestMoney900;
+ Fail ("Test#2");
+ } catch (Exception e) {
+ AssertEquals("test#3", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlSingleToSqlInt16()
+ {
+ SqlSingle TestSingle64 = new SqlSingle(64);
+ SqlSingle TestSingle900 = new SqlSingle(90000);
+
+ AssertEquals("Test#1", (short)64, ((SqlInt16)TestSingle64).Value);
+
+ try {
+ SqlInt16 test = (SqlInt16)TestSingle900;
+ Fail ("Test#2");
+ } catch (Exception e) {
+ AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSqlStringToSqlInt16()
+ {
+ SqlString TestString = new SqlString("Test string");
+ SqlString TestString100 = new SqlString("100");
+ SqlString TestString1000 = new SqlString("100000");
+
+ AssertEquals ("Test#1", (short)100, ((SqlInt16)TestString100).Value);
+
+ try {
+ SqlInt16 test = (SqlInt16)TestString1000;
+ Fail ("Test#2");
+ } catch(Exception e) {
+ AssertEquals ("Test#3", typeof (OverflowException), e.GetType ());
+ }
+
+ try {
+ SqlInt16 test = (SqlInt16)TestString;
+ Fail ("Test#3");
+ } catch(Exception e) {
+ AssertEquals ("Test#4", typeof (FormatException), e.GetType ());
+ }
+ }
+
+ public void TestByteToSqlInt16()
+ {
+ short TestShort = 14;
+ AssertEquals ("Test#1", (short)14, ((SqlInt16)TestShort).Value);
+ }
+ }
+}
+
--- /dev/null
+//
+// SqlInt64Test.cs - NUnit Test Cases for System.Data.SqlTypes.SqlInt64
+//
+// Ville Palo (vi64pa@koti.soon.fi)
+//
+// (C) Ville Palo 2002
+//
+
+using NUnit.Framework;
+using System;
+using System.Data.SqlTypes;
+
+namespace MonoTests.System.Data.SqlTypes
+{
+ public class SqlInt64Test : TestCase {
+
+ public SqlInt64Test() : base ("System.Data.SqlTypes.SqlInt64") {}
+ public SqlInt64Test(string name) : base(name) {}
+
+ protected override void TearDown() {}
+
+ protected override void SetUp() {}
+
+ public static ITest Suite {
+ get {
+ return new TestSuite(typeof(SqlInt64));
+ }
+ }
+
+ // Test constructor
+ public void TestCreate()
+ {
+ SqlInt64 TestLong = new SqlInt64 (29);
+ AssertEquals ("#A01", (long)29, TestLong.Value);
+
+ TestLong = new SqlInt64 (-9000);
+ AssertEquals ("#A02", (long)-9000, TestLong.Value);
+ }
+
+ // Test public fields
+ public void TestPublicFields()
+ {
+ AssertEquals ("#B01", (long)9223372036854775807, SqlInt64.MaxValue.Value);
+ AssertEquals ("#B02", (long)(-9223372036854775808), SqlInt64.MinValue.Value);
+ Assert ("#B03", SqlInt64.Null.IsNull);
+ AssertEquals ("#B04", (long)0, SqlInt64.Zero.Value);
+ }
+
+ // Test properties
+ public void TestProperties()
+ {
+ SqlInt64 Test5443 = new SqlInt64 (5443);
+ SqlInt64 Test1 = new SqlInt64 (1);
+
+ Assert ("#C01", SqlInt64.Null.IsNull);
+ AssertEquals ("#C02", (long)5443, Test5443.Value);
+ AssertEquals ("#C03", (long)1, Test1.Value);
+ }
+
+ // PUBLIC METHODS
+
+ public void TestArithmeticMethods()
+ {
+ SqlInt64 Test64 = new SqlInt64 (64);
+ SqlInt64 Test0 = new SqlInt64 (0);
+ SqlInt64 Test164 = new SqlInt64 (164);
+ SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
+
+ // Add()
+ AssertEquals ("#D01", (long)64, SqlInt64.Add (Test64, Test0).Value);
+ AssertEquals ("#D02", (long)228, SqlInt64.Add (Test64, Test164).Value);
+ AssertEquals ("#D03", (long)164, SqlInt64.Add (Test0, Test164).Value);
+ AssertEquals ("#D04", (long)SqlInt64.MaxValue, SqlInt64.Add (TestMax, Test0).Value);
+
+ try {
+ SqlInt64.Add (TestMax, Test64);
+ Fail ("#D05");
+ } catch (Exception e) {
+ AssertEquals ("#D06", typeof (OverflowException), e.GetType ());
+ }
+
+ // Divide()
+ AssertEquals ("#D07", (long)2, SqlInt64.Divide (Test164, Test64).Value);
+ AssertEquals ("#D08", (long)0, SqlInt64.Divide (Test64, Test164).Value);
+
+ try {
+ SqlInt64.Divide(Test64, Test0);
+ Fail ("#D09");
+ } catch(Exception e) {
+ AssertEquals ("#D10", typeof (DivideByZeroException), e.GetType ());
+ }
+
+ // Mod()
+ AssertEquals ("#D11", (SqlInt64)36, SqlInt64.Mod (Test164, Test64));
+ AssertEquals ("#D12", (SqlInt64)64, SqlInt64.Mod (Test64, Test164));
+
+ // Multiply()
+ AssertEquals ("#D13", (long)10496, SqlInt64.Multiply (Test64, Test164).Value);
+ AssertEquals ("#D14", (long)0, SqlInt64.Multiply (Test64, Test0).Value);
+
+ try {
+ SqlInt64.Multiply (TestMax, Test64);
+ Fail ("#D15");
+ } catch(Exception e) {
+ AssertEquals ("#D16", typeof (OverflowException), e.GetType ());
+ }
+
+ // Subtract()
+ AssertEquals ("#D17", (long)100, SqlInt64.Subtract (Test164, Test64).Value);
+
+ try {
+ SqlInt64.Subtract (SqlInt64.MinValue, Test164);
+ Fail ("#D18");
+ } catch(Exception e) {
+ AssertEquals ("#D19", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestBitwiseMethods()
+ {
+ long MaxValue = SqlInt64.MaxValue.Value;
+ SqlInt64 TestInt = new SqlInt64 (0);
+ SqlInt64 TestIntMax = new SqlInt64 (MaxValue);
+ SqlInt64 TestInt2 = new SqlInt64 (10922);
+ SqlInt64 TestInt3 = new SqlInt64 (21845);
+
+ // BitwiseAnd
+ AssertEquals ("#E01", (long)21845, SqlInt64.BitwiseAnd (TestInt3, TestIntMax).Value);
+ AssertEquals ("#E02", (long)0, SqlInt64.BitwiseAnd (TestInt2, TestInt3).Value);
+ AssertEquals ("#E03", (long)10922, SqlInt64.BitwiseAnd (TestInt2, TestIntMax).Value);
+
+ //BitwiseOr
+ AssertEquals ("#E04", (long)21845, SqlInt64.BitwiseOr (TestInt, TestInt3).Value);
+ AssertEquals ("#E05", (long)MaxValue, SqlInt64.BitwiseOr (TestIntMax, TestInt2).Value);
+ }
+
+ public void TestCompareTo()
+ {
+ SqlInt64 TestInt4000 = new SqlInt64 (4000);
+ SqlInt64 TestInt4000II = new SqlInt64 (4000);
+ SqlInt64 TestInt10 = new SqlInt64 (10);
+ SqlInt64 TestInt10000 = new SqlInt64 (10000);
+ SqlString TestString = new SqlString ("This is a test");
+
+ Assert ("#F01", TestInt4000.CompareTo (TestInt10) > 0);
+ Assert ("#F02", TestInt10.CompareTo (TestInt4000) < 0);
+ Assert ("#F03", TestInt4000II.CompareTo (TestInt4000) == 0);
+ Assert ("#F04", TestInt4000II.CompareTo (SqlInt64.Null) > 0);
+
+ try {
+ TestInt10.CompareTo (TestString);
+ Fail("#F05");
+ } catch(Exception e) {
+ AssertEquals ("#F06", typeof (ArgumentException), e.GetType ());
+ }
+ }
+
+ public void TestEqualsMethod()
+ {
+ SqlInt64 Test0 = new SqlInt64 (0);
+ SqlInt64 Test158 = new SqlInt64 (158);
+ SqlInt64 Test180 = new SqlInt64 (180);
+ SqlInt64 Test180II = new SqlInt64 (180);
+
+ Assert ("#G01", !Test0.Equals (Test158));
+ Assert ("#G01", !Test158.Equals (Test180));
+ Assert ("#G03", !Test180.Equals (new SqlString ("TEST")));
+ Assert ("#G04", Test180.Equals (Test180II));
+ }
+
+ public void TestStaticEqualsMethod()
+ {
+ SqlInt64 Test34 = new SqlInt64 (34);
+ SqlInt64 Test34II = new SqlInt64 (34);
+ SqlInt64 Test15 = new SqlInt64 (15);
+
+ Assert ("#H01", SqlInt64.Equals (Test34, Test34II).Value);
+ Assert ("#H02", !SqlInt64.Equals (Test34, Test15).Value);
+ Assert ("#H03", !SqlInt64.Equals (Test15, Test34II).Value);
+ }
+
+ public void TestGetHashCode()
+ {
+ SqlInt64 Test15 = new SqlInt64 (15);
+
+ // FIXME: Better way to test HashCode
+ AssertEquals ("#I01", (int)15, Test15.GetHashCode ());
+ }
+
+ public void TestGetType()
+ {
+ SqlInt64 Test = new SqlInt64 (84);
+ AssertEquals ("#J01", "System.Data.SqlTypes.SqlInt64", Test.GetType ().ToString ());
+ }
+
+ public void TestGreaters()
+ {
+ SqlInt64 Test10 = new SqlInt64 (10);
+ SqlInt64 Test10II = new SqlInt64 (10);
+ SqlInt64 Test110 = new SqlInt64 (110);
+
+ // GreateThan ()
+ Assert ("#K01", !SqlInt64.GreaterThan (Test10, Test110).Value);
+ Assert ("#K02", SqlInt64.GreaterThan (Test110, Test10).Value);
+ Assert ("#K03", !SqlInt64.GreaterThan (Test10II, Test10).Value);
+
+ // GreaterTharOrEqual ()
+ Assert ("#K04", !SqlInt64.GreaterThanOrEqual (Test10, Test110).Value);
+ Assert ("#K05", SqlInt64.GreaterThanOrEqual (Test110, Test10).Value);
+ Assert ("#K06", SqlInt64.GreaterThanOrEqual (Test10II, Test10).Value);
+ }
+
+ public void TestLessers()
+ {
+ SqlInt64 Test10 = new SqlInt64 (10);
+ SqlInt64 Test10II = new SqlInt64 (10);
+ SqlInt64 Test110 = new SqlInt64 (110);
+
+ // LessThan()
+ Assert ("#L01", SqlInt64.LessThan (Test10, Test110).Value);
+ Assert ("#L02", !SqlInt64.LessThan (Test110, Test10).Value);
+ Assert ("#L03", !SqlInt64.LessThan (Test10II, Test10).Value);
+
+ // LessThanOrEqual ()
+ Assert ("#L04", SqlInt64.LessThanOrEqual (Test10, Test110).Value);
+ Assert ("#L05", !SqlInt64.LessThanOrEqual (Test110, Test10).Value);
+ Assert ("#L06", SqlInt64.LessThanOrEqual (Test10II, Test10).Value);
+ Assert ("#L07", SqlInt64.LessThanOrEqual (Test10II, SqlInt64.Null).IsNull);
+ }
+
+ public void TestNotEquals()
+ {
+ SqlInt64 Test12 = new SqlInt64 (12);
+ SqlInt64 Test128 = new SqlInt64 (128);
+ SqlInt64 Test128II = new SqlInt64 (128);
+
+ Assert ("#M01", SqlInt64.NotEquals (Test12, Test128).Value);
+ Assert ("#M02", SqlInt64.NotEquals (Test128, Test12).Value);
+ Assert ("#M03", SqlInt64.NotEquals (Test128II, Test12).Value);
+ Assert ("#M04", !SqlInt64.NotEquals (Test128II, Test128).Value);
+ Assert ("#M05", !SqlInt64.NotEquals (Test128, Test128II).Value);
+ Assert ("#M06", SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull);
+ Assert ("#M07", SqlInt64.NotEquals (SqlInt64.Null, Test128II).IsNull);
+ }
+
+ public void TestOnesComplement()
+ {
+ SqlInt64 Test12 = new SqlInt64(12);
+ SqlInt64 Test128 = new SqlInt64(128);
+
+ AssertEquals ("#N01", (SqlInt64)(-13), SqlInt64.OnesComplement (Test12));
+ AssertEquals ("#N02", (SqlInt64)(-129), SqlInt64.OnesComplement (Test128));
+ }
+
+ public void TestParse()
+ {
+ try {
+ SqlInt64.Parse (null);
+ Fail ("#O01");
+ } catch (Exception e) {
+ AssertEquals ("#O02", typeof (ArgumentNullException), e.GetType ());
+ }
+
+ try {
+ SqlInt64.Parse ("not-a-number");
+ Fail ("#O03");
+ } catch (Exception e) {
+ AssertEquals ("#O04", typeof (FormatException), e.GetType ());
+ }
+
+ try {
+ SqlInt64.Parse ("1000000000000000000000000000");
+ Fail ("#O05");
+ } catch (Exception e) {
+ AssertEquals ("#O06", typeof (OverflowException), e.GetType ());
+ }
+
+ AssertEquals("#O07", (long)150, SqlInt64.Parse ("150").Value);
+ }
+
+ public void TestConversions()
+ {
+ SqlInt64 Test12 = new SqlInt64 (12);
+ SqlInt64 Test0 = new SqlInt64 (0);
+ SqlInt64 TestNull = SqlInt64.Null;
+ SqlInt64 Test1000 = new SqlInt64 (1000);
+ SqlInt64 Test288 = new SqlInt64(288);
+
+ // ToSqlBoolean ()
+ Assert ("#P01", Test12.ToSqlBoolean ().Value);
+ Assert ("#P02", !Test0.ToSqlBoolean ().Value);
+ Assert ("#P03", TestNull.ToSqlBoolean ().IsNull);
+
+ // ToSqlByte ()
+ AssertEquals ("#P04", (byte)12, Test12.ToSqlByte ().Value);
+ AssertEquals ("#P05", (byte)0, Test0.ToSqlByte ().Value);
+
+ try {
+ SqlByte b = (byte)Test1000.ToSqlByte ();
+ Fail ("#P06");
+ } catch (Exception e) {
+ AssertEquals ("#P07", typeof (OverflowException), e.GetType ());
+ }
+
+ // ToSqlDecimal ()
+ AssertEquals ("#P08", (decimal)12, Test12.ToSqlDecimal ().Value);
+ AssertEquals ("#P09", (decimal)0, Test0.ToSqlDecimal ().Value);
+ AssertEquals ("#P10", (decimal)288, Test288.ToSqlDecimal ().Value);
+
+ // ToSqlDouble ()
+ AssertEquals ("#P11", (double)12, Test12.ToSqlDouble ().Value);
+ AssertEquals ("#P12", (double)0, Test0.ToSqlDouble ().Value);
+ AssertEquals ("#P13", (double)1000, Test1000.ToSqlDouble ().Value);
+
+ // ToSqlInt32 ()
+ AssertEquals ("#P14", (int)12, Test12.ToSqlInt32 ().Value);
+ AssertEquals ("#P15", (int)0, Test0.ToSqlInt32 ().Value);
+ AssertEquals ("#P16", (int)288, Test288.ToSqlInt32().Value);
+
+ // ToSqlInt16 ()
+ AssertEquals ("#P17", (short)12, Test12.ToSqlInt16 ().Value);
+ AssertEquals ("#P18", (short)0, Test0.ToSqlInt16 ().Value);
+ AssertEquals ("#P19", (short)288, Test288.ToSqlInt16 ().Value);
+
+ // ToSqlMoney ()
+ AssertEquals ("#P20", (decimal)12, Test12.ToSqlMoney ().Value);
+ AssertEquals ("#P21", (decimal)0, Test0.ToSqlMoney ().Value);
+ AssertEquals ("#P22", (decimal)288, Test288.ToSqlMoney ().Value);
+
+ // ToSqlSingle ()
+ AssertEquals ("#P23", (float)12, Test12.ToSqlSingle ().Value);
+ AssertEquals ("#P24", (float)0, Test0.ToSqlSingle ().Value);
+ AssertEquals ("#P25", (float)288, Test288.ToSqlSingle().Value);
+
+ // ToSqlString ()
+ AssertEquals ("#P26", "12", Test12.ToSqlString ().Value);
+ AssertEquals ("#P27", "0", Test0.ToSqlString ().Value);
+ AssertEquals ("#P28", "288", Test288.ToSqlString ().Value);
+
+ // ToString ()
+ AssertEquals ("#P29", "12", Test12.ToString ());
+ AssertEquals ("#P30", "0", Test0.ToString ());
+ AssertEquals ("#P31", "288", Test288.ToString ());
+ }
+
+ public void TestXor()
+ {
+ SqlInt64 Test14 = new SqlInt64 (14);
+ SqlInt64 Test58 = new SqlInt64 (58);
+ SqlInt64 Test130 = new SqlInt64 (130);
+ SqlInt64 TestMax = new SqlInt64 (SqlInt64.MaxValue.Value);
+ SqlInt64 Test0 = new SqlInt64 (0);
+
+ AssertEquals ("#Q01", (long)52, SqlInt64.Xor (Test14, Test58).Value);
+ AssertEquals ("#Q02", (long)140, SqlInt64.Xor (Test14, Test130).Value);
+ AssertEquals ("#Q03", (long)184, SqlInt64.Xor (Test58, Test130).Value);
+ AssertEquals ("#Q04", (long)0, SqlInt64.Xor (TestMax, TestMax).Value);
+ AssertEquals ("#Q05", TestMax.Value, SqlInt64.Xor (TestMax, Test0).Value);
+ }
+
+ // OPERATORS
+
+ public void TestArithmeticOperators()
+ {
+ SqlInt64 Test24 = new SqlInt64 (24);
+ SqlInt64 Test64 = new SqlInt64 (64);
+ SqlInt64 Test2550 = new SqlInt64 (2550);
+ SqlInt64 Test0 = new SqlInt64 (0);
+
+ // "+"-operator
+ AssertEquals ("#R01", (SqlInt64)2614,Test2550 + Test64);
+ try {
+ SqlInt64 result = Test64 + SqlInt64.MaxValue;
+ Fail ("#R02");
+ } catch (Exception e) {
+ AssertEquals ("#R03", typeof (OverflowException), e.GetType ());
+ }
+
+ // "/"-operator
+ AssertEquals ("#R04", (SqlInt64)39, Test2550 / Test64);
+ AssertEquals ("#R05", (SqlInt64)0, Test24 / Test64);
+
+ try {
+ SqlInt64 result = Test2550 / Test0;
+ Fail ("#R06");
+ } catch (Exception e) {
+ AssertEquals ("#R07", typeof (DivideByZeroException), e.GetType ());
+ }
+
+ // "*"-operator
+ AssertEquals ("#R08", (SqlInt64)1536, Test64 * Test24);
+
+ try {
+ SqlInt64 test = (SqlInt64.MaxValue * Test64);
+ Fail ("TestC#2");
+ } catch (Exception e) {
+ AssertEquals ("#R08", typeof (OverflowException), e.GetType ());
+ }
+
+ // "-"-operator
+ AssertEquals ("#R09", (SqlInt64)2526, Test2550 - Test24);
+
+ try {
+ SqlInt64 test = SqlInt64.MinValue - Test64;
+ Fail ("#R10");
+ } catch (Exception e) {
+ AssertEquals ("#R11", typeof (OverflowException), e.GetType ());
+ }
+
+ // "%"-operator
+ AssertEquals ("#R12", (SqlInt64)54, Test2550 % Test64);
+ AssertEquals ("#R13", (SqlInt64)24, Test24 % Test64);
+ AssertEquals ("#R14", (SqlInt64)0, new SqlInt64 (100) % new SqlInt64 (10));
+ }
+
+ public void TestBitwiseOperators()
+ {
+ SqlInt64 Test2 = new SqlInt64 (2);
+ SqlInt64 Test4 = new SqlInt64 (4);
+
+ SqlInt64 Test2550 = new SqlInt64 (2550);
+
+ // & -operator
+ AssertEquals ("#S01", (SqlInt64)0, Test2 & Test4);
+ AssertEquals ("#S02", (SqlInt64)2, Test2 & Test2550);
+ AssertEquals ("#S03", (SqlInt64)0, SqlInt64.MaxValue & SqlInt64.MinValue);
+
+ // | -operator
+ AssertEquals ("#S04", (SqlInt64)6,Test2 | Test4);
+ AssertEquals ("#S05", (SqlInt64)2550, Test2 | Test2550);
+ AssertEquals ("#S06", (SqlInt64)(-1), SqlInt64.MinValue | SqlInt64.MaxValue);
+
+ // ^ -operator
+ AssertEquals("#S07", (SqlInt64)2546, (Test2550 ^ Test4));
+ AssertEquals("#S08", (SqlInt64)6, (Test2 ^ Test4));
+ }
+
+ public void TestThanOrEqualOperators()
+ {
+ SqlInt64 Test165 = new SqlInt64 (165);
+ SqlInt64 Test100 = new SqlInt64 (100);
+ SqlInt64 Test100II = new SqlInt64 (100);
+ SqlInt64 Test255 = new SqlInt64 (2550);
+
+ // == -operator
+ Assert ("#T01", (Test100 == Test100II).Value);
+ Assert ("#T02", !(Test165 == Test100).Value);
+ Assert ("#T03", (Test165 == SqlInt64.Null).IsNull);
+
+ // != -operator
+ Assert ("#T04", !(Test100 != Test100II).Value);
+ Assert ("#T05", (Test100 != Test255).Value);
+ Assert ("#T06", (Test165 != Test255).Value);
+ Assert ("#T07", (Test165 != SqlInt64.Null).IsNull);
+
+ // > -operator
+ Assert ("#T08", (Test165 > Test100).Value);
+ Assert ("#T09", !(Test165 > Test255).Value);
+ Assert ("#T10", !(Test100 > Test100II).Value);
+ Assert ("#T11", (Test165 > SqlInt64.Null).IsNull);
+
+ // >= -operator
+ Assert ("#T12", !(Test165 >= Test255).Value);
+ Assert ("#T13", (Test255 >= Test165).Value);
+ Assert ("#T14", (Test100 >= Test100II).Value);
+ Assert ("#T15", (Test165 >= SqlInt64.Null).IsNull);
+
+ // < -operator
+ Assert ("#T16", !(Test165 < Test100).Value);
+ Assert ("#T17", (Test165 < Test255).Value);
+ Assert ("#T18", !(Test100 < Test100II).Value);
+ Assert ("#T19", (Test165 < SqlInt64.Null).IsNull);
+
+ // <= -operator
+ Assert ("#T20", (Test165 <= Test255).Value);
+ Assert ("#T21", !(Test255 <= Test165).Value);
+ Assert ("#T22", (Test100 <= Test100II).Value);
+ Assert ("#T23", (Test165 <= SqlInt64.Null).IsNull);
+ }
+
+ public void TestOnesComplementOperator()
+ {
+ SqlInt64 Test12 = new SqlInt64 (12);
+ SqlInt64 Test128 = new SqlInt64 (128);
+
+ AssertEquals ("#V01", (SqlInt64)(-13), ~Test12);
+ AssertEquals ("#V02", (SqlInt64)(-129), ~Test128);
+ AssertEquals ("#V03", SqlInt64.Null, ~SqlInt64.Null);
+ }
+
+ public void TestUnaryNegation()
+ {
+ SqlInt64 Test = new SqlInt64 (2000);
+ SqlInt64 TestNeg = new SqlInt64 (-3000);
+
+ SqlInt64 Result = -Test;
+ AssertEquals ("#W01", (long)(-2000), Result.Value);
+
+ Result = -TestNeg;
+ AssertEquals ("#W02", (long)3000, Result.Value);
+ }
+
+ public void TestSqlBooleanToSqlInt64()
+ {
+ SqlBoolean TestBoolean = new SqlBoolean (true);
+ SqlInt64 Result;
+
+ Result = (SqlInt64)TestBoolean;
+
+ AssertEquals ("#X01", (long)1, Result.Value);
+
+ Result = (SqlInt64)SqlBoolean.Null;
+ Assert ("#X02", Result.IsNull);
+ }
+
+ public void TestSqlDecimalToSqlInt64()
+ {
+ SqlDecimal TestDecimal64 = new SqlDecimal (64);
+ SqlDecimal TestDecimal900 = new SqlDecimal (90000);
+
+ AssertEquals("#Y01", (long)64, ((SqlInt64)TestDecimal64).Value);
+ AssertEquals("#Y02", SqlInt64.Null, ((SqlInt64)SqlDecimal.Null));
+
+ try {
+ SqlInt64 test = (SqlInt64)SqlDecimal.MaxValue;
+ Fail("#Y03");
+ } catch (Exception e) {
+ AssertEquals("#Y04", typeof(OverflowException), e.GetType());
+ }
+ }
+
+ public void TestSqlDoubleToSqlInt64()
+ {
+ SqlDouble TestDouble64 = new SqlDouble (64);
+ SqlDouble TestDouble900 = new SqlDouble (90000);
+
+ AssertEquals ("#Z01", (long)64, ((SqlInt64)TestDouble64).Value);
+ AssertEquals ("#Z02", SqlInt64.Null, ((SqlInt64)SqlDouble.Null));
+
+ try {
+ SqlInt64 test = (SqlInt64)SqlDouble.MaxValue;
+ Fail ("#Z03");
+ } catch (Exception e) {
+ AssertEquals("#Z04", typeof (OverflowException), e.GetType ());
+ }
+ }
+
+ public void TestSql64IntToInt64()
+ {
+ SqlInt64 Test = new SqlInt64 (12);
+ Int64 Result = (Int64)Test;
+ AssertEquals ("#AA01", (long)12, Result);
+ }
+
+ public void TestSqlInt32ToSqlInt64()
+ {
+ SqlInt32 Test64 = new SqlInt32 (64);
+ AssertEquals ("#AB01", (long)64, ((SqlInt64)Test64).Value);
+ }
+
+ public void TestSqlInt16ToSqlInt64()
+ {
+ SqlInt16 Test64 = new SqlInt16 (64);
+ AssertEquals ("#AC01", (long)64, ((SqlInt64)Test64).Value);
+ }
+
+ public void TestSqlMoneyToSqlInt64()
+ {
+ SqlMoney TestMoney64 = new SqlMoney(64);
+ AssertEquals ("#AD01", (long)64, ((SqlInt64)TestMoney64).Value);
+ }
+
+ public void TestSqlSingleToSqlInt64()
+ {
+ SqlSingle TestSingle64 = new SqlSingle (64);
+ AssertEquals ("#AE01", (long)64, ((SqlInt64)TestSingle64).Value);
+ }
+
+ public void TestSqlStringToSqlInt64()
+ {
+ SqlString TestString = new SqlString ("Test string");
+ SqlString TestString100 = new SqlString ("100");
+ SqlString TestString1000 = new SqlString ("1000000000000000000000");
+
+ AssertEquals ("#AF01", (long)100, ((SqlInt64)TestString100).Value);
+
+ try {
+ SqlInt64 test = (SqlInt64)TestString1000;
+ Fail ("#AF02");
+ } catch(Exception e) {
+ AssertEquals ("#AF03", typeof (OverflowException), e.GetType ());
+ }
+
+ try {
+ SqlInt64 test = (SqlInt64)TestString;
+ Fail ("#AF03");
+ } catch(Exception e) {
+ AssertEquals ("#AF04", typeof (FormatException), e.GetType ());
+ }
+ }
+
+ public void TestByteToSqlInt64()
+ {
+ short TestShort = 14;
+ AssertEquals ("#G01", (long)14, ((SqlInt64)TestShort).Value);
+ }
+ }
+}
+