Author: jordi
Date: 2005-07-05 13:32:59 -0400 (Tue, 05 Jul 2005)
New Revision: 46957
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
Log:
2005-07-05 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
* DataGridTextBoxColumnTest.cs: Test case
* GridTableStylesCollectionTest.cs: Test case
* DataGridTest.cs: Test case
* GridColumnStylesCollectionTest.cs: Test case
* DataGridTableStyleTest.cs: Test case
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2005-07-05 16:41:54 UTC (rev 46956)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2005-07-05 17:32:59 UTC (rev 46957)
@@ -1,4 +1,12 @@
+2005-07-05 Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+ * DataGridTextBoxColumnTest.cs: Test case
+ * GridTableStylesCollectionTest.cs: Test case
+ * DataGridTest.cs: Test case
+ * GridColumnStylesCollectionTest.cs: Test case
+ * DataGridTableStyleTest.cs: Test case
+
+
2005-07-04 Ritvik Mayank <[EMAIL PROTECTED]>
* ListBoxTest.cs : Test Cases for ListBox Properties and Methods
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
2005-07-05 16:41:54 UTC (rev 46956)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTableStyleTest.cs
2005-07-05 17:32:59 UTC (rev 46957)
@@ -0,0 +1,271 @@
+// 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.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Data;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTableStyleTest : Assertion
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+
+ AssertEquals ("AllowSorting property", true,
dg.AllowSorting);
+ AssertEquals ("ColumnHeadersVisible property", true,
dg.ColumnHeadersVisible);
+ AssertEquals ("GridLineStyle property",
DataGridLineStyle.Solid, dg.GridLineStyle);
+ AssertEquals ("PreferredColumnWidth property", 75,
dg.PreferredColumnWidth);
+ AssertEquals ("PreferredRowHeight property", 16,
dg.PreferredRowHeight);
+ AssertEquals ("ReadOnly property", false, dg.ReadOnly);
+ AssertEquals ("RowHeadersVisible property", true,
dg.RowHeadersVisible);
+ AssertEquals ("RowHeaderWidth property", 35,
dg.RowHeaderWidth);
+ }
+
+ [Test]
+ public void TestAllowSortingChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AllowSortingChanged += new EventHandler
(OnEventHandler);
+ dg.AllowSorting = !dg.AllowSorting;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestAlternatingBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.AlternatingBackColorChanged += new EventHandler
(OnEventHandler);
+ dg.AlternatingBackColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Ignore ("Microsoft lunches ForeColor event instead of
BackColor")]
+ public void TestBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.BackColorChanged += new EventHandler
(OnEventHandler);
+ dg.BackColor = Color.Yellow;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestColumnHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ColumnHeadersVisibleChanged += new EventHandler
(OnEventHandler);
+ dg.ColumnHeadersVisible = !dg.ColumnHeadersVisible;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Ignore ("Microsoft lunches BackColor event instead of
ForeColor")]
+ public void TestForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ForeColorChanged += new EventHandler
(OnEventHandler);
+ dg.ForeColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestGridLineColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineColorChanged += new EventHandler
(OnEventHandler);
+ dg.GridLineColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestGridLineStyleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.GridLineStyleChanged += new EventHandler
(OnEventHandler);
+ dg.GridLineStyle = DataGridLineStyle.None;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestHeaderBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderBackColorChanged += new EventHandler
(OnEventHandler);
+ dg.HeaderBackColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestHeaderFontChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderFontChanged += new EventHandler
(OnEventHandler);
+ dg.HeaderFont = new Font ("Arial", 20);
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestHeaderForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.HeaderForeColorChanged += new EventHandler
(OnEventHandler);
+ dg.HeaderForeColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestLinkColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkColorChanged += new EventHandler
(OnEventHandler);
+ dg.LinkColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+
+ [Ignore ("Microsoft is not firing any event")]
+ public void TestLinkHoverColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.LinkHoverColorChanged += new EventHandler
(OnEventHandler);
+ dg.LinkHoverColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.MappingNameChanged += new EventHandler
(OnEventHandler);
+ dg.MappingName = "name1";
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestPreferredColumnWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredColumnWidthChanged += new EventHandler
(OnEventHandler);
+ dg.PreferredColumnWidth = dg.PreferredColumnWidth++;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestPreferredRowHeightChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.PreferredRowHeightChanged += new EventHandler
(OnEventHandler);
+ dg.PreferredRowHeight = dg.PreferredRowHeight++;
+ AssertEquals (true, eventhandled);
+ }
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler (OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestRowHeadersVisibleChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeadersVisibleChanged += new EventHandler
(OnEventHandler);
+ dg.RowHeadersVisible = !dg.RowHeadersVisible;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestRowHeaderWidthChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.RowHeaderWidthChanged += new EventHandler
(OnEventHandler);
+ dg.RowHeaderWidth = dg.RowHeaderWidth++;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestSelectionBackColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionBackColorChanged += new EventHandler
(OnEventHandler);
+ dg.SelectionBackColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestSelectionForeColorChangedEvent ()
+ {
+ DataGridTableStyle dg = new DataGridTableStyle ();
+ eventhandled = false;
+ dg.SelectionForeColorChanged += new EventHandler
(OnEventHandler);
+ dg.SelectionForeColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
2005-07-05 16:41:54 UTC (rev 46956)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTest.cs
2005-07-05 17:32:59 UTC (rev 46957)
@@ -0,0 +1,167 @@
+// 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.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Data;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTest : Assertion
+ {
+ private bool eventhandled;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid dg = new DataGrid ();
+
+ AssertEquals ("AllowNavigation property", true,
dg.AllowNavigation);
+ AssertEquals ("AllowSorting property", true,
dg.AllowSorting);
+ AssertEquals ("BorderStyle property",
BorderStyle.Fixed3D, dg.BorderStyle);
+ AssertEquals ("CaptionText property", string.Empty,
dg.CaptionText);
+ AssertEquals ("CaptionVisible property", true,
dg.CaptionVisible);
+ AssertEquals ("ColumnHeadersVisible property", true,
dg.ColumnHeadersVisible);
+ AssertEquals ("CurrentCell property", new DataGridCell
(), dg.CurrentCell);
+ AssertEquals ("CurrentRowIndex property", -1,
dg.CurrentRowIndex);
+ AssertEquals ("DataMember property", string.Empty,
dg.DataMember);
+ AssertEquals ("DataSource property", null,
dg.DataSource);
+ AssertEquals ("FirstVisibleColumn property", 0,
dg.FirstVisibleColumn);
+ AssertEquals ("FlatMode property", false, dg.FlatMode);
+ AssertEquals ("GridLineStyle property",
DataGridLineStyle.Solid, dg.GridLineStyle);
+ AssertEquals ("ParentRowsLabelStyle property",
DataGridParentRowsLabelStyle.Both, dg.ParentRowsLabelStyle);
+ AssertEquals ("ParentRowsVisible property",
true,dg.ParentRowsVisible);
+ AssertEquals ("PreferredColumnWidth property", 75,
dg.PreferredColumnWidth);
+ AssertEquals ("PreferredRowHeight property", 16,
dg.PreferredRowHeight);
+ AssertEquals ("ReadOnly property", false, dg.ReadOnly);
+ AssertEquals ("RowHeadersVisible property", true,
dg.RowHeadersVisible);
+ AssertEquals ("RowHeaderWidth property", 35,
dg.RowHeaderWidth);
+ AssertEquals ("Site property", null, dg.Site);
+ AssertEquals ("Text property", string.Empty, dg.Text);
+ AssertEquals ("VisibleColumnCount property", 0,
dg.VisibleColumnCount);
+ }
+
+ [Test]
+ public void TestAllowNavigationChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.AllowNavigationChanged += new EventHandler
(OnEventHandler);
+ dg.AllowNavigation = !dg.AllowNavigation;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestBackgroundColorChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BackgroundColorChanged += new EventHandler
(OnEventHandler);
+ dg.BackgroundColor = Color.Red;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestBorderStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.BorderStyleChanged += new EventHandler
(OnEventHandler);
+ dg.BorderStyle = BorderStyle.None;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestCaptionVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.CaptionVisibleChanged += new EventHandler
(OnEventHandler);
+ dg.CaptionVisible = !dg.CaptionVisible;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestFlatModeChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.FlatModeChanged += new EventHandler (OnEventHandler);
+ dg.FlatMode = !dg.FlatMode;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestParentRowsLabelStyleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsLabelStyleChanged += new EventHandler
(OnEventHandler);
+ dg.ParentRowsLabelStyle =
DataGridParentRowsLabelStyle.None;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestParentRowsVisibleChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ParentRowsVisibleChanged += new EventHandler
(OnEventHandler);
+ dg.ParentRowsVisible = !dg.ParentRowsVisible;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestReadOnlyChangedEvent ()
+ {
+ DataGrid dg = new DataGrid ();
+ eventhandled = false;
+ dg.ReadOnlyChanged += new EventHandler
(OnEventHandler);
+ dg.ReadOnly = !dg.ReadOnly;
+ AssertEquals (true, eventhandled);
+ }
+
+
+ public void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
2005-07-05 16:41:54 UTC (rev 46956)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs
2005-07-05 17:32:59 UTC (rev 46957)
@@ -0,0 +1,115 @@
+// 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.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Data;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class DataGridTextBoxColumnTest : Assertion
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn
();
+
+ AssertEquals ("HorizontalAlignment property",
HorizontalAlignment.Left, col.Alignment);
+ AssertEquals ("HeaderText property", "",
col.HeaderText);
+ AssertEquals ("MappingName property", "",
col.MappingName);
+ AssertEquals ("NullText property", "(null)",
col.NullText);
+ AssertEquals ("PropertyDescriptor property", null,
col.PropertyDescriptor);
+ AssertEquals ("ReadOnly property", false, col.ReadOnly);
+ AssertEquals ("Width property", -1, col.Width);
+ AssertEquals ("Format property", "", col.Format);
+ AssertEquals ("FormatInfo property", null,
col.FormatInfo);
+ }
+
+ [Test]
+ public void TestMappingNameChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn
();
+ eventhandled = false;
+ col.MappingNameChanged += new EventHandler
(OnEventHandler);
+ col.MappingName = "name1";
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestAlignmentChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn
();
+ eventhandled = false;
+ col.AlignmentChanged += new EventHandler
(OnEventHandler);
+ col.Alignment = HorizontalAlignment.Center;
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestHeaderTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn
();
+ eventhandled = false;
+ col.HeaderTextChanged += new EventHandler
(OnEventHandler);
+ col.HeaderText = "Header";
+ AssertEquals (true, eventhandled);
+ }
+
+ [Test]
+ public void TestNullTextChangedEvent ()
+ {
+ DataGridTextBoxColumn col = new DataGridTextBoxColumn
();
+ eventhandled = false;
+ col.NullTextChanged += new EventHandler
(OnEventHandler);
+ col.NullText = "Null";
+ AssertEquals (true, eventhandled);
+ }
+
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+ }
+}
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
2005-07-05 16:41:54 UTC (rev 46956)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridColumnStylesCollectionTest.cs
2005-07-05 17:32:59 UTC (rev 46957)
@@ -0,0 +1,180 @@
+// 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.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Data;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridColumnStylesCollectionTests : Assertion
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+
+ AssertEquals ("IsSynchronized property", false,
sc.IsSynchronized);
+ AssertEquals ("SyncRoot property", false,
sc.IsSynchronized);
+ AssertEquals ("IsReadOnly property", false,
sc.IsSynchronized);
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn
();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+ AssertEquals (true, eventhandled);
+ AssertEquals (col1, Element);
+ AssertEquals (CollectionChangeAction.Add, Action);
+
+ // Add multiple
+ ResetEventData ();
+ DataGridTextBoxColumn elem1 = new DataGridTextBoxColumn
();
+ DataGridTextBoxColumn elem2 = new DataGridTextBoxColumn
();
+ sc.AddRange (new DataGridTextBoxColumn [] {elem1,
elem2});
+ AssertEquals (true, eventhandled);
+ AssertEquals (CollectionChangeAction.Add, Action);
+ AssertEquals (elem2, Element);
+
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn
();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn
();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn
();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ sc.Remove (col2);
+ AssertEquals (true, eventhandled);
+ AssertEquals (col2, Element);
+ AssertEquals (CollectionChangeAction.Remove, Action);
+ AssertEquals (2, sc.Count);
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ AssertEquals (true, eventhandled);
+ AssertEquals (col1, Element);
+ AssertEquals (CollectionChangeAction.Remove, Action);
+ AssertEquals (1, sc.Count);
+
+ ResetEventData ();
+ sc.Clear ();
+ AssertEquals (null, Element);
+ AssertEquals (CollectionChangeAction.Refresh, Action);
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ GridColumnStylesCollection sc = ts.GridColumnStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTextBoxColumn col1 = new DataGridTextBoxColumn
();
+ col1.MappingName = "Column1";
+ sc.Add (col1);
+
+ DataGridTextBoxColumn col2 = new DataGridTextBoxColumn
();
+ col2.MappingName = "Column2";
+ sc.Add (col2);
+
+ DataGridTextBoxColumn col3 = new DataGridTextBoxColumn
();
+ col3.MappingName = "Column3";
+ sc.Add (col3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ AssertEquals (1, ilist.IndexOf (col2));
+ AssertEquals (false, sc.Contains ("nothing"));
+ AssertEquals (true, sc.Contains (col3));
+ }
+
+ private void ResetEventData ()
+ {
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender,
CollectionChangeEventArgs e)
+ {
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ }
+
+ }
+
+}
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
2005-07-05 16:41:54 UTC (rev 46956)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/GridTableStylesCollectionTest.cs
2005-07-05 17:32:59 UTC (rev 46957)
@@ -0,0 +1,175 @@
+// 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.
+//
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Author:
+// Jordi Mas i Hernandez <[EMAIL PROTECTED]>
+//
+//
+
+using System;
+using System.Data;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Xml;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+ [TestFixture]
+ class GridTableStylesCollectionTests : Assertion
+ {
+ private bool eventhandled;
+ private object Element;
+ private CollectionChangeAction Action;
+
+ [TearDown]
+ public void Clean() {}
+
+ [SetUp]
+ public void GetReady ()
+ {
+ }
+
+ [Test]
+ public void TestDefaultValues ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+
+ AssertEquals ("IsSynchronized property", false,
sc.IsSynchronized);
+ AssertEquals ("SyncRoot property", false,
sc.IsSynchronized);
+ AssertEquals ("IsReadOnly property", false,
sc.IsSynchronized);
+ }
+
+ [Test]
+ public void TestAdd ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ ResetEventData ();
+ DataGridTableStyle ts = new DataGridTableStyle ();
+ ts.MappingName = "Table1";
+ sc.Add (ts);
+ AssertEquals (true, eventhandled);
+ AssertEquals (ts, Element);
+ AssertEquals (CollectionChangeAction.Add, Action);
+
+ // Add multiple
+ ResetEventData ();
+ sc.AddRange (new DataGridTableStyle [] {new
DataGridTableStyle (), new DataGridTableStyle ()});
+ AssertEquals (true, eventhandled);
+ AssertEquals (null, Element);
+ AssertEquals (CollectionChangeAction.Refresh, Action);
+ }
+
+ [Test]
+ public void TestRemove ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ sc.Remove (ts2);
+ AssertEquals (true, eventhandled);
+ AssertEquals (ts2, Element);
+ AssertEquals (CollectionChangeAction.Remove, Action);
+ AssertEquals (2, sc.Count);
+
+ ResetEventData ();
+ sc.RemoveAt (0);
+ AssertEquals (true, eventhandled);
+ AssertEquals (ts1, Element);
+ AssertEquals (CollectionChangeAction.Remove, Action);
+ AssertEquals (1, sc.Count);
+
+ ResetEventData ();
+ sc.Clear ();
+ AssertEquals (null, Element);
+ AssertEquals (CollectionChangeAction.Refresh, Action);
+
+ }
+
+ [Test]
+ public void TestIndexContains ()
+ {
+ DataGrid grid = new DataGrid ();
+ GridTableStylesCollection sc = grid.TableStyles;
+ sc.CollectionChanged += new
CollectionChangeEventHandler (OnCollectionEventHandler);
+
+ // Add single
+ DataGridTableStyle ts1 = new DataGridTableStyle ();
+ ts1.MappingName = "Table1";
+ sc.Add (ts1);
+
+ DataGridTableStyle ts2 = new DataGridTableStyle ();
+ ts2.MappingName = "Table2";
+ sc.Add (ts2);
+
+ DataGridTableStyle ts3 = new DataGridTableStyle ();
+ ts3.MappingName = "Table3";
+ sc.Add (ts3);
+
+ ResetEventData ();
+ IList ilist = (IList) sc;
+ AssertEquals (1, ilist.IndexOf (ts2));
+ AssertEquals (false, sc.Contains ("nothing"));
+ AssertEquals (true, sc.Contains (ts3));
+ }
+
+ private void ResetEventData ()
+ {
+ eventhandled = false;
+ Element = null;
+ Action = (CollectionChangeAction) 0;
+ }
+
+ private void OnEventHandler (object sender, EventArgs e)
+ {
+ eventhandled = true;
+ }
+
+ private void OnCollectionEventHandler (object sender,
CollectionChangeEventArgs e)
+ {
+ eventhandled = true;
+ Element = e.Element;
+ Action = e.Action;
+ }
+ }
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches