Author: atsushi
Date: 2006-05-25 09:54:56 -0400 (Thu, 25 May 2006)
New Revision: 61109
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingContextTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
Log:
2006-05-25 Atsushi Enomoto <[EMAIL PROTECTED]>
* BindingContext.cs : reject null datasource in Contains() and
Item[].
* CurrencyManager.cs : check data_member validity when data_source
is dataset. When it is late binding, the initial position is -1.
* BindingContextTest.cs : added more tests for Item, Contains()
and GetEnumerator().
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
2006-05-25 13:50:28 UTC (rev 61108)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingContext.cs
2006-05-25 13:54:56 UTC (rev 61109)
@@ -99,7 +99,7 @@
private DataSourceEntry GetEntry (object data_source, string
data_member, bool create)
{
if (data_source == null)
- data_source = null_data_source;
+ throw new ArgumentNullException ("data_source");
DataSourceEntry ds = managers [data_source] as
DataSourceEntry;
if (ds == null && create) {
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-25 13:50:28 UTC (rev 61108)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-25 13:54:56 UTC (rev 61109)
@@ -1,3 +1,10 @@
+2006-05-25 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * BindingContext.cs : reject null datasource in Contains() and
+ Item[].
+ * CurrencyManager.cs : check data_member validity when data_source
+ is dataset. When it is late binding, the initial position is -1.
+
2006-05-24 Jackson Harper <[EMAIL PROTECTED]>
* TreeNodeCollection.cs: Dont't recalculate the visible order on
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
2006-05-25 13:50:28 UTC (rev 61108)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/CurrencyManager.cs
2006-05-25 13:54:56 UTC (rev 61109)
@@ -67,12 +67,24 @@
if (table == null) {
DataSet dataset = data_source as DataSet;
- int sp = data_member.IndexOf ('.');
+ string table_name = data_member;
+ int sp = data_member != null ?
data_member.IndexOf ('.') : -1;
if (sp != -1) {
- data_member = data_member.Substring (0,
sp);
+ table_name = data_member.Substring (0,
sp);
+ data_member = data_member.Substring (sp
+ 1);
}
- if (dataset != null) {
- table = dataset.Tables [data_member];
+ if (dataset != null && table_name !=
String.Empty) {
+ table = dataset.Tables [table_name];
+ if (table == null)
+ throw new ArgumentException
(String.Format ("Specified data member table {0} does not exist in the data
source DataSet", data_member));
+ if (data_member != table_name) {
+ DataColumn col = table.Columns
[data_member];
+ DataRelation rel = (col == null
? dataset.Relations [data_member] : null);
+ if (rel == null && col == null)
+ throw new
ArgumentException (String.Format ("Specified data member {0} does not exist in
the data table {1}", data_member, table_name));
+
+ // FIXME: hmm, in such case
what should we do?
+ }
}
}
@@ -84,6 +96,11 @@
table.ParentRelations.CollectionChanged += new
CollectionChangeEventHandler (MetaDataChangedHandler);
table.Constraints.CollectionChanged += new
CollectionChangeEventHandler (MetaDataChangedHandler);
}
+
+ if (list.Count > 0)
+ listposition = 0;
+ else
+ listposition = -1; // Late binding.
}
public IList List {
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingContextTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingContextTest.cs
2006-05-25 13:50:28 UTC (rev 61108)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingContextTest.cs
2006-05-25 13:54:56 UTC (rev 61109)
@@ -31,6 +31,8 @@
using NUnit.Framework;
+using CategoryAttribute = NUnit.Framework.CategoryAttribute;
+
namespace MonoTests.System.Windows.Forms {
[TestFixture]
@@ -174,7 +176,18 @@
BindingManagerBase a = bc [data_source, "Items"];
}
+ [Category ("NotWorking")]
[Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void CantCreateChildList2 ()
+ {
+ BindingContext bc = new BindingContext ();
+ ArrayList data_source = new ArrayList ();
+
+ BindingManagerBase a = bc [data_source, "Count"];
+ }
+
+ [Test]
public void CreateCurrencyManager ()
{
BindingContext bc = new BindingContext ();
@@ -454,6 +467,42 @@
Assert.AreEqual (0, ((ICollection) p).Count,
"CLEARCORE5");
Assert.AreEqual (p.collection_changed, (int)
CollectionChangeAction.Refresh, "CLEARCORE6");
}
+
+ [Test]
+ public void TestContains ()
+ {
+ BindingContextPoker p = new BindingContextPoker ();
+ object data_source = new object ();
+ p._Add (data_source, new PropertyManager ());
+ Assert.IsTrue (p.Contains (data_source), "#1");
+ Assert.IsFalse (p.Contains ("nonexistent"), "#2");
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentNullException))]
+ public void TestContainsNull ()
+ {
+ BindingContextPoker p = new BindingContextPoker ();
+ p.Contains (null);
+ }
+
+ [Test]
+ public void TestGetEnumerator ()
+ {
+ BindingContextPoker p = new BindingContextPoker ();
+ object data_source = new object ();
+ PropertyManager pm = new PropertyManager ();
+ p._Add (data_source, pm);
+ IEnumerator e = ((IEnumerable) p).GetEnumerator ();
+ Assert.IsNotNull (e, "#1");
+ IDictionaryEnumerator de = e as IDictionaryEnumerator;
+ Assert.IsNotNull (de, "#2");
+ Assert.IsTrue (de.MoveNext (), "#3");
+ // In .NET Key is its internal type.
+ //Assert.AreEqual (data_source, de.Key, "#4");
+ //Assert.AreEqual (pm, de.Value, "#5");
+ Assert.IsFalse (de.MoveNext (), "#6");
+ }
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2006-05-25 13:50:28 UTC (rev 61108)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2006-05-25 13:54:56 UTC (rev 61109)
@@ -1,3 +1,8 @@
+2006-05-25 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * BindingContextTest.cs : added more tests for Item, Contains()
+ and GetEnumerator().
+
2006-05-18 Sebastien Pouliot <[EMAIL PROTECTED]>
* PaintEventArgsTest.cs: New. Unit tests for PaintEventArgs.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches