2006-11-13 Igor Zelmanovich <igorz@mainsoft.com>
authorIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 13 Nov 2006 15:46:32 +0000 (15:46 -0000)
committerIgor Zelmanovich <igorz@mono-cvs.ximian.com>
Mon, 13 Nov 2006 15:46:32 +0000 (15:46 -0000)
* CompositeDataBoundControl.cs: fixed:
DataBind sets ChildControlsCreated=true.

svn path=/trunk/mcs/; revision=67761

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs

index afddfca571e62dc0ea6c5238ed1f9968dab14171..6d8dbe46be69bcc523546ed73dee6691eebd4079 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-13 Igor Zelmanovich <igorz@mainsoft.com>
+
+       * CompositeDataBoundControl.cs: fixed: 
+       DataBind sets ChildControlsCreated=true.
+
 2006-11-13  Vladimir Krasnov  <vladimirk@mainsoft.com>
 
        * Login.cs: fixed CreateChildControls, throws exception if needed
index 3da0b42d0b007df22952b627a7f7d449a2b2c5df..2158e7b3c15f7910925db85bbb8a65cd94dabc0f 100644 (file)
@@ -64,6 +64,7 @@ namespace System.Web.UI.WebControls
                
                protected internal override void PerformDataBinding (IEnumerable data)
                {
+                       ChildControlsCreated = true;
                        ViewState ["_ItemCount"] = CreateChildControls (data, true);
                }
                
index 57d74322c94253e39b45d121bee9ac8cfc29661d..ed42ec59f19d8eb7ecbc7a6fa009305e656d7694 100644 (file)
@@ -1,3 +1,7 @@
+2006-11-13  Igor Zelmanovich   <igorz@mainsoft.com>
+
+       * CompositeDataBoundControlTest.cs: added tests.
+
 2006-11-13  Vladimir Krasnov  <vladimirk@mainsoft.com>
 
        * WizardTest.cs: removed NotWorking attributes,
index 432edd182cfcc5c091a6bacaf6dcdc1d566cabd9..15f52cb3652757600c0458d58929c2ead7cb82e0 100644 (file)
@@ -35,98 +35,115 @@ using System.IO;
 using System.Globalization;
 using System.Web;
 using System.Web.UI;
