From: Igor Zelmanovich Date: Mon, 13 Nov 2006 15:46:32 +0000 (-0000) Subject: 2006-11-13 Igor Zelmanovich X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=c4f4a57a3bc153c9145854e533d7366a8fc972f3;p=mono.git 2006-11-13 Igor Zelmanovich * CompositeDataBoundControl.cs: fixed: DataBind sets ChildControlsCreated=true. svn path=/trunk/mcs/; revision=67761 --- diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index afddfca571e..6d8dbe46be6 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,8 @@ +2006-11-13 Igor Zelmanovich + + * CompositeDataBoundControl.cs: fixed: + DataBind sets ChildControlsCreated=true. + 2006-11-13 Vladimir Krasnov * Login.cs: fixed CreateChildControls, throws exception if needed diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs index 3da0b42d0b0..2158e7b3c15 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs @@ -64,6 +64,7 @@ namespace System.Web.UI.WebControls protected internal override void PerformDataBinding (IEnumerable data) { + ChildControlsCreated = true; ViewState ["_ItemCount"] = CreateChildControls (data, true); } diff --git a/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog index 57d74322c94..ed42ec59f19 100644 --- a/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,7 @@ +2006-11-13 Igor Zelmanovich + + * CompositeDataBoundControlTest.cs: added tests. + 2006-11-13 Vladimir Krasnov * WizardTest.cs: removed NotWorking attributes, diff --git a/mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs b/mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs index 432edd182cf..15f52cb3652 100644 --- a/mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs +++ b/mcs/class/System.Web/Test/System.Web.UI.WebControls/CompositeDataBoundControlTest.cs @@ -35,98 +35,115 @@ using System.IO; using System.Globalization; using System.Web; using System.Web.UI; -using System.Web.UI.WebControls; +using System.Web.UI.WebControls; using System.Collections; namespace MonoTests.System.Web.UI.WebControls { - [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; - - protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding) { - createChildControls2 = true; - 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; - } - } - - [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); - } + [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