Author: calberto
Date: 2008-02-05 02:04:58 -0500 (Tue, 05 Feb 2008)
New Revision: 94853
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingsCollectionTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
Log:
* BindingsCollectionTest.cs: New file.
2008-02-04 Carlos Alberto Cortez <[EMAIL PROTECTED]>
Added:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingsCollectionTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingsCollectionTest.cs
2008-02-05 07:03:45 UTC (rev 94852)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/BindingsCollectionTest.cs
2008-02-05 07:04:58 UTC (rev 94853)
@@ -0,0 +1,109 @@
+// 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) 2008 Novell, Inc.
+//
+// Authors:
+// Carlos Alberto Cortez <[EMAIL PROTECTED]>
+//
+
+
+using System;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms.DataBinding {
+
+ [TestFixture]
+ public class BindingsCollectionTest
+ {
+ [SetUp]
+ protected virtual void SetUp ()
+ {
+ }
+
+ [TearDown]
+ protected virtual void TearDown ()
+ {
+ }
+
+#if NET_2_0
+ //
+ // CollectionChanging event test section
+ //
+ bool collection_changing_called;
+ int collection_expected_count;
+ string collection_expected_assert;
+ CollectionChangeAction collection_action_expected;
+ object collection_element_expected;
+
+ void CollectionChangingHandler (object o,
CollectionChangeEventArgs args)
+ {
+ BindingsCollection coll = (BindingsCollection)o;
+
+ collection_changing_called = true;
+ Assert.AreEqual (collection_expected_count, coll.Count,
collection_expected_assert + "-0");
+ Assert.AreEqual (collection_action_expected,
args.Action, collection_expected_assert + "-1");
+ Assert.AreEqual (collection_element_expected,
args.Element, collection_expected_assert + "-2");
+ }
+
+ [Test]
+ public void CollectionChangingTest ()
+ {
+ Control c = new Control ();
+ c.BindingContext = new BindingContext ();
+ c.CreateControl ();
+
+ ControlBindingsCollection binding_coll = c.DataBindings;
+
+ Binding binding = new Binding ("Text", new MockItem
("A", 0), "Text");
+ Binding binding2 = new Binding ("Name", new MockItem
("B", 0), "Text");
+ binding_coll.Add (binding);
+
+ binding_coll.CollectionChanging +=
CollectionChangingHandler;
+
+ collection_expected_count = 1;
+ collection_action_expected = CollectionChangeAction.Add;
+ collection_element_expected = binding2;
+ collection_expected_assert = "#A0";
+ binding_coll.Add (binding2);
+ Assert.IsTrue (collection_changing_called, "#A1");
+
+ collection_changing_called = false;
+ collection_expected_count = 2;
+ collection_action_expected =
CollectionChangeAction.Remove;
+ collection_element_expected = binding;
+ collection_expected_assert = "#B0";
+ binding_coll.Remove (binding);
+ Assert.IsTrue (collection_changing_called, "#B1");
+
+ collection_changing_called = false;
+ collection_expected_count = 1;
+ collection_element_expected = null;
+ collection_action_expected =
CollectionChangeAction.Refresh;
+ collection_expected_assert = "#C0";
+ binding_coll.Clear ();
+ Assert.IsTrue (collection_changing_called, "#C1");
+ }
+#endif
+ }
+}
+
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2008-02-05 07:03:45 UTC (rev 94852)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2008-02-05 07:04:58 UTC (rev 94853)
@@ -1,5 +1,9 @@
2008-02-04 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+ * BindingsCollectionTest.cs: New file.
+
+2008-02-04 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
* CurrencyManagerTest.cs: New tests for 2.0 ListChanged event.
* ListControlTest.cs: Add a default ctor for MockItem.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches