Author: gert
Date: 2007-09-23 10:26:39 -0400 (Sun, 23 Sep 2007)
New Revision: 86240
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellCollectionTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
Log:
* DataGridViewCellTest.cs: Code formatting. Removed useless SetUp and
TearDown methods. Removed useless test.
* DataGridViewCellCollectionTest.cs: Added indexer tests.
* DataGridViewCellCollection.cs: Added argument checks for indexers.
Use case-insensitive lookup of column name in indexer. Code
formatting.
* System.Windows.Forms_test.dll.sources: Added
DataGridViewCellCollectionTest.cs.
Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2007-09-23 13:26:36 UTC
(rev 86239)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2007-09-23 14:26:39 UTC
(rev 86240)
@@ -1,3 +1,8 @@
+2007-09-23 Gert Driesen <[EMAIL PROTECTED]>
+
+ * System.Windows.Forms_test.dll.sources: Added
+ DataGridViewCellCollectionTest.cs.
+
2007-09-21 Justin Cherniak <[EMAIL PROTECTED]>
* SWF2k5.csproj: Fixed missing file.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-09-23 13:26:36 UTC (rev 86239)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-09-23 14:26:39 UTC (rev 86240)
@@ -1,3 +1,9 @@
+2007-09-23 Gert Driesen <[EMAIL PROTECTED]>
+
+ * DataGridViewCellCollection.cs: Added argument checks for indexers.
+ Use case-insensitive lookup of column name in indexer. Code
+ formatting.
+
2007-09-21 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* TreeNode.cs: When collapsing or expanding a node, check whether its
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
2007-09-23 13:26:36 UTC (rev 86239)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCellCollection.cs
2007-09-23 14:26:39 UTC (rev 86240)
@@ -23,20 +23,20 @@
// Pedro Martínez Juliá <[EMAIL PROTECTED]>
//
-
#if NET_2_0
+using System.Collections;
using System.ComponentModel;
-using System.Collections;
-namespace System.Windows.Forms {
-
+namespace System.Windows.Forms
+{
[ListBindable (false)]
- public class DataGridViewCellCollection : BaseCollection, IList,
ICollection, IEnumerable {
-
+ public class DataGridViewCellCollection : BaseCollection, IList,
ICollection, IEnumerable
+ {
private DataGridViewRow dataGridViewRow;
- public DataGridViewCellCollection (DataGridViewRow
dataGridViewRow) : base() {
+ public DataGridViewCellCollection (DataGridViewRow
dataGridViewRow) : base()
+ {
this.dataGridViewRow = dataGridViewRow;
}
@@ -45,13 +45,18 @@
}
object IList.this [int index] {
- get { return this[index]; }
- set { this[index] = value as DataGridViewCell; }
+ get { return this [index]; }
+ set { this [index] = value as DataGridViewCell; }
}
public DataGridViewCell this [int index] {
- get { return (DataGridViewCell) base.List[index]; }
- set { Insert(index, value); }
+ get { return (DataGridViewCell) base.List [index]; }
+ set {
+ if (value == null)
+ throw new ArgumentNullException
("value");
+
+ Insert(index, value);
+ }
}
internal DataGridViewCell GetCellInternal (int colIndex)
@@ -61,110 +66,136 @@
public DataGridViewCell this [string columnName] {
get {
+ if (columnName == null)
+ throw new ArgumentNullException
("columnName");
+
foreach (DataGridViewCell cell in base.List) {
- if (cell.OwningColumn.Name ==
columnName) {
+ if (string.Compare
(cell.OwningColumn.Name, columnName, true) == 0)
return cell;
- }
}
- return null;
+
+ throw new ArgumentException (string.Format (
+ "Column name {0} cannot be found.",
+ columnName), "columnName");
}
set {
+ if (columnName == null)
+ throw new ArgumentNullException
("columnName");
+ if (value == null)
+ throw new ArgumentNullException
("value");
+
for (int i = 0; i < base.List.Count; i++) {
- DataGridViewCell cell =
(DataGridViewCell) base.List[i];
- if (cell.OwningColumn.Name ==
columnName) {
- Insert(i, value);
+ DataGridViewCell cell =
(DataGridViewCell) base.List [i];
+ if (string.Compare
(cell.OwningColumn.Name, columnName, true) == 0) {
+ Insert (i, value);
return;
}
}
- Add(value);
+ Add (value);
}
}
public event CollectionChangeEventHandler CollectionChanged;
- int IList.Add (object o) {
- return Add(o as DataGridViewCell);
+ int IList.Add (object o)
+ {
+ return Add (o as DataGridViewCell);
}
- public virtual int Add (DataGridViewCell dataGridViewCell) {
- dataGridViewCell.SetOwningRow(dataGridViewRow);
- dataGridViewCell.SetColumnIndex(base.List.Count);
-
dataGridViewCell.SetDataGridView(dataGridViewRow.DataGridView);
- int result = base.List.Add(dataGridViewCell);
- OnCollectionChanged(new
CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewCell));
+ public virtual int Add (DataGridViewCell dataGridViewCell)
+ {
+ dataGridViewCell.SetOwningRow (dataGridViewRow);
+ dataGridViewCell.SetColumnIndex (base.List.Count);
+ dataGridViewCell.SetDataGridView
(dataGridViewRow.DataGridView);
+ int result = base.List.Add (dataGridViewCell);
+ OnCollectionChanged (new CollectionChangeEventArgs (
+ CollectionChangeAction.Add, dataGridViewCell));
return result;
}
[DesignerSerializationVisibility
(DesignerSerializationVisibility.Hidden)]
- public virtual void AddRange (params DataGridViewCell[]
dataGridViewCells) {
- foreach (DataGridViewCell cell in dataGridViewCells) {
- this.Add(cell);
- }
+ public virtual void AddRange (params DataGridViewCell[]
dataGridViewCells)
+ {
+ foreach (DataGridViewCell cell in dataGridViewCells)
+ Add (cell);
}
- public virtual void Clear () {
+ public virtual void Clear ()
+ {
base.List.Clear();
}
- bool IList.Contains (object o) {
- return Contains(o as DataGridViewCell);
+ bool IList.Contains (object o)
+ {
+ return Contains (o as DataGridViewCell);
}
- public virtual bool Contains (DataGridViewCell
dataGridViewCell) {
- return base.List.Contains(dataGridViewCell);
+ public virtual bool Contains (DataGridViewCell dataGridViewCell)
+ {
+ return base.List.Contains (dataGridViewCell);
}
- public void CopyTo (DataGridViewCell[] array, int index) {
- base.List.CopyTo(array, index);
+ public void CopyTo (DataGridViewCell[] array, int index)
+ {
+ base.List.CopyTo (array, index);
}
- int IList.IndexOf (object o) {
- return IndexOf(o as DataGridViewCell);
+ int IList.IndexOf (object o)
+ {
+ return IndexOf (o as DataGridViewCell);
}
- public int IndexOf (DataGridViewCell dataGridViewCell) {
- return base.List.IndexOf(dataGridViewCell);
+ public int IndexOf (DataGridViewCell dataGridViewCell)
+ {
+ return base.List.IndexOf (dataGridViewCell);
}
- void IList.Insert (int index, object o) {
- Insert(index, o as DataGridViewCell);
+ void IList.Insert (int index, object o)
+ {
+ Insert (index, o as DataGridViewCell);
}
- public virtual void Insert (int index, DataGridViewCell
dataGridViewCell) {
- dataGridViewCell.SetOwningRow(dataGridViewRow);
- dataGridViewCell.SetColumnIndex(index);
-
dataGridViewCell.SetDataGridView(dataGridViewRow.DataGridView);
- base.List.Insert(index, dataGridViewCell);
- OnCollectionChanged(new
CollectionChangeEventArgs(CollectionChangeAction.Add, dataGridViewCell));
+ public virtual void Insert (int index, DataGridViewCell
dataGridViewCell)
+ {
+ dataGridViewCell.SetOwningRow (dataGridViewRow);
+ dataGridViewCell.SetColumnIndex (index);
+ dataGridViewCell.SetDataGridView
(dataGridViewRow.DataGridView);
+ base.List.Insert (index, dataGridViewCell);
+ OnCollectionChanged (new CollectionChangeEventArgs (
+ CollectionChangeAction.Add, dataGridViewCell));
}
- void IList.Remove (object o) {
- Remove(o as DataGridViewCell);
+ void IList.Remove (object o)
+ {
+ Remove (o as DataGridViewCell);
}
- public virtual void Remove (DataGridViewCell dataGridViewCell) {
- base.List.Remove(dataGridViewCell);
- OnCollectionChanged(new
CollectionChangeEventArgs(CollectionChangeAction.Remove, dataGridViewCell));
+ public virtual void Remove (DataGridViewCell dataGridViewCell)
+ {
+ base.List.Remove (dataGridViewCell);
+ OnCollectionChanged (new CollectionChangeEventArgs (
+ CollectionChangeAction.Remove,
dataGridViewCell));
}
- public virtual void RemoveAt (int index) {
- DataGridViewCell cell = this[index];
- base.List.RemoveAt(index);
- OnCollectionChanged(new
CollectionChangeEventArgs(CollectionChangeAction.Remove, cell));
+ public virtual void RemoveAt (int index)
+ {
+ DataGridViewCell cell = this [index];
+ base.List.RemoveAt (index);
+ OnCollectionChanged (new CollectionChangeEventArgs (
+ CollectionChangeAction.Remove, cell));
}
protected override ArrayList List {
get { return base.List; }
}
- protected void OnCollectionChanged (CollectionChangeEventArgs
e) {
+ protected void OnCollectionChanged (CollectionChangeEventArgs e)
+ {
if (CollectionChanged != null) {
CollectionChanged(this, e);
}
}
-
}
-
}
#endif
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2007-09-23 13:26:36 UTC (rev 86239)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2007-09-23 14:26:39 UTC (rev 86240)
@@ -43,6 +43,7 @@
System.Windows.Forms/DataGridTextBoxTest.cs
System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
System.Windows.Forms/DataGridViewBandTest.cs
+System.Windows.Forms/DataGridViewCellCollectionTest.cs
System.Windows.Forms/DataGridViewCellStyleTest.cs
System.Windows.Forms/DataGridViewCellTest.cs
System.Windows.Forms/DataGridViewClipboardHeaderTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-09-23 13:26:36 UTC (rev 86239)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-09-23 14:26:39 UTC (rev 86240)
@@ -1,3 +1,9 @@
+2007-09-23 Gert Driesen <[EMAIL PROTECTED]>
+
+ * DataGridViewCellTest.cs: Code formatting. Removed useless SetUp and
+ TearDown methods. Removed useless test.
+ * DataGridViewCellCollectionTest.cs: Added indexer tests.
+
2007-09-21 Jonathan Pobst <[EMAIL PROTECTED]>
* TreeViewTest.cs: Add test for bug #326858.
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellCollectionTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellCollectionTest.cs
2007-09-23 13:26:36 UTC (rev 86239)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellCollectionTest.cs
2007-09-23 14:26:39 UTC (rev 86240)
@@ -0,0 +1,305 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Authors:
+// Gert Driesen <[EMAIL PROTECTED]>
+//
+// Copyright (c) 2007 Gert Driesen
+
+#if NET_2_0
+
+using System;
+using System.Data;
+using System.Windows.Forms;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ public class DataGridViewCellCollectionTest
+ {
+ private DataGridView _dataGridView;
+
+ [SetUp]
+ public void SetUp ()
+ {
+ DataTable dt = new DataTable ();
+ dt.Columns.Add ("Date", typeof (DateTime));
+ dt.Columns.Add ("Registered", typeof (bool));
+ dt.Columns.Add ("Event", typeof (string));
+
+ DataRow row = dt.NewRow ();
+ row ["Date"] = new DateTime (2007, 2, 3);
+ row ["Event"] = "one";
+ row ["Registered"] = false;
+ dt.Rows.Add (row);
+
+ row = dt.NewRow ();
+ row ["Date"] = new DateTime (2008, 3, 4);
+ row ["Event"] = "two";
+ row ["Registered"] = true;
+ dt.Rows.Add (row);
+
+ _dataGridView = new DataGridView ();
+ _dataGridView.DataSource = dt;
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Indexer_ColumnName ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ DataGridViewCell dateCell = cells ["Date"];
+ Assert.IsNotNull (dateCell, "#A1");
+ Assert.IsNotNull (dateCell.OwningColumn, "#A2");
+ Assert.AreEqual ("Date", dateCell.OwningColumn.Name,
"#A3");
+ Assert.IsNotNull (dateCell.Value, "#A4");
+ Assert.AreEqual (new DateTime (2007, 2, 3),
dateCell.Value, "#A5");
+
+ DataGridViewCell eventCell = cells ["eVeNT"];
+ Assert.IsNotNull (eventCell, "#B1");
+ Assert.IsNotNull (eventCell.OwningColumn, "#B2");
+ Assert.AreEqual ("Event", eventCell.OwningColumn.Name,
"#B3");
+ Assert.IsNotNull (eventCell.Value, "#B4");
+ Assert.AreEqual ("one", eventCell.Value, "#B5");
+
+ DataGridViewCell registeredCell = cells ["Registered"];
+ Assert.IsNotNull (registeredCell, "#C1");
+ Assert.IsNotNull (registeredCell.OwningColumn, "#C2");
+ Assert.AreEqual ("Registered",
registeredCell.OwningColumn.Name, "#C3");
+ Assert.IsNotNull (registeredCell.Value, "#C4");
+ Assert.AreEqual (false, registeredCell.Value, "#C5");
+
+ form.Dispose ();
+ }
+
+ [Test]
+ public void Indexer_ColumnName_NotFound ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ try {
+ DataGridViewCell cell = cells ["DoesNotExist"];
+ Assert.Fail ("#A1: " + cell);
+ } catch (ArgumentException ex) {
+ // Column named DoesNotExist cannot be found
+ Assert.AreEqual (typeof (ArgumentException),
ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsTrue (ex.Message.IndexOf
("DoesNotExist") != -1, "#A5");
+ Assert.IsNotNull (ex.ParamName, "#A6");
+ Assert.AreEqual ("columnName", ex.ParamName,
"#A7");
+ }
+
+ try {
+ DataGridViewCell cell = cells [string.Empty];
+ Assert.Fail ("#B1: " + cell);
+ } catch (ArgumentException ex) {
+ // Column named DoesNotExist cannot be found
+ Assert.AreEqual (typeof (ArgumentException),
ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsTrue (ex.Message.IndexOf (" ") != -1,
"#B5");
+ Assert.IsNotNull (ex.ParamName, "#B6");
+ Assert.AreEqual ("columnName", ex.ParamName,
"#B7");
+ }
+
+ form.Dispose ();
+ }
+
+ [Test]
+ public void Indexer_ColumnName_Null ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ try {
+ DataGridViewCell cell = cells [(string) null];
+ Assert.Fail ("#A1: " + cell);
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("columnName", ex.ParamName,
"#A6");
+ }
+
+ try {
+ cells [(string) null] = cells [0];
+ Assert.Fail ("#B1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("columnName", ex.ParamName,
"#B6");
+ }
+
+ form.Dispose ();
+ }
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Indexer_Index ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ DataGridViewCell dateCell = cells [0];
+ Assert.IsNotNull (dateCell, "#A1");
+ Assert.IsNotNull (dateCell.OwningColumn, "#A2");
+ Assert.AreEqual ("Date", dateCell.OwningColumn.Name,
"#A3");
+ Assert.IsNotNull (dateCell.Value, "#A4");
+ Assert.AreEqual (new DateTime (2007, 2, 3),
dateCell.Value, "#A5");
+
+ DataGridViewCell eventCell = cells [2];
+ Assert.IsNotNull (eventCell, "#B1");
+ Assert.IsNotNull (eventCell.OwningColumn, "#B2");
+ Assert.AreEqual ("Event", eventCell.OwningColumn.Name,
"#B3");
+ Assert.IsNotNull (eventCell.Value, "#B4");
+ Assert.AreEqual ("one", eventCell.Value, "#B5");
+
+ DataGridViewCell registeredCell = cells [1];
+ Assert.IsNotNull (registeredCell, "#C1");
+ Assert.IsNotNull (registeredCell.OwningColumn, "#C2");
+ Assert.AreEqual ("Registered",
registeredCell.OwningColumn.Name, "#C3");
+ Assert.IsNotNull (registeredCell.Value, "#C4");
+ Assert.AreEqual (false, registeredCell.Value, "#C5");
+
+ form.Dispose ();
+ }
+
+ [Test]
+ public void Indexer_Index_Negative ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ try {
+ DataGridViewCell cell = cells [-1];
+ Assert.Fail ("#A1:" + cell);
+ } catch (ArgumentOutOfRangeException ex) {
+ // Index was out of range. Must be non-negative
+ // and less than the size of the collection
+ Assert.AreEqual (typeof
(ArgumentOutOfRangeException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("index", ex.ParamName, "#A6");
+ }
+
+ try {
+ cells [-1] = new MockDataGridViewCell ();
+ Assert.Fail ("#B1");
+ } catch (ArgumentOutOfRangeException ex) {
+ // Index was out of range. Must be non-negative
+ // and less than the size of the collection
+ Assert.AreEqual (typeof
(ArgumentOutOfRangeException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("index", ex.ParamName, "#B6");
+ }
+ }
+
+ [Test]
+ public void Indexer_Index_Overflow ()
+ {
+ DataGridViewRow row = new DataGridViewRow ();
+ DataGridViewCellCollection cells = row.Cells;
+ try {
+ DataGridViewCell cell = cells [0];
+ Assert.Fail ("#1:" + cell);
+ } catch (ArgumentOutOfRangeException ex) {
+ // Index was out of range. Must be non-negative
+ // and less than the size of the collection
+ Assert.AreEqual (typeof
(ArgumentOutOfRangeException), ex.GetType (), "#2");
+ Assert.IsNull (ex.InnerException, "#3");
+ Assert.IsNotNull (ex.Message, "#4");
+ Assert.IsNotNull (ex.ParamName, "#5");
+ Assert.AreEqual ("index", ex.ParamName, "#6");
+ }
+ }
+
+ [Test]
+ public void Indexer_Value_Null ()
+ {
+ Form form = new Form ();
+ form.ShowInTaskbar = false;
+ form.Controls.Add (_dataGridView);
+ form.Show ();
+
+ DataGridViewCellCollection cells = _dataGridView.Rows
[0].Cells;
+
+ try {
+ cells ["Date"] = null;
+ Assert.Fail ("#A1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#A2");
+ Assert.IsNull (ex.InnerException, "#A3");
+ Assert.IsNotNull (ex.Message, "#A4");
+ Assert.IsNotNull (ex.ParamName, "#A5");
+ Assert.AreEqual ("value", ex.ParamName, "#A6");
+ }
+
+ try {
+ cells [0] = null;
+ Assert.Fail ("#B1");
+ } catch (ArgumentNullException ex) {
+ Assert.AreEqual (typeof
(ArgumentNullException), ex.GetType (), "#B2");
+ Assert.IsNull (ex.InnerException, "#B3");
+ Assert.IsNotNull (ex.Message, "#B4");
+ Assert.IsNotNull (ex.ParamName, "#B5");
+ Assert.AreEqual ("value", ex.ParamName, "#B6");
+ }
+
+ form.Dispose ();
+ }
+
+ class MockDataGridViewCell : DataGridViewCell
+ {
+ }
+ }
+}
+
+#endif
Property changes on:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellCollectionTest.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
2007-09-23 13:26:36 UTC (rev 86239)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewCellTest.cs
2007-09-23 14:26:39 UTC (rev 86240)
@@ -23,27 +23,21 @@
// Pedro Martínez Juliá <[EMAIL PROTECTED]>
//
-
#if NET_2_0
-using NUnit.Framework;
using System;
+using System.Collections;
+using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
-using System.ComponentModel;
-using System.Collections;
-namespace MonoTests.System.Windows.Forms {
+using NUnit.Framework;
+namespace MonoTests.System.Windows.Forms
+{
[TestFixture]
- public class DataGridViewCellTest {
-
- [SetUp]
- public void GetReady() {}
-
- [TearDown]
- public void Clean() {}
-
+ public class DataGridViewCellTest
+ {
[Test]
public void GetClipboardContentTest ()
{
@@ -160,9 +154,9 @@
Assert.AreEqual ("" + Environment.NewLine,
cell.GetClipboardContentPublic (0, true, true, true, false,
DataFormats.UnicodeText), "#A2");
Assert.AreEqual
("<TABLE><TR><TD> </TD></TR>", cell.GetClipboardContentPublic (0, true,
true, true, false, DataFormats.Html), "#A3");
Assert.AreEqual ("" + Environment.NewLine,
cell.GetClipboardContentPublic (0, true, true, true, false,
DataFormats.CommaSeparatedValue), "#A4");
-
}
}
+
[Test]
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void GetClipboardContentTestException ()
@@ -183,7 +177,6 @@
Assert.AreEqual ("abc\t",
cell.GetClipboardContentPublic (123, false, false, false, false,
DataFormats.UnicodeText), "#A2");
Assert.AreEqual ("<TD>abc</TD>",
cell.GetClipboardContentPublic (123, false, false, false, false,
DataFormats.Html), "#A3");
Assert.AreEqual ("abc,",
cell.GetClipboardContentPublic (123, false, false, false, false,
DataFormats.CommaSeparatedValue), "#A4");
-
}
}
@@ -269,6 +262,7 @@
DataGridViewCell cell =new DataGridViewCellMockObject
();
Assert.AreEqual ("DataGridViewTextBoxEditingControl",
cell.EditType.Name, "#01");
}
+
[Test]
public void TestDefaultValues ()
{
@@ -328,7 +322,6 @@
[Test]
public void AddRow_Changes ()
{
-
using (DataGridView dgv = new DataGridView ()) {
DataGridViewColumn col = new
DataGridViewComboBoxColumn ();
DataGridViewRow row = new DataGridViewRow ();
@@ -610,12 +603,6 @@
}
}
- [Test]
- [ExpectedException(typeof(InvalidEnumArgumentException))]
- public void TestException () {
- throw new InvalidEnumArgumentException();
- }
-
/*
[Test]
[ExpectedException(typeof(Exception))]
@@ -628,6 +615,7 @@
Fail ("Message");
}
*/
+
class DataGridViewCellMockObject : DataGridViewCell
{
public DataGridViewCellMockObject ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches