* DataColumn.cs: Fixed ParamName of ArgumentNullException. Modified
authorGert Driesen <drieseng@users.sourceforge.net>
Sun, 21 Oct 2007 13:26:43 +0000 (13:26 -0000)
committerGert Driesen <drieseng@users.sourceforge.net>
Sun, 21 Oct 2007 13:26:43 +0000 (13:26 -0000)
exception message for invalid DateTimeMode value to match MS. Code
formatting.
* DbDataPermissionAttribute.cs: In KeyRestrictionBehavior, reuse
ExceptionHelper.CheckEnumValue.
* ExceptionHelper.cs: Use same exception message for both 1.0 and 2.0.
* Index.cs: Fixed compiler warnings. Code formatting.
* SqlCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
* OleDbCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
* DBDataPermissionAttributeTest.cs: Improved test for invalid
KeyRestrictionBehavior. Fixed line endings.
* DataColumnTest.cs: No longer derive from deprecated Assertion class.
Code formatting. Added test for DateTimeMode.

svn path=/trunk/mcs/; revision=87866

14 files changed:
mcs/class/System.Data/System.Data.Common/ChangeLog
mcs/class/System.Data/System.Data.Common/DbDataPermissionAttribute.cs
mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs
mcs/class/System.Data/System.Data.Common/Index.cs
mcs/class/System.Data/System.Data.OleDb/ChangeLog
mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs
mcs/class/System.Data/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs
mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataColumn.cs
mcs/class/System.Data/Test/System.Data.Common/ChangeLog
mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs
mcs/class/System.Data/Test/System.Data/ChangeLog
mcs/class/System.Data/Test/System.Data/DataColumnTest.cs

index 92ecb09aa753ed8cd3bdcd4caaf555b24418cb4e..a8c0b25f94b104a585a994a34c696d6b42216dc0 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * DbDataPermissionAttribute.cs: In KeyRestrictionBehavior, reuse
+       ExceptionHelper.CheckEnumValue.
+       * ExceptionHelper.cs: Use same exception message for both 1.0 and 2.0.
+       * Index.cs: Fixed compiler warnings. Code formatting.
+
 2007-10-20  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * DbDataAdapter.cs: Implemented UpdateBatchSize setter.
index b82bfffd52d6765c5bcc1535b6b6574e4e1b5828..bfb97364f16e95a8529a8a6785e4fc29bfc1572a 100644 (file)
@@ -90,14 +90,7 @@ namespace System.Data.Common {
                public KeyRestrictionBehavior KeyRestrictionBehavior {
                        get { return keyRestrictionBehavior; }
                        set {
-                               if (!Enum.IsDefined (typeof (KeyRestrictionBehavior), value)) {
-                                       string msg = Locale.GetText ("Unknown value.");
-#if NET_2_0
-                                       throw new ArgumentOutOfRangeException ("KeyRestrictionBehavior", value, msg);
-#else
-                                       throw new ArgumentException ("KeyRestrictionBehavior", msg);
-#endif
-                               }
+                               ExceptionHelper.CheckEnumValue (typeof (KeyRestrictionBehavior), value);
                                keyRestrictionBehavior = value;
                        }
                }
index 209431285b0a0e4edc4287b1d564d55f1610c822..21452af156f11e4c00cc99bf82a9e05d3d0c12c1 100644 (file)
@@ -26,13 +26,13 @@ namespace System.Data.Common
 \r
                internal static ArgumentException InvalidEnumValueException (String enumeration, object value)\r
                {\r
+                       string msg = string.Format (CultureInfo.InvariantCulture,\r
+                               "The {0} enumeration value, {1}, is invalid.",\r
+                               enumeration, value);\r
 #if NET_2_0\r
-                       return new ArgumentOutOfRangeException (enumeration,\r
-                               string.Format (CultureInfo.InvariantCulture,\r
-                                       "The {0} enumeration value, {1}, is " +\r
-                                       "invalid", enumeration, value));\r
+                       return new ArgumentOutOfRangeException (enumeration, msg);\r
 #else\r
-                       return new ArgumentException (String.Format ("The {0} enumeration value, {1}, is invalid", enumeration, value));\r
+                       return new ArgumentException (msg);\r
 #endif\r
                }\r
 \r
index 947a140dafb761a9083efdf9b388de11d96ff6b2..62956d41bd06368cd0dc2c84b5dba437005f7c31 100644 (file)
@@ -35,7 +35,13 @@ using System.Text;
 \r
 namespace System.Data.Common\r
 {\r
-       enum IndexDuplicatesState { Unknown, True, False }; \r
+       enum IndexDuplicatesState\r
+       {\r
+               Unknown,\r
+               True,\r
+               False\r
+       }\r
+\r
        /// <summary>\r
        /// Summary description for Index.\r
        /// </summary>\r
@@ -43,17 +49,17 @@ namespace System.Data.Common
        {\r
                #region Fields\r
 \r
-               int[] _array;\r
+               int [] _array;\r
                int _size;\r
                Key _key;\r
-               int _refCount = 0;\r
+               int _refCount;\r
                IndexDuplicatesState _hasDuplicates;\r
 \r
                #endregion // Fields\r
 \r
                #region Constructors\r
 \r
-               internal Index(Key key)\r
+               internal Index (Key key)\r
                {\r
                        _key = key;\r
                        Reset();\r
@@ -63,50 +69,42 @@ namespace System.Data.Common
 \r
                #region Properties\r
 \r
-               internal Key Key \r
-               {\r
-                       get {\r
-                               return _key;\r
-                       }\r
+               internal Key Key {\r
+                       get { return _key; }\r
                }\r
 \r
-               internal int Size\r
-               {\r
+               internal int Size {\r
                        get {\r
                                EnsureArray();\r
                                return _size;\r
                        }\r
                }\r
 \r
-               internal int RefCount\r
-               {\r
-                       get {\r
-                               return _refCount;\r
-                       }\r
+               internal int RefCount {\r
+                       get { return _refCount; }\r
                }\r
 \r
-               internal int IndexToRecord(int index){\r
+               internal int IndexToRecord (int index)\r
+               {\r
                        return index < 0 ? index : Array[index];\r
                }\r
 \r
-               private int[] Array\r
-               {\r
+               private int [] Array {\r
                        get {\r
-                               EnsureArray();\r
+                               EnsureArray ();\r
                                return _array;\r
                        }\r
                }\r
 \r
-               internal bool HasDuplicates\r
-               {\r
+               internal bool HasDuplicates {\r
                        get {\r
                                if (_array == null || _hasDuplicates == IndexDuplicatesState.Unknown) {\r
-                                       EnsureArray();\r
+                                       EnsureArray ();\r
                                        if (_hasDuplicates == IndexDuplicatesState.Unknown) {\r
                                                // check for duplicates\r
                                                _hasDuplicates = IndexDuplicatesState.False;\r
-                                               for(int i = 0; i < Size - 1; i++) {\r
-                                                       if (Key.CompareRecords(Array[i],Array[i+1]) == 0) {\r
+                                               for (int i = 0; i < Size - 1; i++) {\r
+                                                       if (Key.CompareRecords (Array [i], Array [i + 1]) == 0) {\r
                                                                _hasDuplicates = IndexDuplicatesState.True;\r
                                                                break;\r
                                                        }\r
@@ -121,7 +119,7 @@ namespace System.Data.Common
 \r
                #region Methods\r
 \r
-               internal int[] Duplicates {\r
+               internal int [] Duplicates {\r
                        get {\r
                                if (!HasDuplicates)\r
                                        return null;\r
@@ -129,122 +127,111 @@ namespace System.Data.Common
                                ArrayList dups = new ArrayList();\r
 \r
                                bool inRange = false;\r
-                               for(int i = 0; i < Size - 1; i++) {\r
-                                       if (Key.CompareRecords(Array[i],Array[i+1]) == 0){\r
+                               for (int i = 0; i < Size - 1; i++) {\r
+                                       if (Key.CompareRecords (Array [i], Array [i + 1]) == 0) {\r
                                                if (!inRange) {\r
                                                        dups.Add(Array[i]);\r
                                                        inRange = true;\r
                                                }\r
 \r
-                                               dups.Add(Array[i+1]);\r
+                                               dups.Add (Array [i + 1]);\r
                                        }\r
                                        else\r
                                                inRange = false;\r
                                }\r
 \r
-                               return (int[])dups.ToArray(typeof(int));\r
+                               return (int []) dups.ToArray (typeof (int));\r
                        }\r
                }\r
 \r
-               private void EnsureArray()\r
+               private void EnsureArray ()\r
                {\r
-                       if (_array == null) {\r
-                               RebuildIndex();\r
-                       }\r
+                       if (_array == null)\r
+                               RebuildIndex ();\r
                }\r
 \r
-               internal int[] GetAll()\r
+               internal int [] GetAll ()\r
                {\r
                        return Array;\r
                }\r
 \r
-               internal DataRow[] GetAllRows ()\r
+               internal DataRow [] GetAllRows ()\r
                {\r
-                       DataRow[] list = new DataRow [Size];\r
-                       for (int i=0; i < Size; ++i)\r
+                       DataRow [] list = new DataRow [Size];\r
+                       for (int i = 0; i < Size; ++i)\r
                                list [i] = Key.Table.RecordCache [Array [i]];\r
                        return list;\r
                }\r
 \r
-               internal DataRow[] GetDistinctRows () \r
+               internal DataRow [] GetDistinctRows () \r
                {\r
                        ArrayList list = new ArrayList ();\r
                        list.Add (Key.Table.RecordCache [Array [0]]);\r
                        int currRecord = Array [0];\r
-                       for (int i=1; i <  Size; ++i) {\r
+                       for (int i = 1; i <  Size; ++i) {\r
                                if (Key.CompareRecords (currRecord, Array [i]) == 0)\r
                                        continue;\r
                                list.Add (Key.Table.RecordCache [Array [i]]);\r
                                currRecord = Array [i];\r
                        }\r
-                       return (DataRow[])list.ToArray (typeof (DataRow));\r
+                       return (DataRow []) list.ToArray (typeof (DataRow));\r
                }\r
 \r
                internal void Reset()\r
                {\r
                        _array = null;\r
-                       RebuildIndex();\r
+                       RebuildIndex ();\r
                }\r
 \r
                private void RebuildIndex()\r
                {\r
                        // consider better capacity approximation\r
-                       _array = new int[Key.Table.RecordCache.CurrentCapacity];\r
+                       _array = new int [Key.Table.RecordCache.CurrentCapacity];\r
                        _size = 0;\r
-                       foreach(DataRow row in Key.Table.Rows) {\r
-                               int record = Key.GetRecord(row);\r
-                               if (record != -1) {\r
-                                       _array[_size++] = record;\r
-                               }\r
+                       foreach (DataRow row in Key.Table.Rows) {\r
+                               int record = Key.GetRecord (row);\r
+                               if (record != -1)\r
+                                       _array [_size++] = record;\r
                        }\r
                        _hasDuplicates = IndexDuplicatesState.False;\r
                        // Note : MergeSort may update hasDuplicates to True\r
-                       Sort();\r
+                       Sort ();\r
                }\r
 \r
-               private void Sort()\r
+               private void Sort ()\r
                {\r
                        //QuickSort(Array,0,Size-1);\r
-                       MergeSort(Array,Size);\r
+                       MergeSort (Array, Size);\r
                }\r
                \r
                /*\r
                 * Returns record number of the record equal to the key values supplied \r
                 * in the meaning of index key, or -1 if no equal record found.\r
                 */\r
-               internal int Find(object[] keys)\r
+               internal int Find (object [] keys)\r
                {\r
                        int index = FindIndex(keys);\r
-                       return IndexToRecord(index);\r
+                       return IndexToRecord (index);\r
                }\r
 \r
                /*\r
                 * Returns record index (location) of the record equal to the key values supplied \r
                 * in the meaning of index key, or -1 if no equal record found.\r
                 */\r
-               internal int FindIndex(object[] keys)\r
+               internal int FindIndex (object [] keys)\r
                {\r
-                       if (keys == null || keys.Length != Key.Columns.Length) {\r
+                       if (keys == null || keys.Length != Key.Columns.Length)\r
                                throw new ArgumentException("Expecting " + Key.Columns.Length + " value(s) for the key being indexed, " +\r
                                        "but received " + ((keys == null) ? 0 : keys.Length) + " value(s).");\r
-                       }\r
 \r
-                       int tmp = Key.Table.RecordCache.NewRecord();\r
+                       int tmp = Key.Table.RecordCache.NewRecord ();\r
                        try {\r
                                // init key values for temporal record\r
-                               for(int i = 0; i < Key.Columns.Length; i++) {\r
-                                       Key.Columns[i].DataContainer[tmp] = keys[i];\r
-                               }\r
-                               return FindIndex(tmp);\r
-                       }\r
-//                     catch(FormatException) {\r
-//                             return -1;\r
-//                     }\r
-//                     catch(InvalidCastException) {\r
-//                             return -1;\r
-//                     }\r
-                       finally {\r
-                               Key.Table.RecordCache.DisposeRecord(tmp);\r
+                               for (int i = 0; i < Key.Columns.Length; i++)\r
+                                       Key.Columns [i].DataContainer [tmp] = keys [i];\r
+                               return FindIndex (tmp);\r
+                       } finally {\r
+                               Key.Table.RecordCache.DisposeRecord (tmp);\r
                        }\r
                }\r
 \r
@@ -252,20 +239,20 @@ namespace System.Data.Common
                 * Returns record number of the record equal to the record supplied \r
                 * in the meaning of index key, or -1 if no equal record found.\r
                 */\r
-               internal int Find(int record)\r
+               internal int Find (int record)\r
                {\r
-                       int index = FindIndex(record);\r
-                       return IndexToRecord(index);\r
+                       int index = FindIndex (record);\r
+                       return IndexToRecord (index);\r
                }\r
 \r
                /*\r
                 * Returns array of record numbers of the records equal equal to the key values supplied \r
                 * in the meaning of index key, or -1 if no equal record found.\r
                 */\r
-               internal int[] FindAll(object[] keys)\r
+               internal int[] FindAll (object [] keys)\r
                {\r
-                       int[] indexes = FindAllIndexes(keys);\r
-                       IndexesToRecords(indexes);\r
+                       int [] indexes = FindAllIndexes (keys);\r
+                       IndexesToRecords (indexes);\r
                        return indexes;\r
                }\r
 \r
@@ -273,29 +260,24 @@ namespace System.Data.Common
                 * Returns array of indexes of the records inside the index equal equal to the key values supplied \r
                 * in the meaning of index key, or -1 if no equal record found.\r
                 */\r
-               internal int[] FindAllIndexes(object[] keys)\r
+               internal int [] FindAllIndexes (object [] keys)\r
                {\r
-                       if (keys == null || keys.Length != Key.Columns.Length) {\r
+                       if (keys == null || keys.Length != Key.Columns.Length)\r
                                throw new ArgumentException("Expecting " + Key.Columns.Length + " value(s) for the key being indexed," +\r
                                        "but received " + ((keys == null) ? 0 : keys.Length) + " value(s).");\r
-                       }\r
 \r
-                       int tmp = Key.Table.RecordCache.NewRecord();\r
+                       int tmp = Key.Table.RecordCache.NewRecord ();\r
                        try {\r
                                // init key values for temporal record\r
-                               for(int i = 0; i < Key.Columns.Length; i++) {\r
-                                       Key.Columns[i].DataContainer[tmp] = keys[i];\r
-                               }\r
-                               return FindAllIndexes(tmp);\r
-                       }\r
-                       catch(FormatException) {\r
-                               return new int[0];\r
-                       }\r
-                       catch(InvalidCastException) {\r
-                               return new int[0];\r
-                       }\r
-                       finally {\r
-                               Key.Table.RecordCache.DisposeRecord(tmp);\r
+                               for (int i = 0; i < Key.Columns.Length; i++)\r
+                                       Key.Columns [i].DataContainer [tmp] = keys [i];\r
+                               return FindAllIndexes (tmp);\r
+                       } catch(FormatException) {\r
+                               return new int [0];\r
+                       } catch(InvalidCastException) {\r
+                               return new int [0];\r
+                       } finally {\r
+                               Key.Table.RecordCache.DisposeRecord (tmp);\r
                        }\r
                }\r
 \r
@@ -303,10 +285,10 @@ namespace System.Data.Common
                 * Returns array of record numbers of the records equal to the record supplied \r
                 * in the meaning of index key, or empty list if no equal records found.\r
                 */\r
-               internal int[] FindAll(int record)\r
+               internal int [] FindAll (int record)\r
                {\r
-                       int[] indexes = FindAllIndexes(record);\r
-            IndexesToRecords(indexes);\r
+                       int [] indexes = FindAllIndexes (record);\r
+                       IndexesToRecords (indexes);\r
                        return indexes;\r
                }\r
 \r
@@ -314,27 +296,26 @@ namespace System.Data.Common
                 * Returns array of indexes of the records inside the index that equal to the record supplied \r
                 * in the meaning of index key, or empty list if no equal records found.\r
                 */\r
-               internal int[] FindAllIndexes(int record)\r
+               internal int [] FindAllIndexes (int record)\r
                {\r
                        int index = FindIndex(record);\r
-\r
-                       if (index == -1) {\r
+                       if (index == -1)\r
                                return new int[0];\r
-                       }\r
 \r
                        int startIndex = index++;\r
                        int endIndex = index;\r
-                       \r
-                       for(;startIndex >= 0 && Key.CompareRecords(Array[startIndex],record) == 0;startIndex--);\r
-                       for(;endIndex < Size && Key.CompareRecords(Array[endIndex],record) == 0;endIndex++);\r
+\r
+                       for (; startIndex >= 0 && Key.CompareRecords (Array [startIndex], record) == 0; startIndex--) {\r
+                       }\r
+                       for (; endIndex < Size && Key.CompareRecords (Array [endIndex], record) == 0; endIndex++) {\r
+                       }\r
                        \r
                        int length = endIndex - startIndex - 1;\r
-                       int[] indexes = new int[length];\r
-                       \r
-                       for(int i = 0; i < length; i++) {\r
-                               indexes[i] = ++startIndex;\r
-                       }\r
+                       int [] indexes = new int [length];\r
                        \r
+                       for (int i = 0; i < length; i++)\r
+                               indexes [i] = ++startIndex;\r
+               \r
                        return indexes;\r
                }\r
 \r
@@ -342,88 +323,78 @@ namespace System.Data.Common
                 * Returns index inside the array where record number of the record equal to the record supplied \r
                 * in the meaning of index key is sored, or -1 if no equal record found.\r
                 */\r
-               private int FindIndex(int record)\r
+               private int FindIndex (int record)\r
                {\r
-                       if (Size == 0) {\r
+                       if (Size == 0)\r
                                return -1;\r
-                       }\r
-                       return BinarySearch(Array,0,Size - 1,record);\r
+                       return BinarySearch (Array, 0, Size - 1, record);\r
                }\r
 \r
                /*\r
                 * Finds exact location of the record specified\r
                 */ \r
-               private int FindIndexExact(int record)\r
+               private int FindIndexExact (int record)\r
                {\r
                        for (int i = 0, size = Size; i < size; i++)\r
-                               if (Array[i] == record)\r
+                               if (Array [i] == record)\r
                                        return i;\r
-\r
                        return -1;\r
                }\r
 \r
                /*\r
                 * Returns array of records from the indexes (locations) inside the index\r
                 */\r
-               private void IndexesToRecords(int[] indexes)\r
+               private void IndexesToRecords (int [] indexes)\r
                {\r
-                       for(int i = 0; i < indexes.Length; i++) {\r
-                               indexes[i] = Array[indexes[i]];\r
-                       }\r
+                       for (int i = 0; i < indexes.Length; i++)\r
+                               indexes [i] = Array [indexes [i]];\r
                }\r
 \r
-               internal void Delete(DataRow row)\r
+               internal void Delete (DataRow row)\r
                {\r
-                       int oldRecord = Key.GetRecord(row);\r
-\r
-                       Delete(oldRecord);\r
+                       int oldRecord = Key.GetRecord (row);\r
+                       Delete (oldRecord);\r
                }\r
 \r
-               internal void Delete(int oldRecord)\r
+               internal void Delete (int oldRecord)\r
                {\r
                        if (oldRecord == -1)\r
                                return;\r
 \r
-                       int index = FindIndexExact(oldRecord);\r
+                       int index = FindIndexExact (oldRecord);\r
                        if (index != -1) {\r
-                               if ((_hasDuplicates == IndexDuplicatesState.True)) {\r
+                               if (_hasDuplicates == IndexDuplicatesState.True) {\r
                                        int c1 = 1;\r
                                        int c2 = 1;\r
 \r
-                                       if (index > 0) {\r
-                                               c1 = Key.CompareRecords(Array[index - 1],oldRecord);\r
-                                       }\r
-                                       if (index < Size - 1) {\r
-                                               c2 = Key.CompareRecords(Array[index + 1],oldRecord);\r
-                                       }\r
+                                       if (index > 0)\r
+                                               c1 = Key.CompareRecords (Array [index - 1], oldRecord);\r
+                                       if (index < Size - 1)\r
+                                               c2 = Key.CompareRecords (Array [index + 1], oldRecord);\r
 \r
-                                       if (c1 == 0 ^ c2 == 0) {\r
+                                       if (c1 == 0 ^ c2 == 0)\r
                                                _hasDuplicates = IndexDuplicatesState.Unknown;\r
-                                       }\r
                                }\r
                                Remove(index);\r
                        }\r
                }\r
 \r
-               private void Remove(int index)\r
+               private void Remove (int index)\r
                {\r
-                       if (Size > 1) {\r
-                               System.Array.Copy(Array,index+1,Array,index,Size - index - 1);\r
-                       }\r
+                       if (Size > 1)\r
+                               System.Array.Copy (Array, index + 1, Array, index,Size - index - 1);\r
                        _size--;\r
                }\r
 \r
-\r
-               internal void Update(DataRow row,int oldRecord, DataRowVersion oldVersion, DataRowState oldState)\r
-               {                       \r
+               internal void Update (DataRow row, int oldRecord, DataRowVersion oldVersion, DataRowState oldState)\r
+               {\r
                        bool contains = Key.ContainsVersion (oldState, oldVersion);\r
-                       int newRecord = Key.GetRecord(row);     \r
+                       int newRecord = Key.GetRecord (row);\r
                        // the record did not appeared in the index before update\r
                        if (oldRecord == -1 || Size == 0 || !contains) {\r
-                               if (newRecord >= 0) {\r
-                                       if (FindIndexExact(newRecord) < 0)\r
-                                               Add(row,newRecord);\r
-                               }\r
+                               if (newRecord >= 0)\r
+                                       if (FindIndexExact (newRecord) < 0)\r
+                                               Add (row,newRecord);\r
                                return;\r
                        }\r
                        \r
@@ -433,95 +404,85 @@ namespace System.Data.Common
                                return;\r
                        }\r
 \r
-                       int oldIdx = FindIndexExact(oldRecord);\r
-\r
-                       if( oldIdx == -1 ) {\r
-                               Add(row,newRecord);\r
+                       int oldIdx = FindIndexExact (oldRecord);\r
+                       if (oldIdx == -1) {\r
+                               Add (row, newRecord);\r
                                return;\r
                        }\r
-                               \r
+\r
                        int newIdx = -1;\r
-                       int compare = Key.CompareRecords(Array[oldIdx],newRecord);\r
-                       int start,end;\r
+                       int compare = Key.CompareRecords (Array [oldIdx], newRecord);\r
+                       int start, end;\r
 \r
                        int c1 = 1;\r
                        int c2 = 1;\r
 \r
                        if (compare == 0) {\r
-                               if (Array[oldIdx] == newRecord) {\r
+                               if (Array [oldIdx] == newRecord) {\r
                                        // we deal with the same record that didn't change\r
                                        // in the context of current index.\r
                                        // so , do nothing.\r
                                        return;\r
                                }\r
-                       }\r
-                       else {\r
-                               if ((_hasDuplicates == IndexDuplicatesState.True)) {\r
-                                       if (oldIdx > 0) {\r
-                                               c1 = Key.CompareRecords(Array[oldIdx - 1],newRecord);\r
-                                       }\r
-                                       if (oldIdx < Size - 1) {\r
-                                               c2 = Key.CompareRecords(Array[oldIdx + 1],newRecord);\r
-                                       }\r
-\r
-                                       if ((c1 == 0 ^ c2 == 0) && compare != 0) {\r
+                       } else {\r
+                               if (_hasDuplicates == IndexDuplicatesState.True) {\r
+                                       if (oldIdx > 0)\r
+                                               c1 = Key.CompareRecords (Array [oldIdx - 1], newRecord);\r
+                                       if (oldIdx < Size - 1)\r
+                                               c2 = Key.CompareRecords (Array [oldIdx + 1], newRecord);\r
+\r
+                                       if ((c1 == 0 ^ c2 == 0) && compare != 0)\r
                                                _hasDuplicates = IndexDuplicatesState.Unknown;\r
-                                       }\r
                                }\r
                        }\r
                        \r
                        if ((oldIdx == 0 && compare > 0) || (oldIdx == (Size - 1) && compare < 0) || (compare == 0)) {\r
                                // no need to switch cells\r
                                newIdx = oldIdx;\r
-                       }\r
-                       else {\r
+                       } else {\r
                                if (compare < 0) {\r
                                        // search after the old place\r
                                        start = oldIdx + 1;\r
                                        end = Size - 1;\r
-                               }\r
-                               else {\r
+                               } else {\r
                                        // search before the old palce\r
                                        start = 0;\r
                                        end = oldIdx - 1;\r
                                }\r
 \r
-                               newIdx = LazyBinarySearch(Array,start,end,newRecord);                                   \r
+                               newIdx = LazyBinarySearch (Array, start, end, newRecord);\r
 \r
                                if (oldIdx < newIdx) {\r
-                                       System.Array.Copy(Array,oldIdx + 1,Array,oldIdx,newIdx - oldIdx);\r
+                                       System.Array.Copy (Array, oldIdx + 1, Array, oldIdx, newIdx - oldIdx);\r
                                        if (Key.CompareRecords (Array [newIdx], newRecord) > 0)\r
                                                --newIdx;\r
-                               }\r
-                               else if (oldIdx > newIdx){\r
-                                       System.Array.Copy(Array,newIdx,Array,newIdx + 1,oldIdx - newIdx);\r
+                               } else if (oldIdx > newIdx){\r
+                                       System.Array.Copy (Array, newIdx, Array, newIdx + 1, oldIdx - newIdx);\r
                                        if (Key.CompareRecords (Array [newIdx], newRecord) < 0)\r
                                                ++newIdx;\r
                                }\r
-                       }                       \r
+                       }\r
                        Array[newIdx] = newRecord;\r
 \r
                        if (compare != 0) {\r
                                if (!(_hasDuplicates == IndexDuplicatesState.True)) {\r
-                                       if (newIdx > 0) {\r
-                                               c1 = Key.CompareRecords(Array[newIdx - 1],newRecord);\r
-                                       }\r
-                                       if (newIdx < Size - 1) {\r
-                                               c2 = Key.CompareRecords(Array[newIdx + 1],newRecord);\r
-                                       }\r
+                                       if (newIdx > 0)\r
+                                               c1 = Key.CompareRecords (Array [newIdx - 1], newRecord);\r
+                                       if (newIdx < Size - 1)\r
+                                               c2 = Key.CompareRecords (Array [newIdx + 1], newRecord);\r
 \r
-                                       if (c1 == 0 || c2 == 0) {\r
+                                       if (c1 == 0 || c2 == 0)\r
                                                _hasDuplicates = IndexDuplicatesState.True;\r
-                                       }\r
                                }\r
                        }\r
                }\r
 \r
-               internal void Add(DataRow row) {\r
-                       Add(row, Key.GetRecord(row));\r
+               internal void Add (DataRow row)\r
+               {\r
+                       Add(row, Key.GetRecord (row));\r
                }\r
 \r
-               private void Add(DataRow row,int newRecord)\r
+               private void Add (DataRow row,int newRecord)\r
                {\r
                        int newIdx;\r
 \r
@@ -530,172 +491,151 @@ namespace System.Data.Common
 \r
                        if (Size == 0) {\r
                                newIdx = 0;\r
-                       }\r
-                       else {\r
-                               newIdx = LazyBinarySearch(Array,0,Size - 1,newRecord);\r
+                       } else {\r
+                               newIdx = LazyBinarySearch (Array, 0, Size - 1, newRecord);\r
                                // if newl value is greater - insert afer old value\r
                                // else - insert before old value\r
-                               if (Key.CompareRecords(Array[newIdx],newRecord) < 0) {\r
+                               if (Key.CompareRecords (Array [newIdx], newRecord) < 0)\r
                                        newIdx++;\r
-                               }\r
                        }\r
-                                       \r
-                       Insert(newIdx,newRecord);\r
+\r
+                       Insert (newIdx, newRecord);\r
 \r
                        int c1 = 1;\r
                        int c2 = 1;\r
                        if (!(_hasDuplicates == IndexDuplicatesState.True)) {\r
-                               if (newIdx > 0) {\r
-                                       c1 = Key.CompareRecords(Array[newIdx - 1],newRecord);\r
-                               }\r
-                               if (newIdx < Size - 1) {\r
-                                       c2 = Key.CompareRecords(Array[newIdx + 1],newRecord);\r
-                               }\r
+                               if (newIdx > 0)\r
+                                       c1 = Key.CompareRecords (Array [newIdx - 1], newRecord);\r
+                               if (newIdx < Size - 1)\r
+                                       c2 = Key.CompareRecords (Array [newIdx + 1], newRecord);\r
 \r
-                               if (c1 == 0 || c2 == 0) {\r
+                               if (c1 == 0 || c2 == 0)\r
                                        _hasDuplicates = IndexDuplicatesState.True;\r
-                               }\r
                        }\r
                }\r
 \r
-               private void Insert(int index,int r)\r
+               private void Insert (int index,int r)\r
                {\r
                        if (Array.Length == Size) {\r
-                               int[] tmp = (Size == 0) ? new int[16] : new int[Size << 1];\r
-                               System.Array.Copy(Array,0,tmp,0,index);\r
-                               tmp[index] = r;\r
-                               System.Array.Copy(Array,index,tmp,index + 1,Size - index);\r
+                               int [] tmp = (Size == 0) ? new int[16] : new int[Size << 1];\r
+                               System.Array.Copy (Array, 0, tmp, 0, index);\r
+                               tmp [index] = r;\r
+                               System.Array.Copy (Array, index, tmp, index + 1, Size - index);\r
                                _array = tmp;\r
-                       }\r
-                       else {\r
-                               System.Array.Copy(Array,index,Array,index + 1,Size - index);\r
-                               Array[index] = r;\r
+                       } else {\r
+                               System.Array.Copy (Array, index, Array, index + 1, Size - index);\r
+                               Array [index] = r;\r
                        }\r
                        _size++;\r
                }\r
 \r
-               private void MergeSort(int[] to, int length)\r
-        {\r
-            int[] from = new int[length];\r
-            System.Array.Copy(to, 0, from, 0, from.Length);\r
-\r
-            MergeSort(from, to, 0, from.Length);\r
-        }\r
-\r
-        private void MergeSort(int[] from, int[] to,int p, int r)\r
-        {\r
-            int q = (p + r) >> 1;\r
-               if (q == p) {\r
-                return;\r
-            }        \r
+               private void MergeSort (int [] to, int length)\r
+               {\r
+                       int [] from = new int [length];\r
+                       System.Array.Copy (to, 0, from, 0, from.Length);\r
+                       MergeSort (from, to, 0, from.Length);\r
+               }\r
 \r
-            MergeSort(to, from, p, q);\r
-            MergeSort(to, from, q, r);\r
+               private void MergeSort(int[] from, int[] to,int p, int r)\r
+               {\r
+                       int q = (p + r) >> 1;\r
+                       if (q == p)\r
+                               return;\r
 \r
-            // merge\r
-            for (int middle = q, current = p;;) {\r
-                               int res = Key.CompareRecords(from[p],from[q]);\r
-                if (res > 0) {\r
-                    to[current++] = from[q++];\r
+                       MergeSort (to, from, p, q);\r
+                       MergeSort (to, from, q, r);\r
 \r
-                    if (q == r) {\r
-                        while( p < middle) {\r
-                                to[current++] = from[p++];\r
-                                               }\r
-                        break;\r
-                    }\r
-                }\r
-                else {\r
+                       // merge\r
+                       for (int middle = q, current = p;;) {\r
+                               int res = Key.CompareRecords (from[p], from[q]);\r
+                               if (res > 0) {\r
+                                       to [current++] = from [q++];\r
 \r
-                                       if (res == 0) {\r
-                                               _hasDuplicates = IndexDuplicatesState.True;\r
+                                       if (q == r) {\r
+                                               while (p < middle)\r
+                                                       to[current++] = from[p++];\r
+                                               break;\r
                                        }\r
+                               } else {\r
+                                       if (res == 0)\r
+                                               _hasDuplicates = IndexDuplicatesState.True;\r
 \r
-                    to[current++] = from[p++];\r
+                                       to [current++] = from [p++];\r
 \r
-                    if (p == middle) {\r
-                        while( q < r) {\r
-                                to[current++] = from[q++];\r
-                                               }\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
+                                       if (p == middle) {\r
+                                               while (q < r)\r
+                                                       to[current++] = from[q++];\r
+                                               break;\r
+                                       }\r
+                               }\r
+                       }\r
                }\r
 \r
-               private void QuickSort(int[] a,int p,int r)\r
+               private void QuickSort (int [] a,int p,int r)\r
                {\r
                        if (p < r) {\r
-                               int q = Partition(a,p,r);\r
-                               QuickSort(a,p,q);\r
-                               QuickSort(a,q+1,r);\r
+                               int q = Partition (a, p, r);\r
+                               QuickSort (a, p, q);\r
+                               QuickSort (a, q + 1, r);\r
                        }\r
                }\r
 \r
-               private int Partition(int[] a,int p,int r)\r
+               private int Partition (int [] a,int p,int r)\r
                {\r
-                       int x = a[p];\r
+                       int x = a [p];\r
                        int i = p - 1;\r
                        int j = r + 1;\r
 \r
-                       while(true) {\r
+                       while (true) {\r
                                // decrement upper limit while values are greater then border value\r
                                do {\r
                                        j--;\r
-                               }\r
-                               while(Key.CompareRecords(a[j],x) > 0);  //while(a[j] > x);\r
+                               } while (Key.CompareRecords (a [j], x) > 0);\r
 \r
                                do {\r
                                        i++;\r
-                               }\r
-                               while(Key.CompareRecords(a[i],x) < 0);  //while(a[i] < x);\r
+                               } while (Key.CompareRecords (a [i], x) < 0);\r
                                \r
-                               if (i<j) {\r
-                                       int tmp = a[j];\r
-                                       a[j] = a[i];\r
-                                       a[i] = tmp;\r
-                               }\r
-                               else {\r
+                               if (i < j) {\r
+                                       int tmp = a [j];\r
+                                       a [j] = a [i];\r
+                                       a [i] = tmp;\r
+                               } else {\r
                                        return j;\r
                                }\r
                        }\r
                }\r
 \r
-               private int BinarySearch(int[] a, int p, int r,int b)\r
+               private int BinarySearch (int [] a, int p, int r,int b)\r
                {\r
-                       int i = LazyBinarySearch(a,p,r,b);\r
-\r
-                       return (Key.CompareRecords(a[i],b) == 0) ? i : -1;\r
+                       int i = LazyBinarySearch (a, p, r, b);\r
+                       return (Key.CompareRecords (a [i], b) == 0) ? i : -1;\r
                }\r
 \r
                // Lazy binary search only returns the cell number the search finished in,\r
                // but does not checks that the correct value was actually found\r
-               private int LazyBinarySearch(int[] a, int p, int r,int b)\r
+               private int LazyBinarySearch (int [] a, int p, int r, int b)\r
                {\r
-                       if ( p == r ) {\r
+                       if (p == r)\r
                                return p;\r
-                       }\r
 \r
-                       int q = (p+r) >> 1;\r
+                       int q = (p + r) >> 1;\r
 \r
-                       int compare = Key.CompareRecords(a[q],b);\r
-                       if (compare < 0) { // if (a[q] < b) {\r
-                               return LazyBinarySearch(a,q+1,r,b);\r
-                       }\r
-                       else if (compare > 0) { // a[q] > b\r
-                               return LazyBinarySearch(a,p,q,b);\r
-                       }       \r
-                       else { // a[q] == b\r
+                       int compare = Key.CompareRecords (a [q], b);\r
+                       if (compare < 0)\r
+                               return LazyBinarySearch (a, q + 1, r, b);\r
+                       else if (compare > 0)\r
+                               return LazyBinarySearch (a, p, q, b);\r
+                       else\r
                                return q;\r
-                       }\r
                }\r
 \r
-               internal void AddRef()\r
+               internal void AddRef ()\r
                {\r
                        _refCount++;\r
                }\r
 \r
-               internal void RemoveRef()\r
+               internal void RemoveRef ()\r
                {\r
                        _refCount--;\r
                }\r
@@ -703,17 +643,17 @@ namespace System.Data.Common
                /*\r
                // Prints indexes. For debugging.\r
                internal void Print ()\r
-                {\r
-                        for (int i=0; i < Size; i++) {\r
-                                Console.Write ("Index {0} record {1}: ", i, Array [i]);\r
-                                for (int j=0; j < Key.Table.Columns.Count; j++) {\r
-                                        DataColumn col = Key.Table.Columns [j];\r
-                                        if (Array [i] >= 0)\r
-                                                Console.Write ("{0,15} ", col [Array [i]]);\r
-                                }\r
-                                Console.WriteLine ();\r
-                        }\r
-                }\r
+               {\r
+                       for (int i=0; i < Size; i++) {\r
+                               Console.Write ("Index {0} record {1}: ", i, Array [i]);\r
+                               for (int j=0; j < Key.Table.Columns.Count; j++) {\r
+                                       DataColumn col = Key.Table.Columns [j];\r
+                                       if (Array [i] >= 0)\r
+                                               Console.Write ("{0,15} ", col [Array [i]]);\r
+                               }\r
+                               Console.WriteLine ();\r
+                       }\r
+               }\r
                */\r
                \r
                #endregion // Methods\r
index ec64c26662d115ee2971f41f11a51c4c55158de3..0d59a192a5705f3cf282622a58496831b50ab160 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * OleDbCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
+
 2007-10-20  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * OleDbDataAdapter.cs: In default ctor, set SelectCommand to null.
index 20ea41fa58d6fc791fb148b7e89a9dd725d8bd25..585c7d7ffb690380d53075824d60939629adb03e 100644 (file)
@@ -238,10 +238,8 @@ namespace System.Data.OleDb
 #endif
                UpdateRowSource UpdatedRowSource {
                        get { return updatedRowSource; }
-                       set
-                       {
-                               if (!Enum.IsDefined (typeof (UpdateRowSource), value))
-                                       throw ExceptionHelper.InvalidEnumValueException ("UpdateRowSource", value);
+                       set {
+                               ExceptionHelper.CheckEnumValue (typeof (UpdateRowSource), value);
                                updatedRowSource = value;
                        }
                }
index 4a290a5232fd7292b372a10a3a00ea47ade5554f..53cee2d4049a1ec4af8a9713fba297f5df08b0db 100644 (file)
@@ -1,3 +1,7 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * SqlCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
+
 2007-10-20  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * SqlCommand.cs: Added constant for default CommandTimeout, instead
index a5e07b15f7e3f9c5c0070abca4fb03a1625a1e9e..72ce26478f6d58d3ce8ba81ca6f0606e94835c5c 100644 (file)
@@ -197,8 +197,7 @@ namespace System.Data.SqlClient {
                                        throw new ArgumentException ("CommandType.TableDirect is not supported by the Mono SqlClient Data Provider.");
 #endif
 
-                               if (!Enum.IsDefined (typeof (CommandType), value))
-                                       throw ExceptionHelper.InvalidEnumValueException ("CommandType", value);
+                               ExceptionHelper.CheckEnumValue (typeof (CommandType), value);
                                commandType = value; 
                        }
                }
@@ -296,8 +295,7 @@ namespace System.Data.SqlClient {
                UpdateRowSource UpdatedRowSource {
                        get { return updatedRowSource; }
                        set {
-                               if (!Enum.IsDefined (typeof (UpdateRowSource), value))
-                                       throw ExceptionHelper.InvalidEnumValueException ("UpdateRowSource", value);
+                               ExceptionHelper.CheckEnumValue (typeof (UpdateRowSource), value);
                                updatedRowSource = value;
                        }
                }
index 2f1d4ced9fa947a6dd311ac17471b6597444a9e5..90811d37901ed8d66cdaccaa65e00ee0afc825e5 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * DataColumn.cs: Fixed ParamName of ArgumentNullException. Modified
+       exception message for invalid DateTimeMode value to match MS. Code
+       formatting.
+
 2007-10-19  Nagappan <anagappan@novell.com> 
 
        * DataRelation.cs: Removed bogus TODO.
index 1a6946f17ae2b120e08a7aa2f622a3f311b88b6d..fa334f236750c5561c5351c7a382ac8615e9fbe8 100644 (file)
@@ -122,9 +122,8 @@ namespace System.Data {
                {\r
                        ColumnName = (columnName == null ? String.Empty : columnName);\r
                        \r
-                       if(dataType == null) {\r
-                               throw new ArgumentNullException("dataType can't be null.");\r
-                       }\r
+                       if (dataType == null)\r
+                               throw new ArgumentNullException("dataType");\r
                        \r
                        DataType = dataType;\r
                        Expression = expr == null ? String.Empty : expr;\r
@@ -167,9 +166,11 @@ namespace System.Data {
                                        throw new InvalidOperationException ("The DateTimeMode can be set only on DataColumns of type DateTime.");\r
                                \r
                                if (!Enum.IsDefined (typeof (DataSetDateTime), value))\r
-                                       throw new InvalidEnumArgumentException ("The DataSetDateTime enumeration value, " + \r
-                                                       (int)value + ", is invalid.");\r
-                                               \r
+                                       throw new InvalidEnumArgumentException (\r
+                                               string.Format (CultureInfo.InvariantCulture,\r
+                                               "The {0} enumeration value, {1}, is invalid",\r
+                                               typeof (DataSetDateTime).Name, value));\r
+\r
                                if (_datetimeMode == value)\r
                                        return;\r
                                if (_table == null || _table.Rows.Count == 0) {\r
@@ -235,7 +236,7 @@ namespace System.Data {
                                _allowDBNull = value;\r
                        }\r
                }\r
-        \r
+\r
                /// <summary>\r
                /// Gets or sets a value indicating whether the column automatically increments the value of the column for new rows added to the table.\r
                /// </summary>\r
@@ -733,7 +734,7 @@ namespace System.Data {
 #endif\r
                [DefaultValue (false)]\r
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
-                public bool Unique \r
+               public bool Unique \r
                {\r
                        get {\r
                                return _unique;\r
@@ -805,7 +806,7 @@ namespace System.Data {
                        copy._columnName = _columnName;\r
                        //Copy.Container\r
                        copy.DataType = DataType;\r
-                       copy._defaultValue = _defaultValue;                     \r
+                       copy._defaultValue = _defaultValue;\r
                        copy._expression = _expression;\r
                        //Copy.ExtendedProperties\r
                        copy._maxLength = _maxLength;\r
@@ -904,29 +905,24 @@ namespace System.Data {
                // Returns true if all the same collumns are in columnSet and compareSet\r
                internal static bool AreColumnSetsTheSame(DataColumn[] columnSet, DataColumn[] compareSet)\r
                {\r
-                       if (null == columnSet && null == compareSet) {\r
+                       if (null == columnSet && null == compareSet)\r
                                return true;\r
-                       }\r
 \r
-                       if (null == columnSet || null == compareSet) {\r
+                       if (null == columnSet || null == compareSet)\r
                                return false;\r
-                       }\r
 \r
-                       if (columnSet.Length != compareSet.Length) { \r
+                       if (columnSet.Length != compareSet.Length)\r
                                return false;\r
-                       }\r
                        \r
                        foreach (DataColumn col in columnSet) {\r
                                bool matchFound = false;\r
                                foreach (DataColumn compare in compareSet) {\r
-                                       if (col == compare) {\r
-                                               matchFound = true;                                      \r
-                                       }\r
+                                       if (col == compare)\r
+                                               matchFound = true;\r
                                }\r
-                               if (! matchFound) {\r
+                               if (!matchFound)\r
                                        return false;\r
-                               }\r
-                       }                       \r
+                       }\r
                        return true;\r
                }\r
 \r
index ac2f4e5b87b480c9b75e8f4f493c0e452eac610a..bee9f7424c5738f7d4f94ba8b87159580bd4a01b 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * DBDataPermissionAttributeTest.cs: Improved test for invalid
+       KeyRestrictionBehavior. Fixed line endings.
+
 2007-10-20  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * DbDataAdapterTest.cs: Added test for UpdateBatchSize.
index 2fabc3f906d0669647960ddaed7334eb5cfda50e..7446bb4e6266118449c686645e0d3006e682be27 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
-using NUnit.Framework;\r
 using System;\r
 using System.Data;\r
 using System.Data.Common;\r
 using System.Security;\r
 using System.Security.Permissions;\r
 \r
-namespace MonoTests.System.Data.Common {\r
-\r
-       public class NonAbstractDBDataPermissionAttribute : DBDataPermissionAttribute {\r
+using NUnit.Framework;\r
 \r
+namespace MonoTests.System.Data.Common\r
+{\r
+       public class NonAbstractDBDataPermissionAttribute : DBDataPermissionAttribute\r
+       {\r
                public NonAbstractDBDataPermissionAttribute (SecurityAction action)\r
                        : base (action)\r
                {\r
                }\r
 \r
-               public override IPermission CreatePermission()
-               {
-                       return null;
-               }
+               public override IPermission CreatePermission()\r
+               {\r
+                       return null;\r
+               }\r
        }\r
 \r
        [TestFixture]\r
-       public class DBDataPermissionAttributeTest {\r
-\r
+       public class DBDataPermissionAttributeTest\r
+       {\r
                [Test]\r
                public void Default ()\r
                {\r
                        DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute (SecurityAction.Assert);\r
-#if !TARGET_JVM                        \r
+#if !TARGET_JVM\r
                        Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");\r
 #endif                 \r
                        Assert.IsFalse (a.Unrestricted, "Unrestricted");\r
@@ -96,7 +97,7 @@ namespace MonoTests.System.Data.Common {
                [Test]\r
                public void Action_Invalid ()\r
                {\r
-                       DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute ((SecurityAction)Int32.MinValue);\r
+                       new NonAbstractDBDataPermissionAttribute ((SecurityAction)Int32.MinValue);\r
                        // no validation in attribute\r
                }\r
 \r
@@ -134,15 +135,34 @@ namespace MonoTests.System.Data.Common {
                }\r
 \r
                [Test]\r
-#if NET_2_0\r
-               [ExpectedException (typeof (ArgumentOutOfRangeException))]\r
-#else\r
-               [ExpectedException (typeof (ArgumentException))]\r
-#endif\r
                public void KeyRestrictionBehavior_Invalid ()\r
                {\r
                        DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute (SecurityAction.Assert);\r
-                       a.KeyRestrictionBehavior = (KeyRestrictionBehavior)Int32.MinValue;\r
+                       try {\r
+                               a.KeyRestrictionBehavior = (KeyRestrictionBehavior) 666;\r
+                               Assert.Fail ("#1");\r
+#if NET_2_0\r
+                       } catch (ArgumentOutOfRangeException ex) {\r
+                               // The KeyRestrictionBehavior enumeration value, 666, is invalid\r
+                               Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               Assert.IsTrue (ex.Message.IndexOf ("KeyRestrictionBehavior") != -1, "#5");\r
+                               Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");\r
+                               Assert.IsNotNull (ex.ParamName, "#7");\r
+                               Assert.AreEqual ("KeyRestrictionBehavior", ex.ParamName, "#8");\r
+                       }\r
+#else\r
+                       } catch (ArgumentException ex) {\r
+                               // The KeyRestrictionBehavior enumeration value, 666, is invalid\r
+                               Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");\r
+                               Assert.IsNull (ex.InnerException, "#3");\r
+                               Assert.IsNotNull (ex.Message, "#4");\r
+                               //Assert.IsTrue (ex.Message.IndexOf ("KeyRestrictionBehavior") != -1, "#5");\r
+                               //Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");\r
+                               //Assert.IsNull (ex.ParamName, "#7");\r
+                       }\r
+#endif\r
                }\r
 \r
                [Test]\r
@@ -165,7 +185,7 @@ namespace MonoTests.System.Data.Common {
 \r
                        object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);\r
                        Assert.AreEqual (1, attrs.Length, "AttributeUsage");\r
-                       AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];\r
+                       AttributeUsageAttribute aua = (AttributeUsageAttribute) attrs [0];\r
                        Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");\r
                        Assert.IsFalse (aua.Inherited, "Inherited");\r
                        AttributeTargets at = AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method;\r
index c878d4c69c95f6765c1848ab4a6015563ee7bdd3..77f4ea960675097e6ce93d4a6c9f615295fef44a 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-21  Gert Driesen  <drieseng@users.sourceforge.net>
+
+       * DataColumnTest.cs: No longer derive from deprecated Assertion class.
+       Code formatting. Added test for DateTimeMode.
+
 2007-08-06  Nagappan A  <anagappan@novell.com>
 
        * DataTableTest.cs (Bug55978): In some cases this test case was
index e00cd9783444b127be4103189f5bdfaa44f25b25..60310ff287eea643a7a802e3b6341f7d7b1e2fdf 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using NUnit.Framework;
 using System;
+using System.ComponentModel;
 using System.Data;
 
+using NUnit.Framework;
+
 namespace MonoTests.System.Data 
 {
        [TestFixture]
-       public class DataColumnTest : Assertion
+       public class DataColumnTest
        {
                private DataTable _tbl;
 
@@ -53,30 +55,31 @@ namespace MonoTests.System.Data
                }
 
                [Test]
-               public void Ctor()      
+               public void Ctor()
                {
                        string colName = "ColName";
-                       DataColumn col = new DataColumn();
+                       DataColumn col = new DataColumn ();
                        
                        //These should all ctor without an exception
-                       col = new DataColumn(colName);
-                       col = new DataColumn(colName,typeof(int));
-                       col = new DataColumn(colName,typeof(int),null);
-                       col = new DataColumn(colName,typeof(int),null,MappingType.Attribute);
-
-                       //DataType Null
-                       try
-                       {
-                               col = new DataColumn(colName, null);
-                               Fail("DC7: Failed to throw ArgumentNullException.");
-                       }
-                       catch (ArgumentNullException){}
-                       catch (AssertionException exc) {throw  exc;}
-                       catch (Exception exc)
-                       {
-                               Fail("DC8: DataColumnNull. Wrong exception type. Got:" + exc);
-                       }
+                       col = new DataColumn (colName);
+                       col = new DataColumn (colName, typeof(int));
+                       col = new DataColumn (colName, typeof(int), null);
+                       col = new DataColumn (colName, typeof(int), null, MappingType.Attribute);
+               }
 
+               [Test]
+               public void Constructor3_DataType_Null ()
+               {
+                       try {
+                               new DataColumn ("ColName", (Type) null);
+                               Assert.Fail ("#1");
+                       } catch (ArgumentNullException ex) {
+                               Assert.AreEqual (typeof (ArgumentNullException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsNotNull (ex.ParamName, "#5");
+                               Assert.AreEqual ("dataType", ex.ParamName, "#6");
+                       }
                }
 
                [Test]
@@ -88,12 +91,9 @@ namespace MonoTests.System.Data
                        _tbl.Rows.Add(_tbl.NewRow());
                        _tbl.Rows[0]["NullCheck"] = DBNull.Value;
                        try {
-                       col.AllowDBNull = false;
-                               Fail("DC8b: Failed to throw DataException.");
-                       }
-                       catch (DataException) {}
-                       catch (Exception exc) {
-                               Fail("DC8c: Wrong exception type. Got:" + exc);
+                               col.AllowDBNull = false;
+                               Assert.Fail ("DC8b: Failed to throw DataException.");
+                       } catch (DataException) {
                        }
                }
 
@@ -117,44 +117,35 @@ namespace MonoTests.System.Data
                        col.AllowDBNull = true;
                        col.AllowDBNull = false;
 
-                       AssertEquals (false, col.AllowDBNull);
+                       Assert.IsFalse (col.AllowDBNull);
                }
 
                [Test]
                public void AutoIncrement()
                {
-                       DataColumn col = new DataColumn("Auto",typeof(string));
+                       DataColumn col = new DataColumn("Auto",typeof (string));
                        col.AutoIncrement = true;
                        
                        //Check for Correct Default Values
-                       AssertEquals("DC9: Seed default", (long)0, col.AutoIncrementSeed);
-                       AssertEquals("DC10: Step default", (long)1, col.AutoIncrementStep);
+                       Assert.AreEqual (0L, col.AutoIncrementSeed, "#1");
+                       Assert.AreEqual (1L, col.AutoIncrementStep, "#2");
 
                        //Check for auto type convert
-                       Assert("DC11: AutoInc type convert failed." ,col.DataType == typeof (int));
+                       Assert.AreEqual (typeof (int), col.DataType, "#3");
                }
 
                [Test]
                public void AutoIncrementExceptions()
                {
                        DataColumn col = new DataColumn();
-
                        col.Expression = "SomeExpression";
 
                        //if computed column exception is thrown
-                       try 
-                       {
+                       try {
                                col.AutoIncrement = true;
-                               Fail("DC12: Failed to throw ArgumentException");
-                       }
-                       catch (ArgumentException){}
-                       catch (AssertionException exc) {throw  exc;}
-                       catch (Exception exc)
-                       {
-                               Fail("DC13: ExprAutoInc. Wrong exception type. Got:" + exc);
+                               Assert.Fail ("DC12: Failed to throw ArgumentException");
+                       } catch (ArgumentException) {
                        }
-
-
                }
 
                [Test]
@@ -162,17 +153,66 @@ namespace MonoTests.System.Data
                {
                        DataColumn col = new DataColumn("ColName");
                        //Caption not set at this point
-                       AssertEquals("DC14: Caption Should Equal Col Name", col.ColumnName, col.Caption);
+                       Assert.AreEqual (col.ColumnName, col.Caption, "#1");
 
                        //Set caption
                        col.Caption = "MyCaption";
-                       AssertEquals("DC15: Caption should equal caption.", "MyCaption", col.Caption);
+                       Assert.AreEqual ("MyCaption", col.Caption, "#2");
 
                        //Clear caption
                        col.Caption = null;
-                       AssertEquals("DC16: Caption Should Equal empty string after clear", String.Empty, col.Caption);
-                       
+                       Assert.AreEqual (string.Empty, col.Caption, "#3");
+               }
+
+#if NET_2_0
+               [Test]
+               public void DateTimeMode_Valid ()
+               {
+                       DataColumn col = new DataColumn ("birthdate", typeof (DateTime));
+                       col.DateTimeMode = DataSetDateTime.Local;
+                       Assert.AreEqual (DataSetDateTime.Local, col.DateTimeMode, "#1");
+                       col.DateTimeMode = DataSetDateTime.Unspecified;
+                       Assert.AreEqual (DataSetDateTime.Unspecified, col.DateTimeMode, "#2");
+                       col.DateTimeMode = DataSetDateTime.Utc;
+                       Assert.AreEqual (DataSetDateTime.Utc, col.DateTimeMode, "#3");
+               }
+
+               [Test]
+               public void DateTime_DataType_Invalid ()
+               {
+                       DataColumn col = new DataColumn ("birthdate", typeof (int));
+                       try {
+                               col.DateTimeMode = DataSetDateTime.Local;
+                               Assert.Fail ("#1");
+                       } catch (InvalidOperationException ex) {
+                               // The DateTimeMode can be set only on DataColumns
+                               // of type DateTime
+                               Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsTrue (ex.Message.IndexOf ("DateTimeMode") != -1, "#5");
+                               Assert.IsTrue (ex.Message.IndexOf ("DateTime") != -1, "#6");
+                       }
+               }
+
+               [Test]
+               public void DateTimeMode_Invalid ()
+               {
+                       DataColumn col = new DataColumn ("birthdate", typeof (DateTime));
+                       try {
+                               col.DateTimeMode = (DataSetDateTime) 666;
+                               Assert.Fail ("#1");
+                       } catch (InvalidEnumArgumentException ex) {
+                               // The DataSetDateTime enumeration value, 666, is invalid
+                               Assert.AreEqual (typeof (InvalidEnumArgumentException), ex.GetType (), "#2");
+                               Assert.IsNull (ex.InnerException, "#3");
+                               Assert.IsNotNull (ex.Message, "#4");
+                               Assert.IsTrue (ex.Message.IndexOf ("DataSetDateTime") != -1, "#5");
+                               Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");
+                               Assert.IsNull (ex.ParamName, "#7");
+                       }
                }
+#endif
 
                [Test]
                public void ForColumnNameException()
@@ -183,25 +223,18 @@ namespace MonoTests.System.Data
                        DataColumn col4 = new DataColumn();
                        
                        col.ColumnName = "abc";
-                       AssertEquals( "abc", col.ColumnName);
+                       Assert.AreEqual ("abc", col.ColumnName, "#1");
 
                        _tbl.Columns.Add(col);
                        
                        //Duplicate name exception
-                       try
-                       {
+                       try {
                                col2.ColumnName = "abc";
                                _tbl.Columns.Add(col2);
-                               AssertEquals( "abc", col2.ColumnName);
-                               Fail("DC17: Failed to throw duplicate name exception.");
+                               Assert.AreEqual ("abc", col2.ColumnName, "#2");
+                               Assert.Fail ("#3");
+                       } catch (DuplicateNameException) {
                        }
-                       catch (DuplicateNameException){}
-                       catch (AssertionException exc) {throw  exc;}
-                       catch (Exception exc)
-                       {
-                               Fail("DC18: Wrong exception type. " + exc.ToString());
-                       }
-
                        // Make sure case matters in duplicate checks
                        col3.ColumnName = "ABC";
                        _tbl.Columns.Add(col3);
@@ -215,138 +248,107 @@ namespace MonoTests.System.Data
                        
                        //Set default Value if Autoincrement is true
                        tbl.Columns[0].AutoIncrement = true;
-                       try
-                       {
+                       try {
                                tbl.Columns[0].DefaultValue = 2;
-                               Fail("DC19: Failed to throw ArgumentException.");
-                       }
-                       catch (ArgumentException){}
-                       catch (AssertionException exc) {throw  exc;}
-                       catch (Exception exc)
-                       {
-                               Fail("DC20: Wrong exception type. " + exc.ToString());
+                               Assert.Fail ("DC19: Failed to throw ArgumentException.");
+                       } catch (ArgumentException) {
                        }
 
-
                        tbl.Columns[0].AutoIncrement = false;
 
                        //Set default value to an incompatible datatype
-                       try
-                       {
+                       try {
                                tbl.Columns[0].DefaultValue = "hello";
-                               Fail("DC21: Failed to throw FormatException.");
-                       }
-                       catch (FormatException){}
-                       catch (AssertionException exc) {throw  exc;}
-                       catch (Exception exc)
-                       {
-                               Fail("DC22: Wrong exception type. " + exc.ToString());
+                               Assert.Fail ("DC21: Failed to throw FormatException.");
+                       } catch (FormatException) {
                        }
 
                        //TODO: maybe add tests for setting default value for types that can implict
                        //cast
-
-
-
-
                }
 
                [Test]
-               public void SetDataType()
+               public void SetDataType ()
                {
                        //test for DataAlready exists and change the datatype
-                       
                        //supported datatype
-
                        //AutoInc column dataType supported
-
                }
 
                [Test]
-               public void Defaults1() 
+               public void Defaults1 ()
                {
                        //Check for defaults - ColumnName not set at the beginning
-                       DataTable table = new DataTable();              
+                       DataTable table = new DataTable();
                        DataColumn column = new DataColumn();
-                       
-                       AssertEquals("DC1: ColumnName default Before Add", column.ColumnName, String.Empty);
-                       AssertEquals("DC2: DataType default Before Add", column.DataType.ToString(), typeof(string).ToString());
+
+                       Assert.AreEqual (String.Empty, column.ColumnName, "#A1");
+                       Assert.AreEqual (typeof (string), column.DataType, "#A2");
                        
                        table.Columns.Add(column);
-                       
-                       AssertEquals("DC3: ColumnName default After Add", table.Columns[0].ColumnName, "Column1");
-                       AssertEquals("DC4: DataType default After Add", table.Columns[0].DataType.ToString(), typeof(string).ToString());       
+
+                       Assert.AreEqual ("Column1", table.Columns [0].ColumnName, "#B1");
+                       Assert.AreEqual (typeof (string), table.Columns [0].DataType, "#B2");
                        
                        DataRow row = table.NewRow();
                        table.Rows.Add(row);
                        DataRow dataRow = table.Rows[0];
                        
-                       object v = null;
-                       try {
-                               v = dataRow.ItemArray[0];
-                       }
-                       catch(Exception e) {
-                               Fail("DC5: getting item from dataRow.ItemArray[0] threw Exception: " + e);
-                       }
-                       
-                       Type vType = dataRow.ItemArray[0].GetType();
-                       AssertEquals("DC6: Value from DataRow.Item", v, DBNull.Value);
+                       object v = dataRow.ItemArray [0];
+                       Assert.AreEqual (typeof (DBNull), v.GetType (), "#C1");
+                       Assert.AreEqual (DBNull.Value, v, "#C2");
                }
 
                [Test]
-               public void Defaults2() 
+               public void Defaults2 ()
                {
                        //Check for defaults - ColumnName set at the beginning
                        string blah = "Blah";
                        //Check for defaults - ColumnName not set at the beginning
-                       DataTable table = new DataTable();              
+                       DataTable table = new DataTable();
                        DataColumn column = new DataColumn(blah);
-                       
-                       AssertEquals("DC23: ColumnName default Before Add", column.ColumnName,blah);
-                       AssertEquals("DC24: DataType default Before Add", column.DataType.ToString(), typeof(string).ToString());
+
+                       Assert.AreEqual (blah, column.ColumnName, "#A1");
+                       Assert.AreEqual (typeof (string), column.DataType, "#A2");
                        
                        table.Columns.Add(column);
                        
-                       AssertEquals("DC25: ColumnName default After Add", table.Columns[0].ColumnName, blah);
-                       AssertEquals("DC26: DataType default After Add", table.Columns[0].DataType.ToString(), typeof(string).ToString());      
+                       Assert.AreEqual (blah, table.Columns[0].ColumnName, "#B1");
+                       Assert.AreEqual (typeof (string), table.Columns[0].DataType, "#B2");
                        
                        DataRow row = table.NewRow();
                        table.Rows.Add(row);
                        DataRow dataRow = table.Rows[0];
 
-                       object v = null;
-                       try {
-                               v = dataRow.ItemArray[0];
-                       }
-                       catch(Exception e) {
-                               Fail("DC27: getting item from dataRow.ItemArray[0] threw Exception: " + e);
-                       }
-                       
-                       Type vType = dataRow.ItemArray[0].GetType();
-                       AssertEquals("DC28: Value from DataRow.Item", v, DBNull.Value);
+                       object v = dataRow.ItemArray[0];
+                       Assert.AreEqual (typeof (DBNull), v.GetType (), "#C1");
+                       Assert.AreEqual (DBNull.Value, v, "#C2");
                }
 
                [Test]
-               [ExpectedException (typeof (OverflowException))]
-               public void ExpressionSubstringlimits() {
-                       DataTable t = new DataTable();
-                       t.Columns.Add("aaa");
-                       t.Rows.Add(new object[]{"xxx"});
-                       DataColumn c = t.Columns.Add("bbb");
-                       c.Expression= "SUBSTRING(aaa, 6000000000000000, 2)";
+               public void ExpressionSubstringlimits () {
+                       DataTable t = new DataTable ();
+                       t.Columns.Add ("aaa");
+                       t.Rows.Add (new object [] {"xxx"});
+                       DataColumn c = t.Columns.Add ("bbb");
+                       try {
+                               c.Expression = "SUBSTRING(aaa, 6000000000000000, 2)";
+                               Assert.Fail ("#1");
+                       } catch (OverflowException) {
+                       }
                }
 
                [Test]
-                public void ExpressionFunctions ()
-                {
-                       DataTable T = new DataTable ("test");
+               public void ExpressionFunctions ()
+               {
+                       DataTable T = new DataTable ("test");
                        DataColumn C = new DataColumn ("name");
                        T.Columns.Add (C);
                        C = new DataColumn ("age");
                        C.DataType = typeof (int);
                        T.Columns.Add (C);
                        C = new DataColumn ("id");
-                       C.Expression = "substring (name, 1, 3) + len (name) + age";
+                       C.Expression = "substring (name, 1, 3) + len (name) + age";
                        T.Columns.Add (C);
                        
                        DataSet Set = new DataSet ("TestSet");
@@ -364,71 +366,67 @@ namespace MonoTests.System.Data
                        Row [0] = "h*an";
                        Row [1] = DBNull.Value;
                        T.Rows.Add (Row);
-                                               
-                       AssertEquals ("DC29", "hum710", T.Rows [10] [2]);
-                       AssertEquals ("DC30", "hum64", T.Rows [4] [2]);
-                       C = T.Columns [2];
-                       C.Expression = "isnull (age, 'succ[[]]ess')";
-                       AssertEquals ("DC31", "succ[[]]ess", T.Rows [100] [2]);
-                       
-                       C.Expression = "iif (age = 24, 'hurrey', 'boo')";
-                       AssertEquals ("DC32", "boo", T.Rows [50] [2]);
-                       AssertEquals ("DC33", "hurrey", T.Rows [24] [2]);
-                       
-                       C.Expression = "convert (age, 'System.Boolean')";
-                       AssertEquals ("DC32", Boolean.TrueString, T.Rows [50] [2]);
-                       AssertEquals ("DC32", Boolean.FalseString, T.Rows [0] [2]);
-                       
-                       //
-                       // Exceptions
-                       //
-                       
-                       try {
-                               C.Expression = "iff (age = 24, 'hurrey', 'boo')";
-                                                       
-                               // The expression contains undefined function call iff().
-                               Fail ("DC34");
+
+                       Assert.AreEqual ("hum710", T.Rows [10] [2], "#A1");
+                       Assert.AreEqual ("hum64", T.Rows [4] [2], "#A2");
+                       C = T.Columns [2];
+                       C.Expression = "isnull (age, 'succ[[]]ess')";
+                       Assert.AreEqual ("succ[[]]ess", T.Rows [100] [2], "#A3");
+
+                       C.Expression = "iif (age = 24, 'hurrey', 'boo')";
+                       Assert.AreEqual ("boo", T.Rows [50] [2], "#B1");
+                       Assert.AreEqual ("hurrey", T.Rows [24] [2], "#B2");
+
+                       C.Expression = "convert (age, 'System.Boolean')";
+                       Assert.AreEqual (Boolean.TrueString, T.Rows [50] [2], "#C1");
+                       Assert.AreEqual (Boolean.FalseString, T.Rows [0] [2], "#C2");
+
+                       //
+                       // Exceptions
+                       //
+
+                       try {
+                               // The expression contains undefined function call iff().
+                               C.Expression = "iff (age = 24, 'hurrey', 'boo')";
+                               Assert.Fail ("#D");
                        } catch (EvaluateException) {
                        } catch (SyntaxErrorException) {
                        }
                        
-                       
-                       //The following two cases fail on mono. MS.net evaluates the expression
-                       //immediatly upon assignment. We don't do this yet hence we don't throw
-                       //an exception at this point.
-                       try {
-                               C.Expression = "iif (nimi = 24, 'hurrey', 'boo')";
-                               Fail ("DC36");
-                       } catch (EvaluateException e) {                                         
-                               AssertEquals ("DC37", typeof (EvaluateException), e.GetType ());
-                               AssertEquals ("DC38", "Cannot find column [nimi].", e.Message);
-                       }
-                       
-                       try {
-                               C.Expression = "iif (name = 24, 'hurrey', 'boo')";
-                               Fail ("DC39");
-                       } catch (Exception e) {
-                               AssertEquals ("DC40", typeof (EvaluateException), e.GetType ());
-                               //AssertEquals ("DC41", "Cannot perform '=' operation on System.String and System.Int32.", e.Message);
-                       }
-                       
-
-                       try {
-                               C.Expression = "convert (age, Boolean)";        
-                               Fail ("DC42");
-                       } catch (Exception e) {
-                               AssertEquals ("DC43", typeof (EvaluateException), e.GetType ());
-                               AssertEquals ("DC44", "Invalid type name 'Boolean'.", e.Message);
-                       }
-                       
-                }
+                       //The following two cases fail on mono. MS.net evaluates the expression
+                       //immediatly upon assignment. We don't do this yet hence we don't throw
+                       //an exception at this point.
+                       try {
+                               C.Expression = "iif (nimi = 24, 'hurrey', 'boo')";
+                               Assert.Fail ("#E1");
+                       } catch (EvaluateException e) {
+                               Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#E2");
+                               Assert.AreEqual ("Cannot find column [nimi].", e.Message, "#E3");
+                       }
+
+                       try {
+                               C.Expression = "iif (name = 24, 'hurrey', 'boo')";
+                               Assert.Fail ("#F1");
+                       } catch (EvaluateException e) {
+                               Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#F2");
+                               //AssertEquals ("DC41", "Cannot perform '=' operation on System.String and System.Int32.", e.Message);
+                       }
+
+                       try {
+                               C.Expression = "convert (age, Boolean)";
+                               Assert.Fail ("#G1");
+                       } catch (EvaluateException e) {
+                               Assert.AreEqual (typeof (EvaluateException), e.GetType (), "#G2");
+                               Assert.AreEqual ("Invalid type name 'Boolean'.", e.Message, "#G3");
+                       }
+               }
 
                [Test]
-                public void ExpressionAggregates ()
-                {
-                       DataTable T = new DataTable ("test");
+               public void ExpressionAggregates ()
+               {
+                       DataTable T = new DataTable ("test");
                        DataTable T2 = new DataTable ("test2");
-                       
+
                        DataColumn C = new DataColumn ("name");
                        T.Columns.Add (C);
                        C = new DataColumn ("age");
@@ -436,7 +434,7 @@ namespace MonoTests.System.Data
                        T.Columns.Add (C);
                        C = new DataColumn ("childname");
                        T.Columns.Add (C);
-                       
+
                        C = new DataColumn ("expression");
                        T.Columns.Add (C);
 
@@ -459,11 +457,11 @@ namespace MonoTests.System.Data
                        T.Rows.Add (Row);
 
                        C = new DataColumn ("name");
-                       T2.Columns.Add (C);
+                       T2.Columns.Add (C);
                        C = new DataColumn ("age");
                        C.DataType = typeof (int);
                        T2.Columns.Add (C);
-                       
+
                        for (int i = 0; i < 100; i++) {
                                Row = T2.NewRow ();
                                Row [0] = "child" + i;
@@ -474,51 +472,51 @@ namespace MonoTests.System.Data
                                Row [1] = i - 2;
                                T2.Rows.Add (Row);
                        }
-                       
-                       DataRelation Rel = new DataRelation ("Rel", T.Columns [2], T2.Columns [0]);
-                       Set.Relations.Add (Rel);
-                       
-                       C = T.Columns [3];
-                       C.Expression = "Sum (Child.age)";
-                       AssertEquals ("DC45", "-2", T.Rows [0] [3]);
-                       AssertEquals ("DC46", "98", T.Rows [50] [3]);
-                       
+
+                       DataRelation Rel = new DataRelation ("Rel", T.Columns [2], T2.Columns [0]);
+                       Set.Relations.Add (Rel);
+
+                       C = T.Columns [3];
+                       C.Expression = "Sum (Child.age)";
+                       Assert.AreEqual ("-2", T.Rows [0] [3], "#A1");
+                       Assert.AreEqual ("98", T.Rows [50] [3], "#A2");
+
                        C.Expression = "Count (Child.age)";
-                       AssertEquals ("DC47", "2", T.Rows [0] [3]);
-                       AssertEquals ("DC48", "2", T.Rows [60] [3]);                                    
+                       Assert.AreEqual ("2", T.Rows [0] [3], "#B1");
+                       Assert.AreEqual ("2", T.Rows [60] [3], "#B2");
                
                        C.Expression = "Avg (Child.age)";
-                       AssertEquals ("DC49", "-1", T.Rows [0] [3]);
-                       AssertEquals ("DC50", "59", T.Rows [60] [3]);                                   
+                       Assert.AreEqual ("-1", T.Rows [0] [3], "#C1");
+                       Assert.AreEqual ("59", T.Rows [60] [3], "#C2");
 
                        C.Expression = "Min (Child.age)";
-                       AssertEquals ("DC51", "-2", T.Rows [0] [3]);
-                       AssertEquals ("DC52", "58", T.Rows [60] [3]);                                   
+                       Assert.AreEqual ("-2", T.Rows [0] [3], "#D1");
+                       Assert.AreEqual ("58", T.Rows [60] [3], "#D2");
 
                        C.Expression = "Max (Child.age)";
-                       AssertEquals ("DC53", "0", T.Rows [0] [3]);
-                       AssertEquals ("DC54", "60", T.Rows [60] [3]);                                   
+                       Assert.AreEqual ("0", T.Rows [0] [3], "#E1");
+                       Assert.AreEqual ("60", T.Rows [60] [3], "#E2");
 
                        C.Expression = "stdev (Child.age)";
-                       AssertEquals ("DC55", (1.4142135623731).ToString(), T.Rows [0] [3]);
-                       AssertEquals ("DC56", (1.4142135623731).ToString(), T.Rows [60] [3]);                                   
+                       Assert.AreEqual ((1.4142135623731).ToString (), T.Rows [0] [3], "#F1");
+                       Assert.AreEqual ((1.4142135623731).ToString (), T.Rows [60] [3], "#F2");
 
                        C.Expression = "var (Child.age)";
-                       AssertEquals ("DC57", "2", T.Rows [0] [3]);
-                       AssertEquals ("DC58", "2", T.Rows [60] [3]);                                    
-                }
+                       Assert.AreEqual ("2", T.Rows [0] [3], "#G1");
+                       Assert.AreEqual ("2", T.Rows [60] [3], "#G2");
+               }
 
                [Test]
                public void ExpressionOperator ()
                {
-                       DataTable T = new DataTable ("test");
+                       DataTable T = new DataTable ("test");
                        DataColumn C = new DataColumn ("name");
                        T.Columns.Add (C);
                        C = new DataColumn ("age");
                        C.DataType = typeof (int);
                        T.Columns.Add (C);
                        C = new DataColumn ("id");
-                       C.Expression = "substring (name, 1, 3) + len (name) + age";
+                       C.Expression = "substring (name, 1, 3) + len (name) + age";
                        T.Columns.Add (C);
                        
                        DataSet Set = new DataSet ("TestSet");
@@ -537,57 +535,56 @@ namespace MonoTests.System.Data
                        Row [1] = DBNull.Value;
                        T.Rows.Add (Row);
                        
-                       C = T.Columns [2];
-                       C.Expression = "age + 4";
-                       AssertEquals ("DC59", "68", T.Rows [64] [2]);
+                       C = T.Columns [2];
+                       C.Expression = "age + 4";
+                       Assert.AreEqual ("68", T.Rows [64] [2], "#A");
                        
                        C.Expression = "age - 4";
-                       AssertEquals ("DC60", "60", T.Rows [64] [2]);
+                       Assert.AreEqual ("60", T.Rows [64] [2], "#B");
                        
                        C.Expression = "age * 4";
-                       AssertEquals ("DC61", "256", T.Rows [64] [2]);
+                       Assert.AreEqual ("256", T.Rows [64] [2], "#C");
                        
                        C.Expression = "age / 4";
-                       AssertEquals ("DC62", "16", T.Rows [64] [2]);
+                       Assert.AreEqual ("16", T.Rows [64] [2], "#D");
                        
                        C.Expression = "age % 5";
-                       AssertEquals ("DC63", "4", T.Rows [64] [2]);
+                       Assert.AreEqual ("4", T.Rows [64] [2], "#E");
                        
                        C.Expression = "age in (5, 10, 15, 20, 25)";
-                       AssertEquals ("DC64", "False", T.Rows [64] [2]);
-                       AssertEquals ("DC65", "True", T.Rows [25] [2]);
+                       Assert.AreEqual ("False", T.Rows [64] [2], "#F1");
+                       Assert.AreEqual ("True", T.Rows [25] [2], "#F2");
                        
                        C.Expression = "name like 'human1%'";
-                       AssertEquals ("DC66", "True", T.Rows [1] [2]);
-                       AssertEquals ("DC67", "False", T.Rows [25] [2]);
+                       Assert.AreEqual ("True", T.Rows [1] [2], "#G1");
+                       Assert.AreEqual ("False", T.Rows [25] [2], "#G2");
 
-                       C.Expression = "age < 4";
-                       AssertEquals ("DC68", "False", T.Rows [4] [2]);
-                       AssertEquals ("DC69", "True", T.Rows [3] [2]);
+                       C.Expression = "age < 4";
+                       Assert.AreEqual ("False", T.Rows [4] [2], "#H1");
+                       Assert.AreEqual ("True", T.Rows [3] [2], "#H2");
 
-                       C.Expression = "age <= 4";
-                       AssertEquals ("DC70", "True", T.Rows [4] [2]);
-                       AssertEquals ("DC71", "False", T.Rows [5] [2]);
+                       C.Expression = "age <= 4";
+                       Assert.AreEqual ("True", T.Rows [4] [2], "#I1");
+                       Assert.AreEqual ("False", T.Rows [5] [2], "#I2");
 
-                       C.Expression = "age > 4";
-                       AssertEquals ("DC72", "False", T.Rows [4] [2]);
-                       AssertEquals ("DC73", "True", T.Rows [5] [2]);
+                       C.Expression = "age > 4";
+                       Assert.AreEqual ("False", T.Rows [4] [2], "#J1");
+                       Assert.AreEqual ("True", T.Rows [5] [2], "#J2");
 
-                       C.Expression = "age >= 4";
-                       AssertEquals ("DC74", "True", T.Rows [4] [2]);
-                       AssertEquals ("DC75", "False", T.Rows [1] [2]);
+                       C.Expression = "age >= 4";
+                       Assert.AreEqual ("True", T.Rows [4] [2], "#K1");
+                       Assert.AreEqual ("False", T.Rows [1] [2], "#K2");
 
-                       C.Expression = "age = 4";
-                       AssertEquals ("DC76", "True", T.Rows [4] [2]);
-                       AssertEquals ("DC77", "False", T.Rows [1] [2]);
+                       C.Expression = "age = 4";
+                       Assert.AreEqual ("True", T.Rows [4] [2], "#L1");
+                       Assert.AreEqual ("False", T.Rows [1] [2], "#L2");
 
-                       C.Expression = "age <> 4";
-                       AssertEquals ("DC76", "False", T.Rows [4] [2]);
-                       AssertEquals ("DC77", "True", T.Rows [1] [2]);
+                       C.Expression = "age <> 4";
+                       Assert.AreEqual ("False", T.Rows [4] [2], "#M1");
+                       Assert.AreEqual ("True", T.Rows [1] [2], "#M2");
                }
-                       
+
                [Test]
-               [ExpectedException (typeof (ArgumentException))]
                public void SetMaxLengthException ()
                {
                        // Setting MaxLength on SimpleContent -> exception
@@ -595,7 +592,11 @@ namespace MonoTests.System.Data
                        ds.Tables.Add("MyType");
                        ds.Tables["MyType"].Columns.Add(new DataColumn("Desc", 
                                typeof (string), "", MappingType.SimpleContent));
-                       ds.Tables["MyType"].Columns["Desc"].MaxLength = 32;
+                       try {
+                               ds.Tables ["MyType"].Columns ["Desc"].MaxLength = 32;
+                               Assert.Fail ("#1");
+                       } catch (ArgumentException) {
+                       }
                }
 
                [Test]
@@ -610,21 +611,19 @@ namespace MonoTests.System.Data
                }
 
                [Test]
-                public void AdditionToConstraintCollectionTest()
-                {
-                        DataTable myTable = new DataTable("myTable");
-                        DataColumn idCol = new DataColumn("id",Type.GetType("System.Int32"));                        //set the unique property and add them to the table
-                        idCol.Unique=true;
-                        myTable.Columns.Add(idCol);
-                        ConstraintCollection cc = myTable.Constraints;
-                        //cc just contains a single UniqueConstraint object.
-                        UniqueConstraint uc = cc[0] as UniqueConstraint;
-                        AssertEquals("#verifying whether the column associated with the UniqueConstraint is same:", uc.Columns[0].ColumnName , "id");
-                                                                                                    
-                }
-
-               // Testcase for #77025
-               [Test]
+               public void AdditionToConstraintCollectionTest()
+               {
+                       DataTable myTable = new DataTable("myTable");
+                       DataColumn idCol = new DataColumn("id", typeof (int));
+                       idCol.Unique = true;
+                       myTable.Columns.Add(idCol);
+                       ConstraintCollection cc = myTable.Constraints;
+                       //cc just contains a single UniqueConstraint object.
+                       UniqueConstraint uc = cc[0] as UniqueConstraint;
+                       Assert.AreEqual ("id", uc.Columns[0].ColumnName);
+               }
+
+               [Test] // bug #77025
                public void CalcStatisticalFunction_SingleElement()
                {
                        DataTable table = new DataTable ();
@@ -635,8 +634,8 @@ namespace MonoTests.System.Data
                        table.Columns.Add ("result_stdev", typeof (double), "stdev(test)");
 
                        // Check DBNull.Value is set as the result 
-                       AssertEquals ("#1" , typeof (DBNull), (table.Rows[0]["result_var"]).GetType ());
-                       AssertEquals ("#2" , typeof (DBNull), (table.Rows[0]["result_stdev"]).GetType ());
+                       Assert.AreEqual (typeof (DBNull), (table.Rows[0]["result_var"]).GetType (), "#1");
+                       Assert.AreEqual (typeof (DBNull), (table.Rows [0] ["result_stdev"]).GetType (), "#2");
                }
 
                [Test]
@@ -655,25 +654,25 @@ namespace MonoTests.System.Data
 
                        // Adding the rows after all the expression columns are added
                        table.Rows.Add (new object[] {0});
-                       AssertEquals ("#1", 1, table.Rows[0]["result_count"]);
-                       AssertEquals ("#2", 0, table.Rows[0]["result_sum"]);
-                       AssertEquals ("#3", 0, table.Rows[0]["result_avg"]);
-                       AssertEquals ("#4", 0, table.Rows[0]["result_max"]);
-                       AssertEquals ("#5", 0, table.Rows[0]["result_min"]);
-                       AssertEquals ("#6", DBNull.Value, table.Rows[0]["result_var"]);
-                       AssertEquals ("#7", DBNull.Value, table.Rows[0]["result_stdev"]);
+                       Assert.AreEqual (1, table.Rows [0] ["result_count"], "#A1");
+                       Assert.AreEqual (0, table.Rows [0] ["result_sum"], "#A2");
+                       Assert.AreEqual (0, table.Rows [0] ["result_avg"], "#A3");
+                       Assert.AreEqual (0, table.Rows [0] ["result_max"], "#A4");
+                       Assert.AreEqual (0, table.Rows [0] ["result_min"], "#A5");
+                       Assert.AreEqual (DBNull.Value, table.Rows [0] ["result_var"], "#A6");
+                       Assert.AreEqual (DBNull.Value, table.Rows [0] ["result_stdev"], "#A7");
 
                        table.Rows.Add (new object[] {1});
                        table.Rows.Add (new object[] {-2});
 
                        // Check if the aggregate columns are updated correctly
-                       AssertEquals ("#8", 3, table.Rows[0]["result_count"]);
-                       AssertEquals ("#9", -1, table.Rows[0]["result_sum"]);
-                       AssertEquals ("#10", 0, table.Rows[0]["result_avg"]);
-                       AssertEquals ("#11", 1, table.Rows[0]["result_max"]);
-                       AssertEquals ("#12", -2, table.Rows[0]["result_min"]);
-                       AssertEquals ("#13", (7.0/3), table.Rows[0]["result_var"]);
-                       AssertEquals ("#14", Math.Sqrt(7.0/3), table.Rows[0]["result_stdev"]);
+                       Assert.AreEqual (3, table.Rows [0] ["result_count"], "#B1");
+                       Assert.AreEqual (-1, table.Rows [0] ["result_sum"], "#B2");
+                       Assert.AreEqual (0, table.Rows [0] ["result_avg"], "#B3");
+                       Assert.AreEqual (1, table.Rows [0] ["result_max"], "#B4");
+                       Assert.AreEqual (-2, table.Rows [0] ["result_min"], "#B5");
+                       Assert.AreEqual ((7.0 / 3), table.Rows [0] ["result_var"], "#B6");
+                       Assert.AreEqual (Math.Sqrt (7.0 / 3), table.Rows [0] ["result_stdev"], "#B7");
                }
                
                [Test]
@@ -707,26 +706,26 @@ namespace MonoTests.System.Data
                                table2.Rows.Add (new object[] {1,j});
                
                        // Check the values for the expression columns in parent table 
-                       AssertEquals ("#1", 10, table.Rows[0]["result_count"]);
-                       AssertEquals ("#2", 0, table.Rows[1]["result_count"]);
+                       Assert.AreEqual (10, table.Rows [0] ["result_count"], "#A1");
+                       Assert.AreEqual (0, table.Rows [1] ["result_count"], "#A2");
 
-                       AssertEquals ("#3", 10, table.Rows[0]["result_sum"]);
-                       AssertEquals ("#4", DBNull.Value, table.Rows[1]["result_sum"]);
+                       Assert.AreEqual (10, table.Rows [0] ["result_sum"], "#B1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_sum"], "#B2");
 
-                       AssertEquals ("#5", 1, table.Rows[0]["result_avg"]);
-                       AssertEquals ("#6", DBNull.Value, table.Rows[1]["result_avg"]);
+                       Assert.AreEqual (1, table.Rows [0] ["result_avg"], "#C1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_avg"], "#C2");
 
-                       AssertEquals ("#7", 1, table.Rows[0]["result_max"]);
-                       AssertEquals ("#8", DBNull.Value, table.Rows[1]["result_max"]);
+                       Assert.AreEqual (1, table.Rows [0] ["result_max"], "#D1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_max"], "#D2");
 
-                       AssertEquals ("#7", 1, table.Rows[0]["result_min"]);
-                       AssertEquals ("#8", DBNull.Value, table.Rows[1]["result_min"]);
+                       Assert.AreEqual (1, table.Rows [0] ["result_min"], "#E1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_min"], "#E2");
 
-                       AssertEquals ("#9", 0, table.Rows[0]["result_var"]);
-                       AssertEquals ("#10", DBNull.Value, table.Rows[1]["result_var"]);
+                       Assert.AreEqual (0, table.Rows [0] ["result_var"], "#F1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_var"], "#F2");
 
-                       AssertEquals ("#11", 0, table.Rows[0]["result_stdev"]);
-                       AssertEquals ("#12", DBNull.Value, table.Rows[1]["result_stdev"]);
+                       Assert.AreEqual (0, table.Rows [0] ["result_stdev"], "#G1");
+                       Assert.AreEqual (DBNull.Value, table.Rows [1] ["result_stdev"], "#G2");
                }
 
                [Test]
@@ -754,49 +753,49 @@ namespace MonoTests.System.Data
                        error = "Aggregation Functions cannot be called on Columns Returning Single Row (Parent Column)";
                        try {
                                table2.Columns.Add ("result", typeof (int), "count(parent.test)");
-                               Fail ("#1" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#1" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        error = "Numerical or Functions cannot be called on Columns Returning Multiple Rows (Child Column)";
                        // Check arithematic operator
                        try {
                                table2.Columns.Add ("result", typeof (int), "10*(child.test)");
-                               Fail ("#2" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#2" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        // Check rel operator
                        try {
                                table2.Columns.Add ("result", typeof (int), "(child.test) > 10");
-                               Fail ("#3" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#3" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        // Check predicates 
                        try {
                                table2.Columns.Add ("result", typeof (int), "(child.test) IN (1,2,3)");
-                               Fail ("#4" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#4" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        try {
                                table2.Columns.Add ("result", typeof (int), "(child.test) LIKE 1");
-                               Fail ("#5" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#5" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        try {
                                table2.Columns.Add ("result", typeof (int), "(child.test) IS null");
-                               Fail ("#6" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#6" + error);
+                       } catch (SyntaxErrorException) {
                        }
 
                        // Check Calc Functions
                        try {
                                table2.Columns.Add ("result", typeof (int), "isnull(child.test,10)");
-                               Fail ("#7" + error);
-                       }catch (SyntaxErrorException) {
+                               Assert.Fail ("#7" + error);
+                       } catch (SyntaxErrorException) {
                        }
                }
 
@@ -810,8 +809,8 @@ namespace MonoTests.System.Data
                        table.Rows.Add (new object[] {});
 
                        // ms.net behavior.. seems to covert all numbers to double
-                       AssertEquals ("#1", 1, table.Rows[0][0]);
-                       AssertEquals ("#2", 1, table.Rows[0][1]);
+                       Assert.AreEqual (1, table.Rows [0] [0], "#1");
+                       Assert.AreEqual (1, table.Rows [0] [1], "#2");
                }
 
                [Test]
@@ -821,21 +820,21 @@ namespace MonoTests.System.Data
                        DataColumn col1 = new DataColumn ("col1", typeof (int));
                        DataColumn col2 = new DataColumn ("col2", typeof (int));
 
-                       AssertEquals ("#1" , -1, col1.Ordinal);
-                       AssertEquals ("#2" , null, col1.Table);
+                       Assert.AreEqual (-1, col1.Ordinal, "#A1");
+                       Assert.IsNull (col1.Table, "#A2");
 
                        table.Columns.Add (col1);
                        table.Columns.Add (col2);
-                       AssertEquals ("#3" , 0, col1.Ordinal);
-                       AssertEquals ("#4" , table, col1.Table);
+                       Assert.AreEqual (0, col1.Ordinal, "#B1");
+                       Assert.AreEqual (table, col1.Table, "#B2");
 
                        table.Columns.RemoveAt(0);
-                       AssertEquals ("#5" , -1, col1.Ordinal);
-                       AssertEquals ("#6" , null, col1.Table);
+                       Assert.AreEqual (-1, col1.Ordinal, "#C1");
+                       Assert.IsNull (col1.Table, "#C2");
 
                        table.Columns.Clear ();
-                       AssertEquals ("#7" , -1, col2.Ordinal);
-                       AssertEquals ("#8" , null, col2.Table);
+                       Assert.AreEqual (-1, col2.Ordinal, "#D1");
+                       Assert.IsNull (col2.Table, "#D2");
                }
        }
 }