Browse Source

2005-09-07 Gonzalo Paniagua Javier <[email protected]>

	* HtmlInputControlTest.cs: new tests for the case when the control is
	inside a different naming container.


svn path=/trunk/mcs/; revision=49655
Gonzalo Paniagua Javier 20 years ago
parent
commit
72476c333d

+ 5 - 0
mcs/class/System.Web/Test/System.Web.UI.HtmlControls/ChangeLog

@@ -1,3 +1,8 @@
+2005-09-07 Gonzalo Paniagua Javier <[email protected]>
+
+	* HtmlInputControlTest.cs: new tests for the case when the control is
+	inside a different naming container.
+
 2005-09-06  Chris Toshok  <[email protected]>
 
 	* HtmlLinkTest.cs: add empty render test.

+ 42 - 0
mcs/class/System.Web/Test/System.Web.UI.HtmlControls/HtmlInputControlTest.cs

@@ -37,6 +37,7 @@ using NUnit.Framework;
 namespace MonoTests.System.Web.UI.HtmlControls {
 
 	public class TestHtmlInputControl : HtmlInputControl {
+		bool name_called;
 
 		public TestHtmlInputControl ()
 			: base ("mono")
@@ -54,6 +55,21 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			base.RenderAttributes (writer);
 			return writer.InnerWriter.ToString ();
 		}
+
+		public override string Name {
+			get {
+				name_called = true;
+				return base.Name;
+			}
+		}
+
+		public bool NameCalled {
+			get { return name_called; }
+			set { name_called = value; }
+		}
+	}
+
+	public class UControl : UserControl {
 	}
 
 	[TestFixture]
@@ -134,6 +150,32 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			Assert.IsNull (ic.Name, "Name-2");
 		}
 
+		[Test]
+		public void Name_InsideNaming ()
+		{
+			Control ctrl = new UControl ();
+			ctrl.ID = "parent";
+			TestHtmlInputControl ic = new TestHtmlInputControl ();
+			ctrl.Controls.Add (ic);
+			Assert.IsNull (ic.ID, "ID");
+			Assert.AreEqual (false, ic.NameCalled);
+			ic.Name = "name";
+			Assert.AreEqual (ic.Name, ic.UniqueID, "name and unique id");
+			Assert.AreEqual (true, ic.NameCalled, "name called");
+
+			ic.ID = "id";
+			Assert.AreEqual ("id", ic.ID, "ID-2");
+			Assert.AreEqual (ic.UniqueID, ic.Name, "Name-ID");
+
+			ic.Name = "name";
+			Assert.AreEqual (ic.Name, ic.UniqueID, "UniqueID-2");
+
+			ic.ID = null;
+			Assert.IsNull (ic.ID, "ID-3");
+			Assert.IsNotNull (ic.UniqueID, "UniqueID-3");
+			Assert.IsNotNull (ic.Name, "Name-2");
+		}
+
 		[Test]
 		public void IDversusValue ()
 		{