-using System.Web.UI.WebControls;\r
+using System.Web.UI.WebControls;
 using System.Collections;
 
 namespace MonoTests.System.Web.UI.WebControls
 {
-       [TestFixture]\r
-       public class CompositeDataBoundControlTest\r
-       {\r
-               class MyCompositeDataBoundControl : CompositeDataBoundControl\r
-               {\r
-                       public bool ensureDataBound = false;\r
-                       public bool ensureCreateChildControls = false;\r
-                       public bool createChildControls1 = false;\r
-                       public bool createChildControls2 = false;\r
-                       public bool dataBind = false;\r
-\r
-                       protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding) {\r
-                               createChildControls2 = true;\r
-                               return 10;\r
-                       }\r
-\r
-                       public void DoEnsureChildControls () {\r
-                               EnsureChildControls ();\r
-                       }\r
-\r
-                       public void DoCreateChildControls () {\r
-                               CreateChildControls ();\r
-                       }\r
-\r
-                       public override void DataBind () {\r
-                               base.DataBind ();\r
-                               dataBind = true;\r
-                       }\r
-\r
-                       protected override void EnsureDataBound () {\r
-                               base.EnsureDataBound ();\r
-                               ensureDataBound = true;\r
-                       }\r
-\r
-                       protected override void EnsureChildControls () {\r
-                               base.EnsureChildControls ();\r
-                               ensureCreateChildControls = true;\r
-                       }\r
-\r
-                       protected override void CreateChildControls () {\r
-                               base.CreateChildControls ();\r
-                               createChildControls1 = true;\r
-                       }\r
-\r
-                       public bool GetRequiresDataBinding () {\r
-                               return RequiresDataBinding;\r
-                       }\r
-\r
-                       public void SetRequiresDataBinding (bool value) {\r
-                               RequiresDataBinding = value;\r
-                       }\r
-               }\r
-\r
-               [Test]\r
-               public void DetailsView_EnsureChildControlsFlow () {\r
-                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();\r
-                       Assert.IsFalse (c.GetRequiresDataBinding());\r
-                       c.DoEnsureChildControls ();\r
-                       Assert.IsTrue (c.ensureCreateChildControls);\r
-                       Assert.IsFalse (c.ensureDataBound);\r
-                       Assert.IsFalse (c.dataBind);\r
-                       Assert.IsTrue (c.createChildControls1);\r
-                       Assert.IsFalse (c.createChildControls2);\r
-               }\r
-\r
-               [Test]\r
-               public void DetailsView_EnsureChildControlsFlow2 () {\r
-                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();\r
-                       c.SetRequiresDataBinding (true);\r
-                       Assert.IsTrue (c.GetRequiresDataBinding ());\r
-                       c.DoEnsureChildControls ();\r
-                       Assert.IsTrue (c.ensureCreateChildControls);\r
-                       Assert.IsTrue (c.ensureDataBound);\r
-                       Assert.IsFalse (c.dataBind);\r
-                       Assert.IsTrue (c.createChildControls1);\r
-                       Assert.IsFalse (c.createChildControls2);\r
-               }\r
-\r
-\r
-               [Test]\r
-               public void DetailsView_CreateChildControls_Clear () {\r
-                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();\r
-                       c.Controls.Add (new WebControl (HtmlTextWriterTag.A));\r
-                       Assert.AreEqual (1, c.Controls.Count);\r
-                       c.DoCreateChildControls ();\r
-                       Assert.AreEqual (0, c.Controls.Count);\r
-               }\r
+       [TestFixture]
+       public class CompositeDataBoundControlTest
+       {
+               class MyCompositeDataBoundControl : CompositeDataBoundControl
+               {
+                       public bool ensureDataBound = false;
+                       public bool ensureCreateChildControls = false;
+                       public bool createChildControls1 = false;
+                       public bool createChildControls2 = false;
+                       public bool dataBind = false;
+                       public bool CreateChildControls_ChildControlsCreated;
+
+                       protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding) {
+                               createChildControls2 = true;
+                               CreateChildControls_ChildControlsCreated = ChildControlsCreated;
+                               return 10;
+                       }
+
+                       public void DoEnsureChildControls () {
+                               EnsureChildControls ();
+                       }
+
+                       public void DoCreateChildControls () {
+                               CreateChildControls ();
+                       }
+
+                       public override void DataBind () {
+                               base.DataBind ();
+                               dataBind = true;
+                       }
+
+                       protected override void EnsureDataBound () {
+                               base.EnsureDataBound ();
+                               ensureDataBound = true;
+                       }
+
+                       protected override void EnsureChildControls () {
+                               base.EnsureChildControls ();
+                               ensureCreateChildControls = true;
+                       }
+
+                       protected override void CreateChildControls () {
+                               base.CreateChildControls ();
+                               createChildControls1 = true;
+                       }
+
+                       public bool GetRequiresDataBinding () {
+                               return RequiresDataBinding;
+                       }
+
+                       public void SetRequiresDataBinding (bool value) {
+                               RequiresDataBinding = value;
+                       }
+
+                       public bool GetChildControlsCreated () {
+                               return ChildControlsCreated;
+                       }
+               }
+
+               [Test]
+               public void DetailsView_EnsureChildControlsFlow () {
+                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();
+                       Assert.IsFalse (c.GetRequiresDataBinding());
+                       c.DoEnsureChildControls ();
+                       Assert.IsTrue (c.ensureCreateChildControls);
+                       Assert.IsFalse (c.ensureDataBound);
+                       Assert.IsFalse (c.dataBind);
+                       Assert.IsTrue (c.createChildControls1);
+                       Assert.IsFalse (c.createChildControls2);
+               }
+
+               [Test]
+               public void DetailsView_EnsureChildControlsFlow2 () {
+                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();
+                       c.SetRequiresDataBinding (true);
+                       Assert.IsTrue (c.GetRequiresDataBinding ());
+                       c.DoEnsureChildControls ();
+                       Assert.IsTrue (c.ensureCreateChildControls);
+                       Assert.IsTrue (c.ensureDataBound);
+                       Assert.IsFalse (c.dataBind);
+                       Assert.IsTrue (c.createChildControls1);
+                       Assert.IsFalse (c.createChildControls2);
+               }
+
+
+               [Test]
+               public void DetailsView_CreateChildControls_Clear () {
+                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();
+                       c.Controls.Add (new WebControl (HtmlTextWriterTag.A));
+                       Assert.AreEqual (1, c.Controls.Count);
+                       c.DoCreateChildControls ();
+                       Assert.AreEqual (0, c.Controls.Count);
+               }
+               
+               [Test]
+               public void DataBind_ChildControlsCreated () {
+                       Page p = new Page ();
+                       MyCompositeDataBoundControl c = new MyCompositeDataBoundControl ();
+                       p.Controls.Add (c);
+                       Assert.IsFalse (c.GetChildControlsCreated (), "ChildControlsCreated before DataBind");
+                       c.DataBind ();
+                       Assert.IsTrue (c.CreateChildControls_ChildControlsCreated, "ChildControlsCreated in CreateChildControls");
+                       Assert.IsTrue (c.GetChildControlsCreated (), "ChildControlsCreated after DataBind");
+               }
        }
 }
-#endif
\ No newline at end of file
+#endif