Quellcode durchsuchen

Implementation of ListControl.VerifyMultiSelect with method with proper overloading in derived types.

svn path=/trunk/mcs/; revision=71038
Ilya Kharmatsky vor 19 Jahren
Ursprung
Commit
7842ea07ef

+ 8 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,11 @@
+2007-01-15 Ilya Kharmatsky  <ilya -at- decode-systems.com>
+
+	* ListControl.cs
+	* CheckBoxList.cs
+	* ListBox.cs
+	Implemented the protected net_2_0 method 'VerifyMultiSelect' with
+	proper overloading in derived types.
+ 
 2007-01-15 Igor Zelmanovich <[email protected]>
 
 	* TreeNode.cs

+ 9 - 1
mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs

@@ -357,5 +357,13 @@ namespace System.Web.UI.WebControls {
 		{
 			RenderItem (itemType, repeatIndex, repeatInfo, writer);
 		}
-	}
+#if NET_2_0
+        protected internal override void VerifyMultiSelect()
+        {
+            //by default the ListControl will throw an exception in this method,
+            //therefor we should override the method if the class is supporting
+            //MultiSelect option.
+        }
+#endif
+    }
 }

+ 10 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs

@@ -282,6 +282,16 @@ namespace System.Web.UI.WebControls {
 		{
 			RaisePostDataChangedEvent ();
 		}
+#if NET_2_0
+        protected internal override void VerifyMultiSelect()
+        {
+            //by default the ListControl will throw an exception in this method,
+            //therefor we should override the method if the class is supporting
+            //MultiSelect option.
+            if (this.SelectionMode != ListSelectionMode.Multiple)
+                throw new HttpException("Multiple select option is not supported");
+        }
+#endif
 	}
 }
 

+ 1 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs

@@ -581,6 +581,7 @@ namespace System.Web.UI.WebControls {
 #if NET_2_0		
 		protected internal virtual void VerifyMultiSelect ()
 		{
+            throw new HttpException("Multi select is not supported");
 		}
 #endif		
 

+ 16 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/BulletedListTest.cs

@@ -86,6 +86,14 @@ namespace MonoTests.System.Web.UI.WebControls
 
 	}
 
+    class VerifyMultiSelectBulletedList : BulletedList
+    {
+        public new virtual void VerifyMultiSelect()
+        {
+            base.VerifyMultiSelect();
+        }
+    }
+
 	[TestFixture]
 	public class BulletedListTest
 	{
@@ -330,6 +338,14 @@ namespace MonoTests.System.Web.UI.WebControls
 			b.Items.Add (item9);
 			b.Items.Add (item10);
 		}
+
+        [Test]
+        [ExpectedException(typeof(HttpException))]
+        public void VerifyMultiSelectTest()
+        {
+            VerifyMultiSelectBulletedList list = new VerifyMultiSelectBulletedList();
+            list.VerifyMultiSelect();
+        }
 	}
 }
 

+ 11 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,14 @@
+2007-01-15 Ilya Kharmatsky <ilya -at- decode-systems.com>
+	
+	* CheckBoxListTest.cs
+	* RadioButtonListTest.cs
+	* DropDownListTest.cs
+	* ListControlTest.cs
+	* ListBoxTest.cs
+	* BulletedListTest.cs
+	Added tests for checking method 'VerifyMultiSelect', removed
+	'NotWorking' attribute.
+
 2007-01-04 Adar Wesley <[email protected]>
 
 	* RepeatInfoTest.auto.cs: Fixed tests to compare HTML with HtmlDiff

+ 15 - 1
mcs/class/System.Web/Test/System.Web.UI.WebControls/CheckBoxListTest.cs

@@ -512,7 +512,20 @@ namespace MonoTests.System.Web.UI.WebControls {
 			Render (c, exp, "C1");
 		}	
 #if NET_2_0
