Browse Source

2008-11-19 Marek Habersack <[email protected]>

	* ListView.cs: added paremeter checks to AddControlToContainer.
	CreateInsertItem must instantiate the template and call raise the
	ItemCreated event.
	Added parameter checks to FindPlaceholder

2008-11-19  Marek Habersack  <[email protected]>

	* AssemblyInfo.cs: made System.Web.Extensions_test_net_2_0 a
	friend assembly.

2008-11-19  Marek Habersack  <[email protected]>

	* EventRecorder.cs: class is now serializable.

	* ListViewTest.cs: use system.web Mainsoft test framework.
	ListViewPoker is now able to record events.
	Added wrappers for ListView protected methods to ListViewPoker,
	Added two simple test ITemplate classes.
	Added tests for initial values.
	Added tests for all the methods which can be tested in a simple
	way, without using a real asp.net page.
	Added test for the Edit functionality.

2008-11-19  Marek Habersack  <[email protected]>

	* CountryCollection.cs, Country.cs: added

2008-11-19  Marek Habersack  <[email protected]>

	* ListViewTest.aspx, ListViewSort.aspx, Web.mono.config: added

2008-11-19  Marek Habersack  <[email protected]>

	* Makefile (NUNIT_RESOURCE_FILES): added

	* System.Web.Extensions_test.dll.sources: added the system.web
	Mainsoft test suite files.
	Added new test files.

svn path=/trunk/mcs/; revision=119375
Marek Habersack 17 years ago
parent
commit
66c1953e77

+ 4 - 0
mcs/class/System.Web.Extensions/Assembly/AssemblyInfo.cs

@@ -63,6 +63,10 @@ using System.Security.Permissions;
 	[assembly: CLSCompliant (true)]
 	[assembly: AssemblyDelaySign (true)]
 	[assembly: AssemblyKeyFile ("../winfx.pub")]
+
+#if NET_2_0
+[assembly: InternalsVisibleTo ("System.Web.Extensions_test_net_2_0, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
+#endif
 #endif
 
 [assembly: ComVisible (false)]

+ 5 - 0
mcs/class/System.Web.Extensions/Assembly/ChangeLog

@@ -1,3 +1,8 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* AssemblyInfo.cs: made System.Web.Extensions_test_net_2_0 a
+	friend assembly.
+
 2008-04-28  Marek Habersack  <[email protected]>
 
 	* AssemblyInfo.cs: disable the ScriptResource attributes - we do

+ 8 - 0
mcs/class/System.Web.Extensions/ChangeLog

@@ -1,3 +1,11 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* Makefile (NUNIT_RESOURCE_FILES): added
+
+	* System.Web.Extensions_test.dll.sources: added the system.web
+	Mainsoft test suite files.
+	Added new test files.
+
 2008-11-18  Marek Habersack  <[email protected]>
 
 	* System.Web.Extensions.dll.sources: added

+ 9 - 2
mcs/class/System.Web.Extensions/Makefile

@@ -25,7 +25,14 @@ RESOURCE_FILES_DIST= \
 	../MicrosoftAjaxLibrary/System.Web.Extensions/1.0.61025.0/MicrosoftAjaxTimer.js		\
 	../MicrosoftAjaxLibrary/System.Web.Extensions/1.0.61025.0/MicrosoftAjaxWebForms.debug.js\
 	../MicrosoftAjaxLibrary/System.Web.Extensions/1.0.61025.0/MicrosoftAjaxWebForms.js
-	
+
+NUNIT_RESOURCE_FILES= \
+	Test/resources/Web.mono.config \
+	$(wildcard Test/resources/*.as?x) \
+	$(wildcard ../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/*.cs) \
+	$(wildcard ../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/*.as?x) \
+	$(wildcard ../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/*.master)
+
 LIB_MCS_FLAGS = \
 	-unsafe \
 	-define:NET_3_5			\
@@ -44,7 +51,7 @@ LIB_MCS_FLAGS = \
 	$(OTHER_LIB_MCS_FLAGS) 		\
 	$(RESOURCE_FILES:%=/resource:%)
 
-TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -doc:$(test_lib:.dll=.xml)  -nowarn:219 -nowarn:169 $(NUNIT_RESOURCE_FILES:%=/resource:%)
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -doc:$(test_lib:.dll=.xml) -nowarn:219,169,1591 $(NUNIT_RESOURCE_FILES:%=/resource:%)
 
 EXTRA_DISTFILES = $(RESOURCE_FILES_DIST) 
 

+ 36 - 0
mcs/class/System.Web.Extensions/System.Web.Extensions_test.dll.sources

@@ -1,3 +1,39 @@
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/AssemblyInfo.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/crc32.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/Header.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlAttribute.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlDocument.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlEntity.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlNode.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlNodeNavigator.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/HtmlWeb.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/MixedCodeDocument.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/ParseReader.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/HtmlAgilityPack/tools.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/NunitWebTest.cs
+../../System.Web/Test/mainsoft/MainsoftWebTest/XmlComparer.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseControl.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseControlCollection.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseInvoker.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseRequest.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/BaseWorkerRequest.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/FakeMembershipProvider.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/FormRequest.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/IForeignData.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/HandlerInvoker.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHandler.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyHost.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyTemplateControls.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/PageDelegates.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/PageInvoker.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/PostableRequest.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/PostableWorkerRequest.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Response.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/StandardUrl.cs
+../../System.Web/Test/mainsoft/NunitWeb/NunitWeb/WebTest.cs
+code/Country.cs
+code/CountryCollection.cs
 System.Web.Script.Serialization/JavaScriptSerializerTest.cs
 System.Web.UI/ScriptBehaviorDescriptorTest.cs
 System.Web.UI/ScriptComponentDescriptorTest.cs

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

@@ -1,3 +1,10 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* ListView.cs: added paremeter checks to AddControlToContainer.
+	CreateInsertItem must instantiate the template and call raise the
+	ItemCreated event.
+	Added parameter checks to FindPlaceholder
+
 2008-11-18  Marek Habersack  <[email protected]>
 
 	* ListViewContainer.cs: added

+ 15 - 7
mcs/class/System.Web.Extensions/System.Web.UI.WebControls/ListView.cs

@@ -738,8 +738,12 @@ namespace System.Web.UI.WebControls
 		
 		protected virtual void AddControlToContainer (Control control, Control container, int addLocation)
 		{
-			if (control == null || container == null)
-				return;
+			if (control == null)
+				throw new ArgumentNullException ("control");
+
+			// .NET doesn't check container for null (!)
+// 			if (container == null)
+// 				throw new ArgumentNullException ("container");
 
 			Control ctl;
 
@@ -908,7 +912,14 @@ namespace System.Web.UI.WebControls
 	
 		protected virtual ListViewItem CreateInsertItem ()
 		{
+			if (_insertItemTemplate == null)
+				// .NET throws a different message, but it's incorrect so we'll use
+				// this one
+				throw new InvalidOperationException ("The ListView control '" + ID + "' does not have an InsertItemTemplate template specified.");
+			
 			ListViewItem ret = CreateItem (ListViewItemType.InsertItem);
+			InstantiateInsertItemTemplate (ret);
+			OnItemCreated (new ListViewItemEventArgs (ret));
 			InsertItem = ret;
 
 			return ret;
@@ -1003,7 +1014,6 @@ namespace System.Web.UI.WebControls
 			
 			if (insertPosition == InsertItemPosition.FirstItem) {
 				lvi = CreateInsertItem ();
-				InstantiateInsertItemTemplate (lvi);
 				AddControlToContainer (lvi, currentGroup, itemPosInGroup++);
 				groupItemCounter--;
 				needSeparator = true;
@@ -1071,7 +1081,6 @@ namespace System.Web.UI.WebControls
 				}
 
 				lvi = CreateInsertItem ();
-				InstantiateInsertItemTemplate (lvi);
 				AddControlToContainer (lvi, currentGroup, itemPosInGroup++);
 				groupItemCounter--;
 			}
@@ -1154,7 +1163,6 @@ namespace System.Web.UI.WebControls
 
 			if (insertPosition == InsertItemPosition.FirstItem) {
 				lvi = CreateInsertItem ();
-				InstantiateInsertItemTemplate (lvi);
 				AddControlToContainer (lvi, _nonGroupedItemsContainer, ipos++);
 				_nonGroupedItemsContainerItemCount++;
 				needSeparator = true;
@@ -1186,7 +1194,6 @@ namespace System.Web.UI.WebControls
 				}
 				
 				lvi = CreateInsertItem ();
-				InstantiateInsertItemTemplate (lvi);
 				AddControlToContainer (lvi, _nonGroupedItemsContainer, ipos++);
 				_nonGroupedItemsContainerItemCount++;
 			}
@@ -1267,7 +1274,8 @@ namespace System.Web.UI.WebControls
 
 		protected virtual Control FindPlaceholder (string containerID, Control container)
 		{
-			if (container == null || String.IsNullOrEmpty (containerID))
+			// .NET doesn't check whether container is null (!)
+			if (String.IsNullOrEmpty (containerID))
 				return null;
 			
 			if (container.ID == containerID)

+ 1 - 1
mcs/class/System.Web.Extensions/Test/System.Web.Script.Serialization/JavaScriptSerializerTest.cs

@@ -536,7 +536,7 @@ namespace Tests.System.Web.Script.Serialization
 		[Category ("NotDotNet")]
 		public void TestSerialize2 () {
 			JavaScriptSerializer ser = new JavaScriptSerializer ();
-			ser.Serialize ("aaa", null);
+			ser.Serialize ("aaa", (StringBuilder)null);
 		}
 
 		static readonly long InitialJavaScriptDateTicks = new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks;

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

@@ -1,3 +1,16 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* EventRecorder.cs: class is now serializable.
+
+	* ListViewTest.cs: use system.web Mainsoft test framework.
+	ListViewPoker is now able to record events.
+	Added wrappers for ListView protected methods to ListViewPoker,
+	Added two simple test ITemplate classes.
+	Added tests for initial values.
+	Added tests for all the methods which can be tested in a simple
+	way, without using a real asp.net page.
+	Added test for the Edit functionality.
+
 2008-10-30  Marek Habersack  <[email protected]>
 
 	* DataPagerFieldCollectionTest.cs: created. Some basic tests for

+ 2 - 1
mcs/class/System.Web.Extensions/Test/System.Web.UI.WebControls/EventRecorder.cs

@@ -35,7 +35,8 @@ using System.Reflection;
 
 namespace Tests.System.Web.UI.WebControls
 {
-	internal sealed class EventRecorder : List <string>
+	[Serializable]
+	public sealed class EventRecorder : List <string>
 	{
 		List <string> list;
 

+ 792 - 6
mcs/class/System.Web.Extensions/Test/System.Web.UI.WebControls/ListViewTest.cs

@@ -30,19 +30,27 @@
 #if NET_3_5
 using System;
 using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.Diagnostics;
 using System.Reflection;
 using System.Web.UI;
+using System.Web.UI.HtmlControls;
 using System.Web.UI.WebControls;
 
 using NUnit.Framework;
+using MonoTests.SystemWeb.Framework;
+using MonoTests.stand_alone.WebHarness;
 
 namespace Tests.System.Web.UI.WebControls
 {
-	internal sealed class ListViewPoker : ListView
+	public sealed class ListViewPoker : ListView
 	{
 		EventRecorder recorder;
 
+		public StateBag StateBag {
+			get { return base.ViewState; }
+		}
+		
 		void RecordEvent (string suffix)
 		{
 			if (recorder == null)
@@ -60,6 +68,18 @@ namespace Tests.System.Web.UI.WebControls
 		{
 			this.recorder = recorder;
 		}
+
+		internal void SetEventRecorder (EventRecorder recorder)
+		{
+			this.recorder = recorder;
+		}
+
+		public override void ExtractItemValues (IOrderedDictionary itemValues, ListViewItem item, bool includePrimaryKey)
+		{
+			RecordEvent ("Enter");
+			base.ExtractItemValues (itemValues, item, includePrimaryKey);
+			RecordEvent ("Leave");
+		}
 		
 		protected override void OnItemCanceling (ListViewCancelEventArgs e)
 		{
@@ -208,25 +228,198 @@ namespace Tests.System.Web.UI.WebControls
 		{
 			return StartRowIndex;
 		}
+		
+		public void DoAddControlToContainer (Control control, Control container, int addLocation)
+		{
+			AddControlToContainer (control, container, addLocation);
+		}
+
+		public void DoCreateControlStyle ()
+		{
+			CreateControlStyle ();
+		}
+
+		public ListViewDataItem DoCreateDataItem (int dataItemIndex, int displayIndex)
+		{
+			return CreateDataItem (dataItemIndex, displayIndex);
+		}
+
+		public DataSourceSelectArguments DoCreateDataSourceSelectArguments ()
+		{
+			return CreateDataSourceSelectArguments ();
+		}
+
+		public void DoCreateEmptyDataItem ()
+		{
+			CreateEmptyDataItem ();
+		}
+
+		public ListViewItem DoCreateEmptyItem ()
+		{
+			return CreateEmptyItem ();
+		}
+
+		public ListViewItem DoCreateInsertItem ()
+		{
+			return CreateInsertItem ();
+		}
+
+		public ListViewItem DoCreateItem (ListViewItemType type)
+		{
+			return CreateItem (type);
+		}
+
+		public void DoCreateLayoutTemplate ()
+		{
+			CreateLayoutTemplate ();
+		}
+
+		public void DoEnsureLayoutTemplate ()
+		{
+			EnsureLayoutTemplate ();
+		}
+
+		public Control DoFindPlaceholder (string containerID, Control container)
+		{
+			return FindPlaceholder (containerID, container);
+		}
+
+		public void DoInstantiateEmptyDataTemplate (Control container)
+		{
+			InstantiateEmptyDataTemplate (container);
+		}
+
+		public void DoInstantiateEmptyItemTemplate (Control container)
+		{
+			InstantiateEmptyItemTemplate (container);
+		}
+
+		public void DoInstantiateGroupSeparatorTemplate (Control container)
+		{
+			InstantiateGroupSeparatorTemplate (container);
+		}
+
+		public void DoInstantiateGroupTemplate (Control container)
+		{
+			InstantiateGroupTemplate (container);
+		}
+
+		public void DoInstantiateInsertItemTemplate (Control container)
+		{
+			InstantiateInsertItemTemplate (container);
+		}
+
+		public void DoInstantiateItemSeparatorTemplate (Control container)
+		{
+			InstantiateItemSeparatorTemplate (container);
+		}
+
+		public void DoInstantiateItemTemplate (Control container, int displayIndex)
+		{
+			InstantiateItemTemplate (container, displayIndex);
+		}
+	}
+
+	class TestTemplate : ITemplate
+	{
+		public void InstantiateIn (Control container)
+		{
+			Control control = new Control ();
+			control.ID = "TestTemplateControl";
+			
+			container.Controls.Add (control);
+		}
+	}
+
+	class DeepTestTemplate : ITemplate
+	{
+		public void InstantiateIn (Control container)
+		{
+			Control top = new Control (), control;
+			top.Controls.Add (new Control ());
+			control = new Control ();
+			control.ID = "DeepTestTemplateControl";
+			top.Controls [0].Controls.Add (control);
+
+			container.Controls.Add (top);
+		}
 	}
 	
 	[TestFixture]
 	public class ListViewTest
 	{
+		enum ListViewItemTemplate
+		{
+			EmptyData,
+			EmptyItem,
+			GroupSeparator,
+			Group,
+			InsertItem,
+			ItemSeparator,
+			Item,
+			EditItem,
+			AlternatingItem,
+			SelectedItem
+		}
+		
+		[TestFixtureSetUp]
+                public void ListView_Init ()
+                {
+#if VISUAL_STUDIO
+                        WebTest.CopyResource (GetType (), "MonoTests.System.Web.Extensions.resources.ListViewTest.aspx", "ListViewTest.aspx");
+#else
+                        WebTest.CopyResource (GetType (), "ListViewTest.aspx", "ListViewTest.aspx");
+#endif
+                }
+		
 		[Test]
 		public void ListView_InitialValues ()
 		{
 			ListViewPoker lvp = new ListViewPoker (null);
 
-			Assert.AreEqual (-1, lvp.GetMaximumRowsProperty ());
-			Assert.AreEqual (0, lvp.GetStartRowIndexProperty ());
+			Assert.AreEqual (0, lvp.StateBag.Count, "ViewState.Count");
+			Assert.AreEqual (true, lvp.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
+			Assert.AreEqual (0, lvp.DataKeyNames.Length, "DataKeyNames.Length");
+			Assert.AreEqual (-1, lvp.EditIndex, "EditIndex");
+			Assert.AreEqual (null, lvp.EditItem, "EditItem");
+			Assert.AreEqual (null, lvp.EditItemTemplate, "EditItemTemplate");
+			Assert.AreEqual (null, lvp.EmptyDataTemplate, "EmptyDataTemplate");
+			Assert.AreEqual (null, lvp.EmptyItemTemplate, "EmptyItemTemplate");
+			Assert.AreEqual (false, lvp.EnableModelValidation, "EnableModelValidation");
+			Assert.AreEqual (1, lvp.GroupItemCount, "GroupItemCount");
+			Assert.AreEqual ("groupPlaceholder", lvp.GroupPlaceholderID, "GroupPlaceholderID");
+			Assert.AreEqual (null, lvp.GroupSeparatorTemplate, "GroupSeparatorTemplate");
+			Assert.AreEqual (null, lvp.GroupTemplate, "GroupTemplate");
+			Assert.AreEqual (null, lvp.InsertItem, "InsertItem");
+			Assert.AreEqual (InsertItemPosition.None, lvp.InsertItemPosition, "InsertItemPosition");
+			Assert.AreEqual (null, lvp.InsertItemTemplate, "InsertItemTemplate");
+			Assert.AreEqual ("itemPlaceholder", lvp.ItemPlaceholderID, "ItemPlaceholderID");
+			Assert.AreEqual (0, lvp.Items.Count, "Items.Length");
+			Assert.AreEqual (null, lvp.ItemSeparatorTemplate, "ItemSeparatorTemplate");
+			Assert.AreEqual (null, lvp.ItemTemplate, "ItemTemplate");
+			Assert.AreEqual (null, lvp.LayoutTemplate, "LayoutTemplate");
+			Assert.AreEqual (-1, lvp.GetMaximumRowsProperty (), "MaximumRows");
+			Assert.AreEqual (null, lvp.SelectedPersistedDataKey, "SelectedPersistedDataKey");
+			Assert.AreEqual (-1, lvp.SelectedIndex, "SelectedIndex");
+			Assert.AreEqual (null, lvp.SelectedItemTemplate, "SelectedItemTemplate");
+			Assert.AreEqual (SortDirection.Ascending, lvp.SortDirection, "SortDirection");
+			Assert.AreEqual (String.Empty, lvp.SortExpression, "SortExpression");
+			Assert.AreEqual (0, lvp.GetStartRowIndexProperty (), "StartRowIndex");
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		public void ListView_InitialValues_SelectedValue ()
+		{
+			var lvp = new ListViewPoker (null);
+			Assert.AreEqual (null, lvp.SelectedValue, "SelectedValue");
 		}
 		
 		[Test]
 		public void ListView_SetPageProperties_Events ()
 		{
-			EventRecorder events = new EventRecorder ();
-			ListViewPoker lvp = new ListViewPoker (events);
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
 
 			// No events expected: databind is false
 			events.Clear ();
@@ -279,10 +472,562 @@ namespace Tests.System.Web.UI.WebControls
 			Assert.AreEqual ("OnPagePropertiesChanging:Enter", events [0], "#A16");
 			Assert.AreEqual ("OnPagePropertiesChanging:Leave", events [1], "#A17");
 			Assert.AreEqual ("OnPagePropertiesChanged:Enter", events [2], "#A18");
-			Assert.AreEqual ("OnPagePropertiesChanged:Leave", events [3], "#A19");
+			Assert.AreEqual ("OnPagePropertiesChanged:Leave", events [3], "#A19");			
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentNullException))]
+		public void ListView_AddControlToContainer_NullControl ()
+		{
+			var lvp = new ListViewPoker ();
+			Control container = new Control ();
+			Control control = new Control ();
+			control.ID = "TestControl";
+			
+			lvp.DoAddControlToContainer (null, container, 0);
+			Assert.AreEqual (0, container.Controls.Count, "#A1");
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_AddControlToContainer_NullContainer ()
+		{
+			var lvp = new ListViewPoker ();
+			Control container = new Control ();
+			Control control = new Control ();
+			control.ID = "TestControl";
 			
+			lvp.DoAddControlToContainer (control, null, 0);
+			Assert.AreEqual (0, container.Controls.Count, "#A2");
+		}
+		
+		[Test]
+		public void ListView_AddControlToContainer ()
+		{
+			var lvp = new ListViewPoker ();
+			Control container = new Control ();
+			Control control = new Control ();
+			control.ID = "TestControl";
+
+			lvp.DoAddControlToContainer (control, container, 0);
+			Assert.AreEqual (typeof (Control), container.Controls [0].GetType (), "#A1");
+			Assert.AreEqual ("TestControl", container.Controls [0].ID, "#A2");
+
+			container = new HtmlTable ();
+			lvp.DoAddControlToContainer (control, container, 0);
+			Assert.AreEqual ("System.Web.UI.WebControls.ListViewTableRow", container.Controls [0].GetType ().ToString (), "#B1");
+			Assert.AreEqual ("TestControl", container.Controls [0].Controls [0].ID, "#B2");
+
+			container = new HtmlTableRow ();
+			lvp.DoAddControlToContainer (control, container, 0);
+			Assert.AreEqual ("System.Web.UI.WebControls.ListViewTableCell", container.Controls [0].GetType ().ToString (), "#C1");
+			Assert.AreEqual ("TestControl", container.Controls [0].Controls [0].ID, "#C2");
+
+			container = new Control ();
+			lvp.DoAddControlToContainer (control, container, -1);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NotSupportedException))]
+		public void ListView_CreateControlStyle ()
+		{
+			var lvp = new ListViewPoker ();
+			lvp.DoCreateControlStyle ();
+		}
+
+		[Test]
+		public void ListView_CreateDataItem ()
+		{
+			var lvp = new ListViewPoker ();
+			ListViewDataItem lvdi = lvp.DoCreateDataItem (0, 0);
+
+			Assert.IsTrue (lvdi != null, "#A1");
+			Assert.AreEqual (null, lvdi.DataItem, "#A2");
+			Assert.AreEqual (0, lvdi.DataItemIndex, "#A3");
+			Assert.AreEqual (0, lvdi.DisplayIndex, "#A4");
+			Assert.AreEqual (ListViewItemType.DataItem, lvdi.ItemType, "#A5");
+
+			lvdi = lvp.DoCreateDataItem (-1, -1);
+			Assert.AreEqual (-1, lvdi.DataItemIndex, "#A6");
+			Assert.AreEqual (-1, lvdi.DisplayIndex, "#A7");
 		}
 
+		[Test]
+		public void ListView_CreateDataSourceSelectArguments ()
+		{
+			var lvp = new ListViewPoker ();
+			DataSourceSelectArguments args = lvp.DoCreateDataSourceSelectArguments ();
+
+			Assert.IsTrue (args != null, "#A1");
+		}
+
+		[Test]
+		public void ListView_CreateEmptyDataItem ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+			lvp.DoCreateEmptyDataItem ();
+
+			Assert.AreEqual (0, events.Count, "#A1");
+			
+			lvp.EmptyDataTemplate = new TestTemplate ();
+			lvp.DoCreateEmptyDataItem ();
+			Assert.AreEqual (1, lvp.Controls.Count, "#B1");
+			Assert.AreEqual (typeof (ListViewItem), lvp.Controls [0].GetType (), "#B2");
+			Assert.AreEqual ("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#B3");
+			Assert.AreEqual ("OnItemCreated:Enter", events [0], "#B4");
+			Assert.AreEqual ("OnItemCreated:Leave", events [1], "#B5");
+		}
+
+		[Test]
+		public void ListView_CreateEmptyItem ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+			ListViewItem item = lvp.DoCreateEmptyItem ();
+
+			Assert.AreEqual (0, events.Count, "#A1");
+			Assert.AreEqual (null, item, "#A2");
+			
+			lvp.EmptyItemTemplate = new TestTemplate ();
+			item = lvp.DoCreateEmptyItem ();
+			Assert.AreEqual (0, lvp.Controls.Count, "#B1");
+			Assert.AreEqual (typeof (Control), item.Controls [0].GetType (), "#B2");
+			Assert.AreEqual ("TestTemplateControl", item.Controls [0].ID, "#B3");
+			Assert.AreEqual ("OnItemCreated:Enter", events [0], "#B4");
+			Assert.AreEqual ("OnItemCreated:Leave", events [1], "#B5");
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		public void ListView_CreateInsertItem_NoInsertItemTemplate ()
+		{
+			var lvp = new ListViewPoker ();
+			ListViewItem item = lvp.DoCreateInsertItem ();
+		}
+		
+		[Test]
+		public void ListView_CreateInsertItem ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+			
+			lvp.InsertItemTemplate = new TestTemplate ();
+			ListViewItem item = lvp.DoCreateInsertItem ();
+			Assert.AreEqual (0, lvp.Controls.Count, "#A1");
+			Assert.AreEqual (typeof (ListViewItem), item.GetType (), "#A2");
+			Assert.AreEqual (typeof (Control), item.Controls [0].GetType (), "#A3");
+
+			Assert.AreEqual (2, events.Count, "#A4");
+			Assert.AreEqual ("TestTemplateControl", item.Controls [0].ID, "#A5");
+			Assert.AreEqual ("OnItemCreated:Enter", events [0], "#A6");
+			Assert.AreEqual ("OnItemCreated:Leave", events [1], "#A7");
+			
+			Assert.AreEqual (ListViewItemType.InsertItem, item.ItemType, "#A7");
+			Assert.IsTrue (item.Equals (lvp.InsertItem), "#A8");
+		}
+
+		[Test]
+		public void ListView_CreateItem ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+			ListViewItem item;
+
+			item = lvp.DoCreateItem (ListViewItemType.DataItem);
+			Assert.IsFalse (item == null, "#A1");
+			Assert.AreEqual (ListViewItemType.DataItem, item.ItemType, "#A2");
+			Assert.AreEqual (typeof (ListViewItem), item.GetType (), "#A3");
+
+			Assert.AreEqual (0, events.Count, "#B1");
+			
+			item = lvp.DoCreateItem (ListViewItemType.InsertItem);
+			Assert.IsFalse (item == null, "#C1");
+			Assert.AreEqual (ListViewItemType.InsertItem, item.ItemType, "#C2");
+			Assert.AreEqual (typeof (ListViewItem), item.GetType (), "#C3");
+
+			item = lvp.DoCreateItem (ListViewItemType.EmptyItem);
+			Assert.IsFalse (item == null, "#D1");
+			Assert.AreEqual (ListViewItemType.EmptyItem, item.ItemType, "#D2");
+			Assert.AreEqual (typeof (ListViewItem), item.GetType (), "#D3");
+		}
+
+		[Test]
+		public void ListView_CreateLayoutTemplate ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+
+			lvp.DoCreateLayoutTemplate ();
+			Assert.AreEqual (2, events.Count, "#A1");
+			Assert.AreEqual ("OnLayoutCreated:Enter", events [0], "#A2");
+			Assert.AreEqual ("OnLayoutCreated:Leave", events [1], "#A3");
+			Assert.AreEqual (0, lvp.Controls.Count, "#A4");
+			
+			events.Clear ();
+			lvp.LayoutTemplate = new TestTemplate ();
+			lvp.DoCreateLayoutTemplate ();
+			Assert.AreEqual (2, events.Count, "#B1");
+			Assert.AreEqual ("OnLayoutCreated:Enter", events [0], "#B2");
+			Assert.AreEqual ("OnLayoutCreated:Leave", events [1], "#B3");
+			Assert.AreEqual (1, lvp.Controls.Count, "#B4");
+			Assert.AreEqual (typeof (Control), lvp.Controls [0].GetType (), "#B5");
+			Assert.AreEqual ("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#B6");
+		}
+
+		[Test]
+		public void ListView_EnsureLayoutTemplate ()
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+
+			lvp.DoEnsureLayoutTemplate ();
+			Assert.AreEqual (2, events.Count, "#A1");
+			Assert.AreEqual ("OnLayoutCreated:Enter", events [0], "#A2");
+			Assert.AreEqual ("OnLayoutCreated:Leave", events [1], "#A3");
+			Assert.AreEqual (0, lvp.Controls.Count, "#A4");
+			
+			events.Clear ();
+			lvp.LayoutTemplate = new TestTemplate ();
+			lvp.DoEnsureLayoutTemplate ();
+			Assert.AreEqual (2, events.Count, "#B1");
+			Assert.AreEqual ("OnLayoutCreated:Enter", events [0], "#B2");
+			Assert.AreEqual ("OnLayoutCreated:Leave", events [1], "#B3");
+			Assert.AreEqual (1, lvp.Controls.Count, "#B4");
+			Assert.AreEqual (typeof (Control), lvp.Controls [0].GetType (), "#B5");
+			Assert.AreEqual ("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#B6");
+
+			events.Clear ();
+			lvp.DoEnsureLayoutTemplate ();
+			Assert.AreEqual (0, events.Count, "#C1");
+			Assert.AreEqual (1, lvp.Controls.Count, "#C2");
+			Assert.AreEqual (typeof (Control), lvp.Controls [0].GetType (), "#C3");
+			Assert.AreEqual ("TestTemplateControl", lvp.Controls [0].Controls [0].ID, "#C4");
+		}
+
+		[Test]
+		public void ListView_FindPlaceholder ()
+		{
+			var lvp = new ListViewPoker ();
+			Control control;
+
+			control = lvp.DoFindPlaceholder ("somePlaceholder", lvp);
+			Assert.IsTrue (control == null, "#A1");
+
+			control = lvp.DoFindPlaceholder (null, lvp);
+			Assert.IsTrue (control == null, "#A2");
+			
+			control = lvp.DoFindPlaceholder (String.Empty, lvp);
+			Assert.IsTrue (control == null, "#A3");
+
+			lvp.LayoutTemplate = new TestTemplate ();
+			lvp.DoEnsureLayoutTemplate ();
+			control = lvp.DoFindPlaceholder ("TestTemplateControl", lvp);
+			Assert.IsFalse (control == null, "#B1");
+			Assert.AreEqual ("TestTemplateControl", control.ID, "#B2");
+			control = lvp.DoFindPlaceholder ("DoesNotExist", lvp);
+			Assert.IsTrue (control == null, "#B3");
+			
+			lvp = new ListViewPoker ();
+			lvp.LayoutTemplate = new DeepTestTemplate ();
+			lvp.DoEnsureLayoutTemplate ();
+			control = lvp.DoFindPlaceholder ("DeepTestTemplateControl", lvp);
+			Assert.IsFalse (control == null, "#C1");
+			Assert.AreEqual ("DeepTestTemplateControl", control.ID, "#C2");
+			control = lvp.DoFindPlaceholder ("DoesNotExist", lvp);
+			Assert.IsTrue (control == null, "#C3");
+		}
+
+		void DoInstantiateCall (ListViewItemTemplate whichTemplate)
+		{
+			var events = new EventRecorder ();
+			var lvp = new ListViewPoker (events);
+			var container = new Control ();
+			var template = new TestTemplate ();
+
+			switch (whichTemplate) {
+				case ListViewItemTemplate.EmptyData:
+					lvp.DoInstantiateEmptyDataTemplate (null);
+					lvp.EmptyDataTemplate = template;
+					lvp.DoInstantiateEmptyDataTemplate (container);
+					break;
+
+				case ListViewItemTemplate.EmptyItem:
+					lvp.DoInstantiateEmptyItemTemplate (null);
+					lvp.EmptyItemTemplate = template;
+					lvp.DoInstantiateEmptyItemTemplate (container);
+					break;
+
+				case ListViewItemTemplate.GroupSeparator:
+					lvp.DoInstantiateGroupSeparatorTemplate (null);
+					lvp.GroupSeparatorTemplate = template;
+					lvp.DoInstantiateGroupSeparatorTemplate (container);
+					break;
+
+				case ListViewItemTemplate.Group:
+					lvp.DoInstantiateGroupTemplate (null);
+					lvp.GroupTemplate = template;
+					lvp.DoInstantiateGroupTemplate (container);
+					break;
+
+				case ListViewItemTemplate.InsertItem:
+					lvp.DoInstantiateInsertItemTemplate (null);
+					lvp.InsertItemTemplate = template;
+					lvp.DoInstantiateInsertItemTemplate (container);
+					break;
+
+				case ListViewItemTemplate.ItemSeparator:
+					lvp.DoInstantiateItemSeparatorTemplate (null);
+					lvp.ItemSeparatorTemplate = template;
+					lvp.DoInstantiateItemSeparatorTemplate (container);
+					break;
+
+				case ListViewItemTemplate.Item:
+					lvp.ItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (container, 0);
+					break;
+					
+				case ListViewItemTemplate.EditItem:
+					lvp.EditIndex = 0;
+					lvp.ItemTemplate = template;
+					lvp.EditItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (container, 0);
+					break;
+					
+				case ListViewItemTemplate.AlternatingItem:
+					lvp.ItemTemplate = template;
+					lvp.AlternatingItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (container, 1);
+					break;
+					
+				case ListViewItemTemplate.SelectedItem:
+					lvp.ItemTemplate = template;
+					lvp.SelectedIndex = 0;
+					lvp.SelectedItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (container, 0);
+					break;
+
+				default:
+					throw new NotSupportedException ("Unsupported ListView item type.");
+			}
+			
+			Assert.AreEqual (0, events.Count, "#A1");
+			Assert.AreEqual (typeof (Control), container.Controls [0].GetType (), "#A2");
+			Assert.AreEqual ("TestTemplateControl", container.Controls [0].ID, "#A3");
+		}
+
+		void DoInstantiateContainerNullCall (ListViewItemTemplate whichTemplate)
+		{
+			var lvp = new ListViewPoker ();
+			var template = new TestTemplate ();
+
+			switch (whichTemplate) {
+				case ListViewItemTemplate.EmptyData:
+					lvp.EmptyDataTemplate = template;
+					lvp.DoInstantiateEmptyDataTemplate (null);
+					break;
+
+				case ListViewItemTemplate.EmptyItem:
+					lvp.EmptyItemTemplate = template;
+					lvp.DoInstantiateEmptyItemTemplate (null);
+					break;
+
+				case ListViewItemTemplate.GroupSeparator:
+					lvp.GroupSeparatorTemplate = template;
+					lvp.DoInstantiateGroupSeparatorTemplate (null);
+					break;
+
+				case ListViewItemTemplate.Group:
+					lvp.GroupTemplate = template;
+					lvp.DoInstantiateGroupTemplate (null);
+					break;
+
+				case ListViewItemTemplate.InsertItem:
+					lvp.InsertItemTemplate = template;
+					lvp.DoInstantiateInsertItemTemplate (null);
+					break;
+
+				case ListViewItemTemplate.ItemSeparator:
+					lvp.ItemSeparatorTemplate = template;
+					lvp.DoInstantiateItemSeparatorTemplate (null);
+					break;
+					
+				case ListViewItemTemplate.Item:
+					lvp.ItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (null, 0);
+					break;
+					
+				case ListViewItemTemplate.EditItem:
+					lvp.EditItemTemplate = template;
+					lvp.ItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (null, 0);
+					break;
+					
+				case ListViewItemTemplate.AlternatingItem:
+					lvp.AlternatingItemTemplate = template;
+					lvp.ItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (null, 0);
+					break;
+					
+				case ListViewItemTemplate.SelectedItem:
+					lvp.SelectedItemTemplate = template;
+					lvp.ItemTemplate = template;
+					lvp.DoInstantiateItemTemplate (null, 0);
+					break;
+
+				default:
+					throw new NotSupportedException ("Unsupported ListView item type.");
+			}
+		}
+
+		[Test]
+		[ExpectedException (typeof (InvalidOperationException))]
+		public void ListView_InstantiateItemTemplate_NoItemTemplate ()
+		{
+			var lvp = new ListViewPoker ();
+			lvp.DoInstantiateItemTemplate (new Control (), 0);
+		}
+		
+		[Test]
+		public void ListView_InstantiateEmptyDataTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.EmptyData);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateEmptyDataTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.EmptyData);
+		}
+		
+		[Test]
+		public void ListView_InstantiateEmptyItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.EmptyItem);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateEmptyItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.EmptyItem);
+		}
+
+		[Test]
+		public void ListView_InstantiateGroupSeparatorTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.GroupSeparator);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateGroupSeparatorTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.GroupSeparator);
+		}
+
+		[Test]
+		public void ListView_InstantiateGroupTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.Group);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateGroupTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.Group);
+		}
+
+		[Test]
+		public void ListView_InstantiateInsertItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.InsertItem);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateInsertItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.InsertItem);
+		}
+
+		[Test]
+		public void ListView_InstantiateItemSeparatorTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.ItemSeparator);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateItemSeparatorTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.ItemSeparator);
+		}
+
+		[Test]
+		public void ListView_InstantiateItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.Item);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.Item);
+		}
+
+		[Test]
+		public void ListView_InstantiateEditItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.EditItem);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateEditItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.EditItem);
+		}
+
+		[Test]
+		public void ListView_InstantiateAlternatingItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.AlternatingItem);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateAlternatingItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.AlternatingItem);
+		}
+
+		[Test]
+		public void ListView_InstantiateSelectedItemTemplate ()
+		{
+			DoInstantiateCall (ListViewItemTemplate.SelectedItem);
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_InstantiateSelectedItemTemplate_NullContainer ()
+		{
+			DoInstantiateContainerNullCall (ListViewItemTemplate.SelectedItem);
+		}
+		
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void ListView_FindPlaceholder_NullContainer ()
+		{
+			var lvp = new ListViewPoker ();
+			Control control;
+
+			control = lvp.DoFindPlaceholder ("somePlaceholder", null);
+		}
+		
 		[Test]
 		[ExpectedException (typeof (ArgumentOutOfRangeException))]
 		public void ListView_SetPageProperties_Parameters1 ()
@@ -298,6 +1043,47 @@ namespace Tests.System.Web.UI.WebControls
 			ListViewPoker lvp = new ListViewPoker ();
 			lvp.DoSetPageProperties (0, 0, false);
 		}
+		
+		[Test]
+		public void ListView_Edit ()
+		{
+			WebTest t = new WebTest ("ListViewTest.aspx");
+			t.Invoker = PageInvoker.CreateOnInit (ListView_Edit_OnInit);
+			t.Run ();
+
+			FormRequest fr = new FormRequest(t.Response, "form1");
+#if DOT_NET
+			fr.Controls.Add ("ListView1$ctrl0$ctl03$EditButton");
+			fr.Controls.Add ("ListView1$ctrl6$ctrl7$CapitalTextBox");
+			fr.Controls.Add ("ListView1$ctrl6$ctrl7$IDTextBox");
+			fr.Controls.Add ("ListView1$ctrl6$ctrl7$NameTextBox");
+			fr.Controls.Add ("ListView1$ctrl6$ctrl7$PopulationTextBox");
+			fr.Controls ["ListView1$ctrl0$ctl03$EditButton"].Value = "Edit";
+#else
+			fr.Controls.Add ("ListView1$ctl13$EditButton");
+			fr.Controls.Add ("ListView1$ctl51$CapitalTextBox");
+			fr.Controls.Add ("ListView1$ctl51$IDTextBox");
+			fr.Controls.Add ("ListView1$ctl51$NameTextBox");
+			fr.Controls.Add ("ListView1$ctl51$PopulationTextBox");
+			fr.Controls ["ListView1$ctl13$EditButton"].Value = "Edit";
+#endif
+			t.Request = fr;
+			
+			EventRecorder events = new EventRecorder();
+			t.UserData = events;
+			t.Run ();
+			
+			Console.WriteLine ("recorded events:");
+			events = t.UserData as EventRecorder;
+			foreach (string e in events)
+				Console.WriteLine ("\t{0}", e);
+		}
+
+		public static void ListView_Edit_OnInit (Page p)
+		{
+			ListViewPoker poker = p.FindControl ("ListView1") as ListViewPoker;
+			poker.SetEventRecorder (WebTest.CurrentTest.UserData as EventRecorder);
+		}
 	}
 }
 #endif

+ 4 - 0
mcs/class/System.Web.Extensions/Test/code/ChangeLog

@@ -0,0 +1,4 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* CountryCollection.cs, Country.cs: added
+

+ 42 - 0
mcs/class/System.Web.Extensions/Test/code/Country.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace TestCode
+{
+    public class Country
+    {
+        public Country(int id, string name, string capital, double population)
+        {
+            ID = id;
+            Name = name;
+            Capital = capital;
+            Population = population;
+        }
+
+        public int ID
+        {
+            get;
+            set;
+        }
+
+        public string Name
+        {
+            get;
+            set;
+        }
+
+        public string Capital
+        {
+            get;
+            set;
+        }
+
+        public double Population
+        {
+            get;
+            set;
+        }
+    }
+}

+ 131 - 0
mcs/class/System.Web.Extensions/Test/code/CountryCollection.cs

@@ -0,0 +1,131 @@
+using System;
+using System.Collections.Generic;
+
+namespace TestCode
+{
+    public class CountryCollection
+    {
+        static List<Country> db;
+        static CountryCollection()
+        {
+            db = new List<Country>();
+
+            db.Add(new Country(1, "Poland", "Warsaw", 38116000.0));
+            db.Add(new Country(2,"Portugal", "Lisbon", 10617575.0));
+            db.Add(new Country(3,"Australia", "Canberra", 21468700.0));
+            db.Add(new Country(4,"Austria", "Vienna", 8316487.0));
+            db.Add(new Country(5,"Belgium", "Brussels", 10666866.0));
+            db.Add(new Country(6,"Brazil", "Brasilia", 190132630.0));
+            db.Add(new Country(7,"China", "Bejing", 1321000000.0));
+            db.Add(new Country(8,"Chad", "N'Djamena", 10780600.0));
+            db.Add(new Country(9,"Venezuela", "Caracas", 28199822.0));
+            db.Add(new Country(10,"Vietnam", "Hanoi", 86116559.0));
+            db.Add(new Country(11,"New Zealand", "Wellington", 4268000.0));
+            db.Add(new Country(12,"Nigeria", "Abuja", 148000000.0));
+            db.Add(new Country(13,"Oman", "Muscat", 2577000.0));
+            db.Add(new Country(14,"Quatar", "Doha", 1450000.0));
+            db.Add(new Country(15,"Denmark", "Copenhagen", 5505995.0));
+            db.Add(new Country(16,"Dominican Republic", "Santo Domingo de Guzman", 9904000.0));
+            db.Add(new Country(17,"France", "Paris", 64473140.0));
+            db.Add(new Country(18,"United States of America", "Washington", 305619000.0));
+            db.Add(new Country(19,"Latvia", "Riga", 2270700.0));
+        }
+
+        public List<Country> GetCountries(string sortExpression)
+        {
+            var ret = new List<Country>();
+            ret.AddRange(db);
+            ret.Sort(new CountryComparer(sortExpression));
+
+            return ret;
+        }
+
+        public int Update(int id, string name, string capital, double population)
+        {
+            if (String.IsNullOrEmpty(name))
+                return 0;
+
+            int updated = 0;
+            foreach (Country c in db)
+            {
+                if (c.ID != id)
+                    continue;
+                updated++;
+                c.Name = name;
+                c.Capital = capital;
+                c.Population = population;
+            }
+
+            return updated;
+        }
+
+        public int Insert(int id, string name, string capital, double population)
+        {
+            if (String.IsNullOrEmpty(name))
+                return 0;
+
+            db.Add(new Country(id, name, capital, population));
+            return 1;
+        }
+
+        public int Delete(int id)
+        {
+            var toDelete = new List<Country> ();
+            foreach (Country c in db)
+            {
+                if (c.ID != id)
+                    continue;
+                toDelete.Add(c);
+            }
+
+            foreach (Country c in toDelete)
+                db.Remove(c);
+
+            return toDelete.Count;
+        }
+    }
+
+    sealed class CountryComparer : IComparer<Country>
+    {
+        string sortProperty;
+        bool descending;
+
+        public CountryComparer(string sortExpression)
+        {
+            descending = sortExpression.ToLowerInvariant().EndsWith(" desc");
+            if (descending)
+            {
+                sortProperty = sortExpression.Substring(0, sortExpression.Length - 5);
+            }
+            else
+            {
+                if (sortExpression.ToLowerInvariant().EndsWith(" asc"))
+                    sortProperty = sortExpression.Substring(0, sortExpression.Length - 4);
+                else
+                    sortProperty = sortExpression;
+            }
+        }
+
+        public int Compare(Country a, Country b)
+        {
+            int retVal = 0;
+            switch (sortProperty)
+            {
+                case "Name":
+                    retVal = String.Compare(a.Name, b.Name, StringComparison.InvariantCultureIgnoreCase);
+                    break;
+                case "Capital":
+                    retVal = String.Compare(a.Capital, b.Capital, StringComparison.InvariantCultureIgnoreCase);
+                    break;
+                case "Population":
+                    retVal = (int)(a.Population - b.Population);
+                    break;
+            }
+
+            if (descending)
+                return retVal;
+            return retVal * -1;
+        }
+    }
+
+}

+ 4 - 0
mcs/class/System.Web.Extensions/Test/resources/ChangeLog

@@ -0,0 +1,4 @@
+2008-11-19  Marek Habersack  <[email protected]>
+
+	* ListViewTest.aspx, ListViewSort.aspx, Web.mono.config: added
+

+ 16 - 0
mcs/class/System.Web.Extensions/Test/resources/ListViewSort.aspx

@@ -0,0 +1,16 @@
+<%@ Page Language="C#" AutoEventWireUp="true" %>
+<%@ Register Assembly="System.Web.Extensions_test_net_2_0" Namespace="Tests.System.Web.UI.WebControls" TagPrefix="tc" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" >
+  <head id="Head1" runat="server"><title>Untitled Page</title></head>
+  <body>
+    <form id="form1" runat="server">
+      <div><%= MonoTests.stand_alone.WebHarness.HtmlDiff.BEGIN_TAG %>
+	<tc:ListViewPoker runat="server">
+	  
+	</tc:ListView>
+	<%= MonoTests.stand_alone.WebHarness.HtmlDiff.END_TAG %>
+      </div>
+    </form>
+  </body>
+</html>

+ 197 - 0
mcs/class/System.Web.Extensions/Test/resources/ListViewTest.aspx

@@ -0,0 +1,197 @@
+<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
+<%@ Register Assembly="System.Web.Extensions_test_net_2_0" Namespace="Tests.System.Web.UI.WebControls" TagPrefix="t" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+    <title></title>
+</head>
+<body>
+    <form id="form1" runat="server">
+    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
+        SelectMethod="GetCountries" TypeName="TestCode.CountryCollection" 
+        SortParameterName="sortExpression" UpdateMethod="Update" 
+        DeleteMethod="Delete" InsertMethod="Insert">
+        <DeleteParameters>
+            <asp:Parameter Name="id" Type="Int32" />
+        </DeleteParameters>
+        <UpdateParameters>
+            <asp:Parameter Name="id" Type="Int32" />
+            <asp:Parameter Name="name" Type="String" />
+            <asp:Parameter Name="capital" Type="String" />
+            <asp:Parameter Name="population" Type="Double" />
+        </UpdateParameters>
+        <SelectParameters>
+            <asp:Parameter Name="sortExpression" Type="String" />
+        </SelectParameters>
+        <InsertParameters>
+            <asp:Parameter Name="id" Type="Int32" />
+            <asp:Parameter Name="name" Type="String" />
+            <asp:Parameter Name="capital" Type="String" />
+            <asp:Parameter Name="population" Type="Double" />
+        </InsertParameters>
+    </asp:ObjectDataSource>
+    
+    <div>
+        <t:ListViewPoker ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" InsertItemPosition="LastItem">
+            <ItemTemplate>
+                <tr style="">
+                    <td>
+                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
+                            Text="Delete" />
+                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
+                        <asp:Button ID="SelectButton" runat="server" CommandName="Select" Text="Select" />
+                    </td>
+                    <td>
+                        <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="CapitalLabel" runat="server" Text='<%# Eval("Capital") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="PopulationLabel" runat="server" 
+                            Text='<%# Eval("Population") %>' />
+                    </td>
+                </tr>
+            </ItemTemplate>
+            <AlternatingItemTemplate>
+                <tr style="">
+                    <td>
+                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
+                            Text="Delete" />
+                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
+                        <asp:Button ID="SelectButton" runat="server" CommandName="Select" Text="Select" />
+                    </td>
+                    <td>
+                        <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="CapitalLabel" runat="server" Text='<%# Eval("Capital") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="PopulationLabel" runat="server" 
+                            Text='<%# Eval("Population") %>' />
+                    </td>
+                </tr>
+            </AlternatingItemTemplate>
+            <EmptyDataTemplate>
+                <table runat="server" 
+                    
+                    style="">
+                    <tr>
+                        <td>
+                            No data was returned.</td>
+                    </tr>
+                </table>
+            </EmptyDataTemplate>
+            <InsertItemTemplate>
+                <tr style="">
+                    <td>
+                        <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
+                            Text="Insert" />
+                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
+                            Text="Clear" />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="CapitalTextBox" runat="server" Text='<%# Bind("Capital") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="PopulationTextBox" runat="server" 
+                            Text='<%# Bind("Population") %>' />
+                    </td>
+                </tr>
+            </InsertItemTemplate>
+            <LayoutTemplate>
+                <table runat="server">
+                    <tr runat="server">
+                        <td runat="server">
+                            <table ID="itemPlaceholderContainer" runat="server" border="0" 
+                                style="">
+                                <tr runat="server" style="">
+                                    <th runat="server">
+                                    </th>
+                                    <th runat="server">
+                                        ID</th>
+                                    <th runat="server">
+                                        Name</th>
+                                    
+                                    <th runat="server">
+                                        Capital</th>
+                                    <th runat="server">
+                                        Population</th>
+                                    
+                                </tr>
+                                <tr ID="itemPlaceholder" runat="server">
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                    <tr runat="server">
+                        <td runat="server" 
+                            style="">
+                        </td>
+                    </tr>
+                </table>
+            </LayoutTemplate>
+            <EditItemTemplate>
+                <tr style="">
+                    <td>
+                        <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
+                            Text="Update" />
+                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
+                            Text="Cancel" />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="CapitalTextBox" runat="server" Text='<%# Bind("Capital") %>' />
+                    </td>
+                    <td>
+                        <asp:TextBox ID="PopulationTextBox" runat="server" 
+                            Text='<%# Bind("Population") %>' />
+                    </td>
+                </tr>
+            </EditItemTemplate>
+            <SelectedItemTemplate>
+                <tr style="">
+                    <td>
+                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
+                            Text="Delete" />
+                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
+                    </td>
+                    <td>
+                        <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="CapitalLabel" runat="server" Text='<%# Eval("Capital") %>' />
+                    </td>
+                    <td>
+                        <asp:Label ID="PopulationLabel" runat="server" 
+                            Text='<%# Eval("Population") %>' />
+                    </td>
+                </tr>
+            </SelectedItemTemplate>
+        </t:ListViewPoker>
+    </div>
+    </form>
+</body>
+</html>

+ 120 - 0
mcs/class/System.Web.Extensions/Test/resources/Web.mono.config

@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<!-- 
+    Note: As an alternative to hand editing this file you can use the 
+    web admin tool to configure settings for your application. Use
+    the Website->Asp.Net Configuration option in Visual Studio.
+    A full list of settings and comments can be found in 
+    machine.config.comments usually located in 
+    \Windows\Microsoft.Net\Framework\v2.x\Config 
+-->
+<configuration>
+	<configSections>
+		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
+					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
+				</sectionGroup>
+			</sectionGroup>
+		</sectionGroup>
+	</configSections>
+	<appSettings/>
+	<connectionStrings/>
+	<system.web>
+		<!-- 
+            Set compilation debug="true" to insert debugging 
+            symbols into the compiled page. Because this 
+            affects performance, set this value to true only 
+            during development.
+        -->
+		<compilation debug="true">
+			<assemblies>
+				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+			</assemblies>
+		</compilation>
+		<!--
+            The <authentication> section enables configuration 
+            of the security authentication mode used by 
+            ASP.NET to identify an incoming user. 
+        -->
+		<authentication mode="Windows"/>
+		<!--
+            The <customErrors> section enables configuration 
+            of what to do if/when an unhandled error occurs 
+            during the execution of a request. Specifically, 
+            it enables developers to configure html error pages 
+            to be displayed in place of a error stack trace.
+
+        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
+            <error statusCode="403" redirect="NoAccess.htm" />
+            <error statusCode="404" redirect="FileNotFound.htm" />
+        </customErrors>
+        -->
+		<pages>
+			<controls>
+				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+				<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+			</controls>
+		</pages>
+		<httpHandlers>
+			<remove verb="*" path="*.asmx"/>
+			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
+		</httpHandlers>
+		<httpModules>
+			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+		</httpModules>
+	</system.web>
+	<system.codedom>
+		<compilers>
+			<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+				<providerOption name="CompilerVersion" value="v3.5"/>
+				<providerOption name="WarnAsError" value="false"/>
+			</compiler>
+			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+				<providerOption name="CompilerVersion" value="v3.5"/>
+				<providerOption name="OptionInfer" value="true"/>
+				<providerOption name="WarnAsError" value="false"/>
+			</compiler>
+		</compilers>
+	</system.codedom>
+	<!-- 
+        The system.webServer section is required for running ASP.NET AJAX under Internet
+        Information Services 7.0.  It is not necessary for previous version of IIS.
+    -->
+	<system.webServer>
+		<validation validateIntegratedModeConfiguration="false"/>
+		<modules>
+			<remove name="ScriptModule"/>
+			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+		</modules>
+		<handlers>
+			<remove name="WebServiceHandlerFactory-Integrated"/>
+			<remove name="ScriptHandlerFactory"/>
+			<remove name="ScriptHandlerFactoryAppServices"/>
+			<remove name="ScriptResource"/>
+			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+			<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+		</handlers>
+	</system.webServer>
+	<runtime>
+		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+			<dependentAssembly>
+				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
+				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
+			</dependentAssembly>
+			<dependentAssembly>
+				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
+				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
+			</dependentAssembly>
+		</assemblyBinding>
+	</runtime>
+</configuration>