Sfoglia il codice sorgente

* DataColumn.cs: Fixed ParamName of ArgumentNullException. Modified
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

Gert Driesen 18 anni fa
parent
commit
c231373769

+ 7 - 0
mcs/class/System.Data/System.Data.Common/ChangeLog

@@ -1,3 +1,10 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* DbDataAdapter.cs: Implemented UpdateBatchSize setter.

+ 1 - 8
mcs/class/System.Data/System.Data.Common/DbDataPermissionAttribute.cs

@@ -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;
 			}
 		}

+ 5 - 5
mcs/class/System.Data/System.Data.Common/ExceptionHelper.cs

@@ -26,13 +26,13 @@ namespace System.Data.Common
 
 		internal static ArgumentException InvalidEnumValueException (String enumeration, object value)
 		{
+			string msg = string.Format (CultureInfo.InvariantCulture,
+				"The {0} enumeration value, {1}, is invalid.",
+				enumeration, value);
 #if NET_2_0
-			return new ArgumentOutOfRangeException (enumeration,
-				string.Format (CultureInfo.InvariantCulture,
-					"The {0} enumeration value, {1}, is " +
-					"invalid", enumeration, value));
+			return new ArgumentOutOfRangeException (enumeration, msg);
 #else
-			return new ArgumentException (String.Format ("The {0} enumeration value, {1}, is invalid", enumeration, value));
+			return new ArgumentException (msg);
 #endif
 		}
 

+ 238 - 298
mcs/class/System.Data/System.Data.Common/Index.cs

@@ -35,7 +35,13 @@ using System.Text;
 
 namespace System.Data.Common
 {
-	enum IndexDuplicatesState { Unknown, True, False }; 
+	enum IndexDuplicatesState
+	{
+		Unknown,
+		True,
+		False
+	}
+
 	/// <summary>
 	/// Summary description for Index.
 	/// </summary>
@@ -43,17 +49,17 @@ namespace System.Data.Common
 	{
 		#region Fields
 
-		int[] _array;
+		int [] _array;
 		int _size;
 		Key _key;
-		int _refCount = 0;
+		int _refCount;
 		IndexDuplicatesState _hasDuplicates;
 
 		#endregion // Fields
 
 		#region Constructors
 
-		internal Index(Key key)
+		internal Index (Key key)
 		{
 			_key = key;
 			Reset();
@@ -63,50 +69,42 @@ namespace System.Data.Common
 
 		#region Properties
 
-		internal Key Key 
-		{
-			get {
-				return _key;
-			}
+		internal Key Key {
+			get { return _key; }
 		}
 
-		internal int Size
-		{
+		internal int Size {
 			get {
 				EnsureArray();
 				return _size;
 			}
 		}
 
-		internal int RefCount
-		{
-			get {
-				return _refCount;
-			}
+		internal int RefCount {
+			get { return _refCount; }
 		}
 
-		internal int IndexToRecord(int index){
+		internal int IndexToRecord (int index)
+		{
 			return index < 0 ? index : Array[index];
 		}
 
-		private int[] Array
-		{
+		private int [] Array {
 			get {
-				EnsureArray();
+				EnsureArray ();
 				return _array;
 			}
 		}
 
-		internal bool HasDuplicates
-		{
+		internal bool HasDuplicates {
 			get {
 				if (_array == null || _hasDuplicates == IndexDuplicatesState.Unknown) {
-					EnsureArray();
+					EnsureArray ();
 					if (_hasDuplicates == IndexDuplicatesState.Unknown) {
 						// check for duplicates
 						_hasDuplicates = IndexDuplicatesState.False;
-						for(int i = 0; i < Size - 1; i++) {
-							if (Key.CompareRecords(Array[i],Array[i+1]) == 0) {
+						for (int i = 0; i < Size - 1; i++) {
+							if (Key.CompareRecords (Array [i], Array [i + 1]) == 0) {
 								_hasDuplicates = IndexDuplicatesState.True;
 								break;
 							}
@@ -121,7 +119,7 @@ namespace System.Data.Common
 
 		#region Methods
 
-		internal int[] Duplicates {
+		internal int [] Duplicates {
 			get {
 				if (!HasDuplicates)
 					return null;
@@ -129,122 +127,111 @@ namespace System.Data.Common
 				ArrayList dups = new ArrayList();
 
 				bool inRange = false;
-				for(int i = 0; i < Size - 1; i++) {
-					if (Key.CompareRecords(Array[i],Array[i+1]) == 0){
+				for (int i = 0; i < Size - 1; i++) {
+					if (Key.CompareRecords (Array [i], Array [i + 1]) == 0) {
 						if (!inRange) {
 							dups.Add(Array[i]);
 							inRange = true;
 						}
 
-						dups.Add(Array[i+1]);
+						dups.Add (Array [i + 1]);
 					}
 					else
 						inRange = false;
 				}
 
-				return (int[])dups.ToArray(typeof(int));
+				return (int []) dups.ToArray (typeof (int));
 			}
 		}
 
-		private void EnsureArray()
+		private void EnsureArray ()
 		{
-			if (_array == null) {
-				RebuildIndex();
-			}
+			if (_array == null)
+				RebuildIndex ();
 		}
 
-		internal int[] GetAll()
+		internal int [] GetAll ()
 		{
 			return Array;
 		}
 
-		internal DataRow[] GetAllRows ()
+		internal DataRow [] GetAllRows ()
 		{
-			DataRow[] list = new DataRow [Size];
-			for (int i=0; i < Size; ++i)
+			DataRow [] list = new DataRow [Size];
+			for (int i = 0; i < Size; ++i)
 				list [i] = Key.Table.RecordCache [Array [i]];
 			return list;
 		}
 
-		internal DataRow[] GetDistinctRows () 
+		internal DataRow [] GetDistinctRows () 
 		{
 			ArrayList list = new ArrayList ();
 			list.Add (Key.Table.RecordCache [Array [0]]);
 			int currRecord = Array [0];
-			for (int i=1; i <  Size; ++i) {
+			for (int i = 1; i <  Size; ++i) {
 				if (Key.CompareRecords (currRecord, Array [i]) == 0)
 					continue;
 				list.Add (Key.Table.RecordCache [Array [i]]);
 				currRecord = Array [i];
 			}
-			return (DataRow[])list.ToArray (typeof (DataRow));
+			return (DataRow []) list.ToArray (typeof (DataRow));
 		}
 
 		internal void Reset()
 		{
 			_array = null;
-			RebuildIndex();
+			RebuildIndex ();
 		}
 
 		private void RebuildIndex()
 		{
 			// consider better capacity approximation
-			_array = new int[Key.Table.RecordCache.CurrentCapacity];
+			_array = new int [Key.Table.RecordCache.CurrentCapacity];
 			_size = 0;
-			foreach(DataRow row in Key.Table.Rows) {
-				int record = Key.GetRecord(row);
-				if (record != -1) {
-					_array[_size++] = record;
-				}
+			foreach (DataRow row in Key.Table.Rows) {
+				int record = Key.GetRecord (row);
+				if (record != -1)
+					_array [_size++] = record;
 			}
 			_hasDuplicates = IndexDuplicatesState.False;
 			// Note : MergeSort may update hasDuplicates to True
-			Sort();
+			Sort ();
 		}
 
-		private void Sort()
+		private void Sort ()
 		{
 			//QuickSort(Array,0,Size-1);
-			MergeSort(Array,Size);
+			MergeSort (Array, Size);
 		}
 		
 		/*
 		 * Returns record number of the record equal to the key values supplied 
 		 * in the meaning of index key, or -1 if no equal record found.
 		 */
-		internal int Find(object[] keys)
+		internal int Find (object [] keys)
 		{
 			int index = FindIndex(keys);
-			return IndexToRecord(index);
+			return IndexToRecord (index);
 		}
 
 		/*
 		 * Returns record index (location) of the record equal to the key values supplied 
 		 * in the meaning of index key, or -1 if no equal record found.
 		 */
-		internal int FindIndex(object[] keys)
+		internal int FindIndex (object [] keys)
 		{
-			if (keys == null || keys.Length != Key.Columns.Length) {
+			if (keys == null || keys.Length != Key.Columns.Length)
 				throw new ArgumentException("Expecting " + Key.Columns.Length + " value(s) for the key being indexed, " +
 					"but received " + ((keys == null) ? 0 : keys.Length) + " value(s).");
-			}
 
-			int tmp = Key.Table.RecordCache.NewRecord();
+			int tmp = Key.Table.RecordCache.NewRecord ();
 			try {
 				// init key values for temporal record
-				for(int i = 0; i < Key.Columns.Length; i++) {
-					Key.Columns[i].DataContainer[tmp] = keys[i];
-				}
-				return FindIndex(tmp);
-			}
-//			catch(FormatException) {
-//				return -1;
-//			}
-//			catch(InvalidCastException) {
-//				return -1;
-//			}
-			finally {
-				Key.Table.RecordCache.DisposeRecord(tmp);
+				for (int i = 0; i < Key.Columns.Length; i++)
+					Key.Columns [i].DataContainer [tmp] = keys [i];
+				return FindIndex (tmp);
+			} finally {
+				Key.Table.RecordCache.DisposeRecord (tmp);
 			}
 		}
 
@@ -252,20 +239,20 @@ namespace System.Data.Common
 		 * Returns record number of the record equal to the record supplied 
 		 * in the meaning of index key, or -1 if no equal record found.
 		 */
-		internal int Find(int record)
+		internal int Find (int record)
 		{
-			int index = FindIndex(record);
-			return IndexToRecord(index);
+			int index = FindIndex (record);
+			return IndexToRecord (index);
 		}
 
 		/*
 		 * Returns array of record numbers of the records equal equal to the key values supplied 
 		 * in the meaning of index key, or -1 if no equal record found.
 		 */
-		internal int[] FindAll(object[] keys)
+		internal int[] FindAll (object [] keys)
 		{
-			int[] indexes = FindAllIndexes(keys);
-			IndexesToRecords(indexes);
+			int [] indexes = FindAllIndexes (keys);
+			IndexesToRecords (indexes);
 			return indexes;
 		}
 
@@ -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 
 		 * in the meaning of index key, or -1 if no equal record found.
 		 */
-		internal int[] FindAllIndexes(object[] keys)
+		internal int [] FindAllIndexes (object [] keys)
 		{
-			if (keys == null || keys.Length != Key.Columns.Length) {
+			if (keys == null || keys.Length != Key.Columns.Length)
 				throw new ArgumentException("Expecting " + Key.Columns.Length + " value(s) for the key being indexed," +
 					"but received " + ((keys == null) ? 0 : keys.Length) + " value(s).");
-			}
 
-			int tmp = Key.Table.RecordCache.NewRecord();
+			int tmp = Key.Table.RecordCache.NewRecord ();
 			try {
 				// init key values for temporal record
-				for(int i = 0; i < Key.Columns.Length; i++) {
-					Key.Columns[i].DataContainer[tmp] = keys[i];
-				}
-				return FindAllIndexes(tmp);
-			}
-			catch(FormatException) {
-				return new int[0];
-			}
-			catch(InvalidCastException) {
-				return new int[0];
-			}
-			finally {
-				Key.Table.RecordCache.DisposeRecord(tmp);
+				for (int i = 0; i < Key.Columns.Length; i++)
+					Key.Columns [i].DataContainer [tmp] = keys [i];
+				return FindAllIndexes (tmp);
+			} catch(FormatException) {
+				return new int [0];
+			} catch(InvalidCastException) {
+				return new int [0];
+			} finally {
+				Key.Table.RecordCache.DisposeRecord (tmp);
 			}
 		}
 
@@ -303,10 +285,10 @@ namespace System.Data.Common
 		 * Returns array of record numbers of the records equal to the record supplied 
 		 * in the meaning of index key, or empty list if no equal records found.
 		 */
-		internal int[] FindAll(int record)
+		internal int [] FindAll (int record)
 		{
-			int[] indexes = FindAllIndexes(record);
-            IndexesToRecords(indexes);
+			int [] indexes = FindAllIndexes (record);
+			IndexesToRecords (indexes);
 			return indexes;
 		}
 
@@ -314,27 +296,26 @@ namespace System.Data.Common
 		 * Returns array of indexes of the records inside the index that equal to the record supplied 
 		 * in the meaning of index key, or empty list if no equal records found.
 		 */
-		internal int[] FindAllIndexes(int record)
+		internal int [] FindAllIndexes (int record)
 		{
 			int index = FindIndex(record);
-
-			if (index == -1) {
+			if (index == -1)
 				return new int[0];
-			}
 
 			int startIndex = index++;
 			int endIndex = index;
-			
-			for(;startIndex >= 0 && Key.CompareRecords(Array[startIndex],record) == 0;startIndex--);
-			for(;endIndex < Size && Key.CompareRecords(Array[endIndex],record) == 0;endIndex++);
+
+			for (; startIndex >= 0 && Key.CompareRecords (Array [startIndex], record) == 0; startIndex--) {
+			}
+			for (; endIndex < Size && Key.CompareRecords (Array [endIndex], record) == 0; endIndex++) {
+			}
 			
 			int length = endIndex - startIndex - 1;
-			int[] indexes = new int[length];
-			
-			for(int i = 0; i < length; i++) {
-				indexes[i] = ++startIndex;
-			}
+			int [] indexes = new int [length];
 			
+			for (int i = 0; i < length; i++)
+				indexes [i] = ++startIndex;
+		
 			return indexes;
 		}
 
@@ -342,88 +323,78 @@ namespace System.Data.Common
 		 * Returns index inside the array where record number of the record equal to the record supplied 
 		 * in the meaning of index key is sored, or -1 if no equal record found.
 		 */
-		private int FindIndex(int record)
+		private int FindIndex (int record)
 		{
-			if (Size == 0) {
+			if (Size == 0)
 				return -1;
-			}
-			return BinarySearch(Array,0,Size - 1,record);
+			return BinarySearch (Array, 0, Size - 1, record);
 		}
 
 		/*
 		 * Finds exact location of the record specified
 		 */ 
-		private int FindIndexExact(int record)
+		private int FindIndexExact (int record)
 		{
 			for (int i = 0, size = Size; i < size; i++)
-				if (Array[i] == record)
+				if (Array [i] == record)
 					return i;
-
 			return -1;
 		}
 
 		/*
 		 * Returns array of records from the indexes (locations) inside the index
 		 */
-		private void IndexesToRecords(int[] indexes)
+		private void IndexesToRecords (int [] indexes)
 		{
-			for(int i = 0; i < indexes.Length; i++) {
-				indexes[i] = Array[indexes[i]];
-			}
+			for (int i = 0; i < indexes.Length; i++)
+				indexes [i] = Array [indexes [i]];
 		}
 
-		internal void Delete(DataRow row)
+		internal void Delete (DataRow row)
 		{
-			int oldRecord = Key.GetRecord(row);
-
-			Delete(oldRecord);
+			int oldRecord = Key.GetRecord (row);
+			Delete (oldRecord);
 		}
 
-		internal void Delete(int oldRecord)
+		internal void Delete (int oldRecord)
 		{
 			if (oldRecord == -1)
 				return;
 
-			int index = FindIndexExact(oldRecord);
+			int index = FindIndexExact (oldRecord);
 			if (index != -1) {
-				if ((_hasDuplicates == IndexDuplicatesState.True)) {
+				if (_hasDuplicates == IndexDuplicatesState.True) {
 					int c1 = 1;
 					int c2 = 1;
 
-					if (index > 0) {
-						c1 = Key.CompareRecords(Array[index - 1],oldRecord);
-					}
-					if (index < Size - 1) {
-						c2 = Key.CompareRecords(Array[index + 1],oldRecord);
-					}
+					if (index > 0)
+						c1 = Key.CompareRecords (Array [index - 1], oldRecord);
+					if (index < Size - 1)
+						c2 = Key.CompareRecords (Array [index + 1], oldRecord);
 
-					if (c1 == 0 ^ c2 == 0) {
+					if (c1 == 0 ^ c2 == 0)
 						_hasDuplicates = IndexDuplicatesState.Unknown;
-					}
 				}
 				Remove(index);
 			}
 		}
 
-		private void Remove(int index)
+		private void Remove (int index)
 		{
-			if (Size > 1) {
-				System.Array.Copy(Array,index+1,Array,index,Size - index - 1);
-			}
+			if (Size > 1)
+				System.Array.Copy (Array, index + 1, Array, index,Size - index - 1);
 			_size--;
 		}
 
-
-		internal void Update(DataRow row,int oldRecord, DataRowVersion oldVersion, DataRowState oldState)
-		{			
+		internal void Update (DataRow row, int oldRecord, DataRowVersion oldVersion, DataRowState oldState)
+		{
 			bool contains = Key.ContainsVersion (oldState, oldVersion);
-			int newRecord = Key.GetRecord(row);	
+			int newRecord = Key.GetRecord (row);
 			// the record did not appeared in the index before update
 			if (oldRecord == -1 || Size == 0 || !contains) {
-				if (newRecord >= 0) {
-					if (FindIndexExact(newRecord) < 0)
-						Add(row,newRecord);
-				}
+				if (newRecord >= 0)
+					if (FindIndexExact (newRecord) < 0)
+						Add (row,newRecord);
 				return;
 			}
 			
@@ -433,95 +404,85 @@ namespace System.Data.Common
 				return;
 			}
 
-			int oldIdx = FindIndexExact(oldRecord);
-
-			if( oldIdx == -1 ) {
-				Add(row,newRecord);
+			int oldIdx = FindIndexExact (oldRecord);
+			if (oldIdx == -1) {
+				Add (row, newRecord);
 				return;
 			}
-				
+
 			int newIdx = -1;
-			int compare = Key.CompareRecords(Array[oldIdx],newRecord);
-			int start,end;
+			int compare = Key.CompareRecords (Array [oldIdx], newRecord);
+			int start, end;
 
 			int c1 = 1;
 			int c2 = 1;
 
 			if (compare == 0) {
-				if (Array[oldIdx] == newRecord) {
+				if (Array [oldIdx] == newRecord) {
 					// we deal with the same record that didn't change
 					// in the context of current index.
 					// so , do nothing.
 					return;
 				}
-			}
-			else {
-				if ((_hasDuplicates == IndexDuplicatesState.True)) {
-					if (oldIdx > 0) {
-						c1 = Key.CompareRecords(Array[oldIdx - 1],newRecord);
-					}
-					if (oldIdx < Size - 1) {
-						c2 = Key.CompareRecords(Array[oldIdx + 1],newRecord);
-					}
-
-					if ((c1 == 0 ^ c2 == 0) && compare != 0) {
+			} else {
+				if (_hasDuplicates == IndexDuplicatesState.True) {
+					if (oldIdx > 0)
+						c1 = Key.CompareRecords (Array [oldIdx - 1], newRecord);
+					if (oldIdx < Size - 1)
+						c2 = Key.CompareRecords (Array [oldIdx + 1], newRecord);
+
+					if ((c1 == 0 ^ c2 == 0) && compare != 0)
 						_hasDuplicates = IndexDuplicatesState.Unknown;
-					}
 				}
 			}
 			
 			if ((oldIdx == 0 && compare > 0) || (oldIdx == (Size - 1) && compare < 0) || (compare == 0)) {
 				// no need to switch cells
 				newIdx = oldIdx;
-			}
-			else {
+			} else {
 				if (compare < 0) {
 					// search after the old place
 					start = oldIdx + 1;
 					end = Size - 1;
-				}
-				else {
+				} else {
 					// search before the old palce
 					start = 0;
 					end = oldIdx - 1;
 				}
 
-				newIdx = LazyBinarySearch(Array,start,end,newRecord);					
+				newIdx = LazyBinarySearch (Array, start, end, newRecord);
 
 				if (oldIdx < newIdx) {
-					System.Array.Copy(Array,oldIdx + 1,Array,oldIdx,newIdx - oldIdx);
+					System.Array.Copy (Array, oldIdx + 1, Array, oldIdx, newIdx - oldIdx);
 					if (Key.CompareRecords (Array [newIdx], newRecord) > 0)
 						--newIdx;
-				}
-				else if (oldIdx > newIdx){
-					System.Array.Copy(Array,newIdx,Array,newIdx + 1,oldIdx - newIdx);
+				} else if (oldIdx > newIdx){
+					System.Array.Copy (Array, newIdx, Array, newIdx + 1, oldIdx - newIdx);
 					if (Key.CompareRecords (Array [newIdx], newRecord) < 0)
 						++newIdx;
 				}
-			}			
+			}
 			Array[newIdx] = newRecord;
 
 			if (compare != 0) {
 				if (!(_hasDuplicates == IndexDuplicatesState.True)) {
-					if (newIdx > 0) {
-						c1 = Key.CompareRecords(Array[newIdx - 1],newRecord);
-					}
-					if (newIdx < Size - 1) {
-						c2 = Key.CompareRecords(Array[newIdx + 1],newRecord);
-					}
+					if (newIdx > 0)
+						c1 = Key.CompareRecords (Array [newIdx - 1], newRecord);
+					if (newIdx < Size - 1)
+						c2 = Key.CompareRecords (Array [newIdx + 1], newRecord);
 
-					if (c1 == 0 || c2 == 0) {
+					if (c1 == 0 || c2 == 0)
 						_hasDuplicates = IndexDuplicatesState.True;
-					}
 				}
 			}
 		}
 
-		internal void Add(DataRow row) {
-			Add(row, Key.GetRecord(row));
+		internal void Add (DataRow row)
+		{
+			Add(row, Key.GetRecord (row));
 		}
 
-		private void Add(DataRow row,int newRecord)
+		private void Add (DataRow row,int newRecord)
 		{
 			int newIdx;
 
@@ -530,172 +491,151 @@ namespace System.Data.Common
 
 			if (Size == 0) {
 				newIdx = 0;
-			}
-			else {
-				newIdx = LazyBinarySearch(Array,0,Size - 1,newRecord);
+			} else {
+				newIdx = LazyBinarySearch (Array, 0, Size - 1, newRecord);
 				// if newl value is greater - insert afer old value
 				// else - insert before old value
-				if (Key.CompareRecords(Array[newIdx],newRecord) < 0) {
+				if (Key.CompareRecords (Array [newIdx], newRecord) < 0)
 					newIdx++;
-				}
 			}
-					
-			Insert(newIdx,newRecord);
+
+			Insert (newIdx, newRecord);
 
 			int c1 = 1;
 			int c2 = 1;
 			if (!(_hasDuplicates == IndexDuplicatesState.True)) {
-				if (newIdx > 0) {
-					c1 = Key.CompareRecords(Array[newIdx - 1],newRecord);
-				}
-				if (newIdx < Size - 1) {
-					c2 = Key.CompareRecords(Array[newIdx + 1],newRecord);
-				}
+				if (newIdx > 0)
+					c1 = Key.CompareRecords (Array [newIdx - 1], newRecord);
+				if (newIdx < Size - 1)
+					c2 = Key.CompareRecords (Array [newIdx + 1], newRecord);
 
-				if (c1 == 0 || c2 == 0) {
+				if (c1 == 0 || c2 == 0)
 					_hasDuplicates = IndexDuplicatesState.True;
-				}
 			}
 		}
 
-		private void Insert(int index,int r)
+		private void Insert (int index,int r)
 		{
 			if (Array.Length == Size) {
-				int[] tmp = (Size == 0) ? new int[16] : new int[Size << 1];
-				System.Array.Copy(Array,0,tmp,0,index);
-				tmp[index] = r;
-				System.Array.Copy(Array,index,tmp,index + 1,Size - index);
+				int [] tmp = (Size == 0) ? new int[16] : new int[Size << 1];
+				System.Array.Copy (Array, 0, tmp, 0, index);
+				tmp [index] = r;
+				System.Array.Copy (Array, index, tmp, index + 1, Size - index);
 				_array = tmp;
-			}
-			else {
-				System.Array.Copy(Array,index,Array,index + 1,Size - index);
-				Array[index] = r;
+			} else {
+				System.Array.Copy (Array, index, Array, index + 1, Size - index);
+				Array [index] = r;
 			}
 			_size++;
 		}
 
-		private void MergeSort(int[] to, int length)
-        {
-            int[] from = new int[length];
-            System.Array.Copy(to, 0, from, 0, from.Length);
-
-            MergeSort(from, to, 0, from.Length);
-        }
-
-        private void MergeSort(int[] from, int[] to,int p, int r)
-        {
-            int q = (p + r) >> 1;
-	        if (q == p) {
-                return;
-            }        
+		private void MergeSort (int [] to, int length)
+		{
+			int [] from = new int [length];
+			System.Array.Copy (to, 0, from, 0, from.Length);
+			MergeSort (from, to, 0, from.Length);
+		}
 
-            MergeSort(to, from, p, q);
-            MergeSort(to, from, q, r);
+		private void MergeSort(int[] from, int[] to,int p, int r)
+		{
+			int q = (p + r) >> 1;
+			if (q == p)
+				return;
 
-            // merge
-            for (int middle = q, current = p;;) {
-				int res = Key.CompareRecords(from[p],from[q]);
-                if (res > 0) {
-                    to[current++] = from[q++];
+			MergeSort (to, from, p, q);
+			MergeSort (to, from, q, r);
 
-                    if (q == r) {
-                        while( p < middle) {
-                                to[current++] = from[p++];
-						}
-                        break;
-                    }
-                }
-                else {
+			// merge
+			for (int middle = q, current = p;;) {
+				int res = Key.CompareRecords (from[p], from[q]);
+				if (res > 0) {
+					to [current++] = from [q++];
 
-					if (res == 0) {
-						_hasDuplicates = IndexDuplicatesState.True;
+					if (q == r) {
+						while (p < middle)
+							to[current++] = from[p++];
+						break;
 					}
+				} else {
+					if (res == 0)
+						_hasDuplicates = IndexDuplicatesState.True;
 
-                    to[current++] = from[p++];
+					to [current++] = from [p++];
 
-                    if (p == middle) {
-                        while( q < r) {
-                                to[current++] = from[q++];
-						}
-                        break;
-                    }
-                }
-            }
+					if (p == middle) {
+						while (q < r)
+							to[current++] = from[q++];
+						break;
+					}
+				}
+			}
 		}
 
-		private void QuickSort(int[] a,int p,int r)
+		private void QuickSort (int [] a,int p,int r)
 		{
 			if (p < r) {
-				int q = Partition(a,p,r);
-				QuickSort(a,p,q);
-				QuickSort(a,q+1,r);
+				int q = Partition (a, p, r);
+				QuickSort (a, p, q);
+				QuickSort (a, q + 1, r);
 			}
 		}
 
-		private int Partition(int[] a,int p,int r)
+		private int Partition (int [] a,int p,int r)
 		{
-			int x = a[p];
+			int x = a [p];
 			int i = p - 1;
 			int j = r + 1;
 
-			while(true) {
+			while (true) {
 				// decrement upper limit while values are greater then border value
 				do {
 					j--;
-				}
-				while(Key.CompareRecords(a[j],x) > 0);	//while(a[j] > x);
+				} while (Key.CompareRecords (a [j], x) > 0);
 
 				do {
 					i++;
-				}
-				while(Key.CompareRecords(a[i],x) < 0);	//while(a[i] < x);
+				} while (Key.CompareRecords (a [i], x) < 0);
 				
-				if (i<j) {
-					int tmp = a[j];
-					a[j] = a[i];
-					a[i] = tmp;
-				}
-				else {
+				if (i < j) {
+					int tmp = a [j];
+					a [j] = a [i];
+					a [i] = tmp;
+				} else {
 					return j;
 				}
 			}
 		}
 
-		private int BinarySearch(int[] a, int p, int r,int b)
+		private int BinarySearch (int [] a, int p, int r,int b)
 		{
-			int i = LazyBinarySearch(a,p,r,b);
-
-			return (Key.CompareRecords(a[i],b) == 0) ? i : -1;
+			int i = LazyBinarySearch (a, p, r, b);
+			return (Key.CompareRecords (a [i], b) == 0) ? i : -1;
 		}
 
 		// Lazy binary search only returns the cell number the search finished in,
 		// but does not checks that the correct value was actually found
-		private int LazyBinarySearch(int[] a, int p, int r,int b)
+		private int LazyBinarySearch (int [] a, int p, int r, int b)
 		{
-			if ( p == r ) {
+			if (p == r)
 				return p;
-			}
 
-			int q = (p+r) >> 1;
+			int q = (p + r) >> 1;
 
-			int compare = Key.CompareRecords(a[q],b);
-			if (compare < 0) { // if (a[q] < b) {
-				return LazyBinarySearch(a,q+1,r,b);
-			}
-			else if (compare > 0) { // a[q] > b
-				return LazyBinarySearch(a,p,q,b);
-			}	
-			else { // a[q] == b
+			int compare = Key.CompareRecords (a [q], b);
+			if (compare < 0)
+				return LazyBinarySearch (a, q + 1, r, b);
+			else if (compare > 0)
+				return LazyBinarySearch (a, p, q, b);
+			else
 				return q;
-			}
 		}
 
-		internal void AddRef()
+		internal void AddRef ()
 		{
 			_refCount++;
 		}
 
-		internal void RemoveRef()
+		internal void RemoveRef ()
 		{
 			_refCount--;
 		}
@@ -703,17 +643,17 @@ namespace System.Data.Common
 		/*
 		// Prints indexes. For debugging.
 		internal void Print ()
-                {
-                        for (int i=0; i < Size; i++) {
-                                Console.Write ("Index {0} record {1}: ", i, Array [i]);
-                                for (int j=0; j < Key.Table.Columns.Count; j++) {
-                                        DataColumn col = Key.Table.Columns [j];
-                                        if (Array [i] >= 0)
-                                                Console.Write ("{0,15} ", col [Array [i]]);
-                                }
-                                Console.WriteLine ();
-                        }
-                }
+		{
+			for (int i=0; i < Size; i++) {
+				Console.Write ("Index {0} record {1}: ", i, Array [i]);
+				for (int j=0; j < Key.Table.Columns.Count; j++) {
+					DataColumn col = Key.Table.Columns [j];
+					if (Array [i] >= 0)
+						Console.Write ("{0,15} ", col [Array [i]]);
+				}
+				Console.WriteLine ();
+			}
+		}
 		*/
 		
 		#endregion // Methods

+ 4 - 0
mcs/class/System.Data/System.Data.OleDb/ChangeLog

@@ -1,3 +1,7 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* OleDbCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
+
 2007-10-20  Gert Driesen  <[email protected]>
 
 	* OleDbDataAdapter.cs: In default ctor, set SelectCommand to null.

+ 2 - 4
mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs

@@ -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;
 			}
 		}

+ 4 - 0
mcs/class/System.Data/System.Data.SqlClient/ChangeLog

@@ -1,3 +1,7 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* SqlCommand.cs: Use ExceptionHelper.CheckEnumValue for enum checks.
+
 2007-10-20  Gert Driesen  <[email protected]>
 
 	* SqlCommand.cs: Added constant for default CommandTimeout, instead

+ 2 - 4
mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs

@@ -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;
 			}
 		}

+ 6 - 0
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,9 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* DataColumn.cs: Fixed ParamName of ArgumentNullException. Modified
+	exception message for invalid DateTimeMode value to match MS. Code
+	formatting.
+
 2007-10-19  Nagappan <[email protected]> 
 
 	* DataRelation.cs: Removed bogus TODO.

+ 17 - 21
mcs/class/System.Data/System.Data/DataColumn.cs

@@ -122,9 +122,8 @@ namespace System.Data {
 		{
 			ColumnName = (columnName == null ? String.Empty : columnName);
 			
-			if(dataType == null) {
-				throw new ArgumentNullException("dataType can't be null.");
-			}
+			if (dataType == null)
+				throw new ArgumentNullException("dataType");
 			
 			DataType = dataType;
 			Expression = expr == null ? String.Empty : expr;
@@ -167,9 +166,11 @@ namespace System.Data {
 					throw new InvalidOperationException ("The DateTimeMode can be set only on DataColumns of type DateTime.");
 				
 				if (!Enum.IsDefined (typeof (DataSetDateTime), value))
-					throw new InvalidEnumArgumentException ("The DataSetDateTime enumeration value, " + 
-							(int)value + ", is invalid.");
-						
+					throw new InvalidEnumArgumentException (
+						string.Format (CultureInfo.InvariantCulture,
+						"The {0} enumeration value, {1}, is invalid",
+						typeof (DataSetDateTime).Name, value));
+
 				if (_datetimeMode == value)
 					return;
 				if (_table == null || _table.Rows.Count == 0) {
@@ -235,7 +236,7 @@ namespace System.Data {
 				_allowDBNull = value;
 			}
 		}
-        
+
 		/// <summary>
 		/// Gets or sets a value indicating whether the column automatically increments the value of the column for new rows added to the table.
 		/// </summary>
@@ -733,7 +734,7 @@ namespace System.Data {
 #endif
 		[DefaultValue (false)]
 		[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-                public bool Unique 
+		public bool Unique 
 		{
 			get {
 				return _unique;
@@ -805,7 +806,7 @@ namespace System.Data {
 			copy._columnName = _columnName;
 			//Copy.Container
 			copy.DataType = DataType;
-			copy._defaultValue = _defaultValue;			
+			copy._defaultValue = _defaultValue;
 			copy._expression = _expression;
 			//Copy.ExtendedProperties
 			copy._maxLength = _maxLength;
@@ -904,29 +905,24 @@ namespace System.Data {
 		// Returns true if all the same collumns are in columnSet and compareSet
 		internal static bool AreColumnSetsTheSame(DataColumn[] columnSet, DataColumn[] compareSet)
 		{
-			if (null == columnSet && null == compareSet) {
+			if (null == columnSet && null == compareSet)
 				return true;
-			}
 
-			if (null == columnSet || null == compareSet) {
+			if (null == columnSet || null == compareSet)
 				return false;
-			}
 
-			if (columnSet.Length != compareSet.Length) { 
+			if (columnSet.Length != compareSet.Length)
 				return false;
-			}
 			
 			foreach (DataColumn col in columnSet) {
 				bool matchFound = false;
 				foreach (DataColumn compare in compareSet) {
-					if (col == compare) {
-						matchFound = true;					
-					}
+					if (col == compare)
+						matchFound = true;
 				}
-				if (! matchFound) {
+				if (!matchFound)
 					return false;
-				}
-			}			
+			}
 			return true;
 		}
 

+ 5 - 0
mcs/class/System.Data/Test/System.Data.Common/ChangeLog

@@ -1,3 +1,8 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* DBDataPermissionAttributeTest.cs: Improved test for invalid
+	KeyRestrictionBehavior. Fixed line endings.
+
 2007-10-20  Gert Driesen  <[email protected]>
 
 	* DbDataAdapterTest.cs: Added test for UpdateBatchSize.

+ 39 - 19
mcs/class/System.Data/Test/System.Data.Common/DBDataPermissionAttributeTest.cs

@@ -27,36 +27,37 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using NUnit.Framework;
 using System;
 using System.Data;
 using System.Data.Common;
 using System.Security;
 using System.Security.Permissions;
 
-namespace MonoTests.System.Data.Common {
-
-	public class NonAbstractDBDataPermissionAttribute : DBDataPermissionAttribute {
+using NUnit.Framework;
 
+namespace MonoTests.System.Data.Common
+{
+	public class NonAbstractDBDataPermissionAttribute : DBDataPermissionAttribute
+	{
 		public NonAbstractDBDataPermissionAttribute (SecurityAction action)
 			: base (action)
 		{
 		}
 
-		public override IPermission CreatePermission()
-		{
-	 		return null;
-		}
+		public override IPermission CreatePermission()
+		{
+	 		return null;
+		}
 	}
 
 	[TestFixture]
-	public class DBDataPermissionAttributeTest {
-
+	public class DBDataPermissionAttributeTest
+	{
 		[Test]
 		public void Default ()
 		{
 			DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute (SecurityAction.Assert);
-#if !TARGET_JVM			
+#if !TARGET_JVM
 			Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
 #endif			
 			Assert.IsFalse (a.Unrestricted, "Unrestricted");
@@ -96,7 +97,7 @@ namespace MonoTests.System.Data.Common {
 		[Test]
 		public void Action_Invalid ()
 		{
-			DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute ((SecurityAction)Int32.MinValue);
+			new NonAbstractDBDataPermissionAttribute ((SecurityAction)Int32.MinValue);
 			// no validation in attribute
 		}
 
@@ -134,15 +135,34 @@ namespace MonoTests.System.Data.Common {
 		}
 
 		[Test]
-#if NET_2_0
-		[ExpectedException (typeof (ArgumentOutOfRangeException))]
-#else
-		[ExpectedException (typeof (ArgumentException))]
-#endif
 		public void KeyRestrictionBehavior_Invalid ()
 		{
 			DBDataPermissionAttribute a = new NonAbstractDBDataPermissionAttribute (SecurityAction.Assert);
-			a.KeyRestrictionBehavior = (KeyRestrictionBehavior)Int32.MinValue;
+			try {
+				a.KeyRestrictionBehavior = (KeyRestrictionBehavior) 666;
+				Assert.Fail ("#1");
+#if NET_2_0
+			} catch (ArgumentOutOfRangeException ex) {
+				// The KeyRestrictionBehavior enumeration value, 666, is invalid
+				Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				Assert.IsTrue (ex.Message.IndexOf ("KeyRestrictionBehavior") != -1, "#5");
+				Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");
+				Assert.IsNotNull (ex.ParamName, "#7");
+				Assert.AreEqual ("KeyRestrictionBehavior", ex.ParamName, "#8");
+			}
+#else
+			} catch (ArgumentException ex) {
+				// The KeyRestrictionBehavior enumeration value, 666, is invalid
+				Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "#2");
+				Assert.IsNull (ex.InnerException, "#3");
+				Assert.IsNotNull (ex.Message, "#4");
+				//Assert.IsTrue (ex.Message.IndexOf ("KeyRestrictionBehavior") != -1, "#5");
+				//Assert.IsTrue (ex.Message.IndexOf ("666") != -1, "#6");
+				//Assert.IsNull (ex.ParamName, "#7");
+			}
+#endif
 		}
 
 		[Test]
@@ -165,7 +185,7 @@ namespace MonoTests.System.Data.Common {
 
 			object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);
 			Assert.AreEqual (1, attrs.Length, "AttributeUsage");
-			AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];
+			AttributeUsageAttribute aua = (AttributeUsageAttribute) attrs [0];
 			Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");
 			Assert.IsFalse (aua.Inherited, "Inherited");
 			AttributeTargets at = AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method;

+ 5 - 0
mcs/class/System.Data/Test/System.Data/ChangeLog

@@ -1,3 +1,8 @@
+2007-10-21  Gert Driesen  <[email protected]>
+
+	* DataColumnTest.cs: No longer derive from deprecated Assertion class.
+	Code formatting. Added test for DateTimeMode.
+
 2007-08-06  Nagappan A  <[email protected]>
 
 	* DataTableTest.cs (Bug55978): In some cases this test case was

+ 318 - 319
mcs/class/System.Data/Test/System.Data/DataColumnTest.cs

@@ -35,14 +35,16 @@
 // 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");
 		}
 	}
 }