-		[TestFixtureTearDown]
+        class TestCheckBoxList : CheckBoxList
+        {
+            public new virtual void VerifyMultiSelect()
+            {
+                base.VerifyMultiSelect();
+            }
+        }
+        [Test]
+        public void VerifyMultiSelectTest()
+        {
+            TestCheckBoxList list = new TestCheckBoxList();
+            list.VerifyMultiSelect();
+        }
+        [TestFixtureTearDown]
 		public void teardown ()
 		{
 			WebTest.Unload ();
@@ -523,3 +536,4 @@ namespace MonoTests.System.Web.UI.WebControls {
 	}
 }
 
+

+ 18 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/DropDownListTest.cs

@@ -396,6 +396,24 @@ namespace MonoTests.System.Web.UI.WebControls
 			Assert.IsTrue (html.IndexOf ("<hola>") == -1, "#01");
 			Assert.IsTrue (html.IndexOf ("&lt;hola>") != -1, "#02");
 		}
+
+#if NET_2_0
+        class VerifyMultiSelectDropDownList : DropDownList
+        {
+            public new virtual void VerifyMultiSelect()
+            {
+                base.VerifyMultiSelect();
+            }
+        }
+
+        [Test]
+        [ExpectedException(typeof(HttpException))]
+        public void VerifyMultiSelectTest()
+        {
+            VerifyMultiSelectDropDownList list = new VerifyMultiSelectDropDownList();
+            list.VerifyMultiSelect();
+        }
+#endif
         
         
 

+ 25 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/ListBoxTest.cs

@@ -78,6 +78,12 @@ namespace MonoTests.System.Web.UI.WebControls
 			base.Render (writer);
 			return writer.InnerWriter.ToString ();
 		}
+#if NET_2_0
+        public new virtual void VerifyMultiSelect()
+        {
+            base.VerifyMultiSelect();
+        }
+#endif
 	}
 
 	[TestFixture]	
@@ -359,6 +365,25 @@ namespace MonoTests.System.Web.UI.WebControls
 			Assert.IsFalse (list.Items [3].Selected, "#14");
 
 		}
+#if NET_2_0
+        [Test]
+        public void VerifyMultiSelectPositive()
+        {
+            ListBoxPoker list = new ListBoxPoker();
+            list.SelectionMode = ListSelectionMode.Multiple;
+            list.VerifyMultiSelect();
+        }
+
+        [Test]
+        [ExpectedException(typeof(HttpException))]
+        public void VerifyMultiSelectNegative()
+        {
+            ListBoxPoker list = new ListBoxPoker();
+            list.SelectionMode = ListSelectionMode.Single;
+            list.VerifyMultiSelect();
+        }
+#endif
 	}
 }
 
+

+ 0 - 1
mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs

@@ -1014,7 +1014,6 @@ namespace MonoTests.System.Web.UI.WebControls
 		}
 #if NET_2_0
 		[Test]
-		[Category ("NotWorking")]
 		[ExpectedException (typeof (HttpException))]
 		public void VerifyMultiSelect_Exception ()
 		{

+ 13 - 0
mcs/class/System.Web/Test/System.Web.UI.WebControls/RadioButtonListTest.cs

@@ -127,6 +127,11 @@ namespace MonoTests.System.Web.UI.WebControls {
 			{
 				base.RaisePostDataChangedEvent ();
 			}
+
+			public new virtual void VerifyMultiSelect()
+			{
+				base.VerifyMultiSelect();
+			}
 		}
 #endif
 		#endregion
@@ -318,6 +323,14 @@ namespace MonoTests.System.Web.UI.WebControls {
 
 		
 #if NET_2_0
+		[Test]
+		[ExpectedException(typeof(HttpException))]
+		public void VerifyMultiSelectTest()
+	        {
+	            PokerRadioButtonList list = new PokerRadioButtonList();
+	            list.VerifyMultiSelect();
+	        }
+
 		[Test]
 		public void Defaults ()
 		{