Pārlūkot izejas kodu

2005-09-05 Chris Toshok <[email protected]>

	* HtmlFormTest.cs: add some more tests to make figure out the
	property spot to be storing some of these attributes.


svn path=/trunk/mcs/; revision=49509
Chris Toshok 20 gadi atpakaļ
vecāks
revīzija
b980355ee7

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

@@ -1,3 +1,8 @@
+2005-09-05  Chris Toshok  <[email protected]>
+
+	* HtmlFormTest.cs: add some more tests to make figure out the
+	property spot to be storing some of these attributes.
+
 2005-09-01  Sebastien Pouliot  <[email protected]>
 
 	* HtmlAnchorCas.cs, HtmlButtonCas.cs, HtmlEmptyTagControlBuilderCas.cs,

+ 102 - 0
mcs/class/System.Web/Test/System.Web.UI.HtmlControls/HtmlFormTest.cs

@@ -36,6 +36,29 @@ using NUnit.Framework;
 
 namespace MonoTests.System.Web.UI.HtmlControls {
 
+	public class FormPoker : HtmlForm {
+		public FormPoker () {
+			TrackViewState ();
+		}
+
+		public object SaveState ()
+		{
+			return SaveViewState ();
+		}
+
+		public void LoadState (object state)
+		{
+			LoadViewState (state);
+		}
+
+#if NET_2_0
+		public ControlCollection GetControlCollection ()
+		{
+			return CreateControlCollection();
+		}
+#endif
+	}
+
 	[TestFixture]
 	public class HtmlFormTest {
 
@@ -51,6 +74,10 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			Assert.AreEqual (String.Empty, form.Target, "Target");
 
 			Assert.AreEqual ("form", form.TagName, "TagName");
+
+#if NET_2_0
+			Assert.IsFalse (form.SubmitDisabledControls, "TagName");
+#endif
 		}
 
 		[Test]
@@ -67,7 +94,82 @@ namespace MonoTests.System.Web.UI.HtmlControls {
 			form.Target = null;
 			Assert.AreEqual (String.Empty, form.Target, "Target");
 
+#if NET_2_0
+			form.DefaultButton = null;
+			Assert.AreEqual (String.Empty, form.DefaultButton, "DefaultButton");
+
+			form.DefaultFocus = null;
+			Assert.AreEqual (String.Empty, form.DefaultFocus, "DefaultFocus");
+#endif
 			Assert.AreEqual (0, form.Attributes.Count, "Attributes.Count");
+
+		}
+
+		[Test]
+		public void Attributes ()
+		{
+			HtmlForm form = new HtmlForm ();
+			IAttributeAccessor a = (IAttributeAccessor)form;
+
+#if NET_2_0
+			/* not stored in Attributes */
+			form.DefaultButton = "defaultbutton";
+			Assert.IsNull (a.GetAttribute ("defaultbutton"), "A1");
+
+			/* not stored in Attributes */
+			form.DefaultFocus = "defaultfocus";
+			Assert.IsNull (a.GetAttribute ("defaultfocus"), "A2");
+#endif
+			form.Enctype = "enctype";
+			Assert.AreEqual ("enctype", a.GetAttribute ("enctype"), "A3");
+
+			form.Method = "method";
+			Assert.AreEqual ("method", a.GetAttribute ("method"), "A4");
+
+			/* not stored in Attributes */
+			form.Name = "name";
+			Assert.IsNull (a.GetAttribute ("name"), "A5");
+
+#if NET_2_0
+			form.SubmitDisabledControls = true;
+			Assert.IsNull (a.GetAttribute ("submitdisabledcontrols"), "A6");
+#endif
+
+			form.Target = "target";
+			Assert.AreEqual ("target", a.GetAttribute ("target"), "A7");
+		}
+
+		[Test]
+		public void ViewState ()
+		{
+			FormPoker form = new FormPoker();
+			FormPoker copy = new FormPoker();
+
+#if NET_2_0
+			form.DefaultButton = "defaultbutton";
+			form.DefaultFocus = "defaultfocus";
+#endif
+
+			object state = form.SaveState();
+			copy.LoadState (state);
+
+#if NET_2_0
+			Assert.AreEqual ("", copy.DefaultButton, "A1");
+			Assert.AreEqual ("defaultfocus", form.DefaultFocus, "A2");
+#endif
+
+		}
+
+#if NET_2_0
+		[Test]
+		public void ControlCollection ()
+		{
+			FormPoker poker = new FormPoker();
+			ControlCollection col = poker.GetControlCollection();
+			Assert.AreEqual (col.GetType(), typeof (ControlCollection), "A1");
+			Assert.IsFalse (col.IsReadOnly, "A2");
+			Assert.AreEqual (0, col.Count, "A3");
 		}
+#endif
 	}
 }