From fc0d545d9b41cf519a0de5c0e43fe3d1460cbb98 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Thu, 15 Mar 2007 17:17:54 +0000 Subject: [PATCH] In Test/System.Windows.Forms: 2007-03-15 Chris Toshok * BindingSourceTest.cs: add another test, and mark the NotWorking ones so that they aren't clogging up the 2.0 build. In System.Windows.Forms: 2007-03-15 Chris Toshok * BindingSource.cs: get a lot of the unit tests working. svn path=/trunk/mcs/; revision=74401 --- .../System.Windows.Forms/BindingSource.cs | 29 ++++++++++++++--- .../System.Windows.Forms/ChangeLog | 4 +++ .../System.Windows.Forms_test.dll.sources | 1 + .../Test/System.Windows.Forms/BindingSourceTest.cs | 38 ++++++++++++++++++++++ .../Test/System.Windows.Forms/ChangeLog | 5 +++ 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource.cs index 8781ce9f319..658a68bb429 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingSource.cs @@ -143,7 +143,18 @@ namespace System.Windows.Forms { [Browsable (false)] public virtual bool AllowEdit { - get { throw new NotImplementedException (); } + get { + if (list == null) + return false; + + if (list.IsReadOnly) + return false; + + if (list is IBindingList) + return ((IBindingList)list).AllowEdit; + + return true; + } } public virtual bool AllowNew { @@ -151,12 +162,12 @@ namespace System.Windows.Forms { if (allow_new_set) return allow_new; - if (list is IBindingList) - return ((IBindingList)list).AllowNew; - if (list.IsFixedSize || list.IsReadOnly) return false; + if (list is IBindingList) + return ((IBindingList)list).AllowNew; + // XXX we need to check the element // type to see if it has a default // constructor @@ -178,7 +189,15 @@ namespace System.Windows.Forms { get { if (list == null) return false; - throw new NotImplementedException (); } + + if (list.IsFixedSize || list.IsReadOnly) + return false; + + if (list is IBindingList) + return ((IBindingList)list).AllowRemove; + + return true; + } } [Browsable (false)] diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 2121700b13c..81f3703719a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,7 @@ +2007-03-15 Chris Toshok + + * BindingSource.cs: get a lot of the unit tests working. + 2007-03-15 Jonathan Pobst * Control.cs: Modify UpdateStyles to store distances when bounds >= diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources index 946fff4b4fe..ef94843a181 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources @@ -5,6 +5,7 @@ System.Windows.Forms/ApplicationContextTest.cs System.Windows.Forms/BindingTest.cs System.Windows.Forms/BindingContextTest.cs System.Windows.Forms/BindingMemberInfoTest.cs +System.Windows.Forms/BindingSourceTest.cs System.Windows.Forms/ButtonTest.cs System.Windows.Forms/CheckBoxEventTest.cs System.Windows.Forms/CheckBoxTest.cs diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingSourceTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingSourceTest.cs index e78aca7c438..c49c26f0473 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingSourceTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingSourceTest.cs @@ -31,6 +31,8 @@ using System.Windows.Forms; using NUnit.Framework; +using CategoryAttribute = NUnit.Framework.CategoryAttribute; + namespace MonoTests.System.Windows.Forms { [TestFixture] @@ -45,6 +47,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void DataSource_InitialAddChangingType () { BindingSource source = new BindingSource (); @@ -361,6 +364,32 @@ namespace MonoTests.System.Windows.Forms { } [Test] + public void AllowEdit () + { + BindingSource source = new BindingSource (); + + Assert.IsTrue (source.AllowEdit, "1"); + + source.DataSource = ""; + Assert.IsTrue (source.AllowEdit, "2"); + + source.DataSource = new int[10]; + Assert.IsTrue (source.AllowEdit, "3"); + + source.DataSource = new WorkingEnumerable (5); + Assert.IsTrue (source.AllowEdit, "4"); + + ArrayList al = new ArrayList (); + al.Add (5); + + source.DataSource = al; + Assert.IsTrue (source.AllowEdit, "5"); + + source.DataSource = ArrayList.ReadOnly (al); + Assert.IsFalse (source.AllowEdit, "6"); + } + + [Test] public void AllowRemove () { BindingSource source = new BindingSource (); @@ -416,6 +445,7 @@ namespace MonoTests.System.Windows.Forms { [Test] [ExpectedException (typeof (ArgumentException))] // DataMember property 'hi' cannot be found on the DataSource. + [Category ("NotWorking")] public void DataMemberArgumentException () { ArrayList list = new ArrayList (); @@ -469,6 +499,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void SuppliedDataSource () { List list = new List(); @@ -486,6 +517,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void DataSourceMember_set () { BindingSource source = new BindingSource (); @@ -532,6 +564,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void AddNew () { BindingSource source = new BindingSource (); @@ -540,6 +573,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void AddNew_NonBindingList () { IList list = new List (); @@ -570,6 +604,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void AllowNew () { BindingSource source = new BindingSource (); @@ -585,6 +620,7 @@ namespace MonoTests.System.Windows.Forms { [Test] [ExpectedException (typeof (InvalidOperationException))] + [Category ("NotWorking")] // "AllowNew can only be set to true on an // IBindingList or on a read-write list with a default // public constructor." @@ -679,6 +715,7 @@ namespace MonoTests.System.Windows.Forms { [Test] [ExpectedException (typeof (InvalidOperationException))] + [Category ("NotWorking")] // "AddNew cannot be called on the 'System.String' type. This type does not have a public default constructor. You can call AddNew on the 'System.String' type if you set AllowNew=true and handle the AddingNew event." public void AddNew_Invalid () { @@ -688,6 +725,7 @@ namespace MonoTests.System.Windows.Forms { } [Test] + [Category ("NotWorking")] public void BindingSuspended1 () { /* how does this property work? */ diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog index 6ff590f2fb4..8a9171c680a 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog @@ -1,3 +1,8 @@ +2007-03-15 Chris Toshok + + * BindingSourceTest.cs: add another test, and mark the NotWorking + ones so that they aren't clogging up the 2.0 build. + 2007-03-15 Jonathan Pobst * DefaultLayoutTest.cs: Add test for bug #80912. -- 2.11.4.GIT