Author: yonik
Date: 2006-11-29 07:15:58 -0500 (Wed, 29 Nov 2006)
New Revision: 68659
Added:
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ListControlPage.aspx
Modified:
trunk/mcs/class/System.Web/ChangeLog
trunk/mcs/class/System.Web/Makefile
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs
Log:
New tests for ListControl 2.0 + resource ListControlPage.aspx
Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog 2006-11-29 12:14:23 UTC (rev
68658)
+++ trunk/mcs/class/System.Web/ChangeLog 2006-11-29 12:15:58 UTC (rev
68659)
@@ -1,3 +1,7 @@
+2006-11-29 Yoni Klain <[EMAIL PROTECTED]>
+
+ * MakeFile added new resources ListControlPage.aspx for
ListControlTest.cs
+
2006-11-28 Miguel de Icaza <[EMAIL PROTECTED]>
* Rationalize the user of MonoTODOs.
Modified: trunk/mcs/class/System.Web/Makefile
===================================================================
--- trunk/mcs/class/System.Web/Makefile 2006-11-29 12:14:23 UTC (rev 68658)
+++ trunk/mcs/class/System.Web/Makefile 2006-11-29 12:15:58 UTC (rev 68659)
@@ -128,6 +128,7 @@
Test/mainsoft/NunitWebResources/PageCultureTest.aspx \
Test/mainsoft/NunitWebResources/adapters.browser \
Test/mainsoft/NunitWebResources/NoEventValidation.aspx \
+ Test/mainsoft/NunitWebResources/ListControlPage.aspx \
Test/mainsoft/MainsoftWebTest/nunitweb_config.xml
NUNIT_RESOURCE_FILES = $(TEST_RESOURCE_FILES)
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2006-11-29 12:14:23 UTC (rev 68658)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2006-11-29 12:15:58 UTC (rev 68659)
@@ -1,3 +1,7 @@
+2006-11-27 Yoni Klain <[EMAIL PROTECTED]>
+
+ * ListControlTest.cs: added new test for 2.0
+
2006-11-29 Vladimir Krasnov <[EMAIL PROTECTED]>
* SqlDataSourceDerbyTest.cs: fixed connection on db init
Modified:
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs
===================================================================
---
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs
2006-11-29 12:14:23 UTC (rev 68658)
+++
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ListControlTest.cs
2006-11-29 12:15:58 UTC (rev 68659)
@@ -36,6 +36,8 @@
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
+using MonoTests.stand_alone.WebHarness;
+using MonoTests.SystemWeb.Framework;
namespace MonoTests.System.Web.UI.WebControls {
@@ -79,14 +81,109 @@
{
return TagKey;
}
+
+ public new void OnSelectedIndexChanged (EventArgs e)
+ {
+ base.OnSelectedIndexChanged (e);
+ }
+
+ public new void OnTextChanged (EventArgs e)
+ {
+ base.OnTextChanged (e);
+ }
+
+ public new void VerifyMultiSelect ()
+ {
+ base.VerifyMultiSelect ();
+ }
+
#endif
}
[TestFixture]
- public class ListControlTest {
+ public class ListControlTest
+ {
+ #region help_class_for_addattributetorender
+ class Poker : ListControl
+ {
+ public void TrackState ()
+ {
+ TrackViewState ();
+ }
+ public object SaveState ()
+ {
+ return SaveViewState ();
+ }
+
+ public void LoadState (object state)
+ {
+ LoadViewState (state);
+ }
+
+ public object ViewStateValue (string name)
+ {
+ return ViewState[name];
+ }
+
+
+ public string Render ()
+ {
+ StringWriter sw = new StringWriter ();
+ sw.NewLine = "\n";
+ HtmlTextWriter writer = new HtmlTextWriter (sw);
+ base.Render (writer);
+ return writer.InnerWriter.ToString ();
+ }
+#if NET_2_0
+ ArrayList Databound ()
+ {
+ ArrayList list = new ArrayList ();
+ list.Add (1);
+ list.Add (2);
+ list.Add (3);
+ return list;
+ }
+
+ public HtmlTextWriterTag GetTagKey ()
+ {
+ return TagKey;
+ }
+
+ protected override void AddAttributesToRender
(HtmlTextWriter writer)
+ {
+ writer.AddAttribute
(HtmlTextWriterAttribute.Type, "MyType");
+ writer.AddAttribute
(HtmlTextWriterAttribute.Name, "MyName");
+ writer.AddAttribute
(HtmlTextWriterAttribute.Value, "MyValue");
+ base.AddAttributesToRender (writer);
+ }
+
+ protected override void PerformDataBinding (IEnumerable
dataSource)
+ {
+ base.PerformDataBinding (Databound());
+ }
+
+ protected override void PerformSelect ()
+ {
+ base.PerformSelect ();
+ SelectedIndex = 0;
+ }
+
+ public new void SetPostDataSelection(int selectedItem)
+ {
+ base.SetPostDataSelection(selectedItem);
+ }
+#endif
+ }
+ #endregion
private Hashtable changed = new Hashtable ();
+ [TestFixtureSetUp]
+ public void SetUp ()
+ {
+ WebTest.CopyResource (GetType (),
"ListControlPage.aspx", "ListControlPage.aspx");
+ }
+
[Test]
public void DefaultProperties ()
{
@@ -106,10 +203,214 @@
Assert.IsFalse (p.AppendDataBoundItems, "A11");
Assert.AreEqual (p.Text, "", "A12");
Assert.AreEqual (p.GetTagKey(),
HtmlTextWriterTag.Select, "A13");
+ Assert.AreEqual (false, p.AppendDataBoundItems, "A14");
+ Assert.AreEqual (false, p.CausesValidation, "A15");
#endif
}
+#if NET_2_0
[Test]
+ public void AddAttributesToRender ()
+ {
+ Poker p = new Poker ();
+ ListItem foo = new ListItem ("foo");
+ ListItem bar = new ListItem ("bar");
+ p.Items.Add (foo);
+ p.Items.Add (bar);
+#region orig
+ string orig = "<select type=\"MyType\" name=\"MyName\"
value=\"MyValue\"><option value=\"foo\">foo</option><option
value=\"bar\">bar</option></select>";
+#endregion
+ string html = p.Render ();
+
HtmlDiff.AssertAreEqual(orig,html,"AddAttributesToRender failed");
+ }
+
+ [Test]
+ public void AppendDataBoundItems ()
+ {
+ ListControlPoker p = new ListControlPoker ();
+ ListItem foo = new ListItem ("foo");
+ ListItem bar = new ListItem ("bar");
+ p.Items.Add (foo);
+ p.Items.Add (bar);
+ Assert.AreEqual (2, p.Items.Count, "Before databound");
+ p.AppendDataBoundItems = true; // Not to clear list
before databind
+ p.DataSource = Databound ();
+ p.DataBind ();
+ Assert.AreEqual (5, p.Items.Count, "After databound");
+ p.AppendDataBoundItems = false; // To clear list before
databind
+ p.DataBind ();
+ Assert.AreEqual (3, p.Items.Count, "Clear list and
databound");
+ }
+
+ ArrayList Databound ()
+ {
+ ArrayList list = new ArrayList ();
+ list.Add (1);
+ list.Add (2);
+ list.Add (3);
+ return list;
+ }
+
+ [Test]
+ [Category ("NunitWeb")]
+ public void CausesValidation_ValidationGroup ()
+ {
+ WebTest t = new WebTest ("ListControlPage.aspx");
+ string str = t.Run ();
+ FormRequest fr = new FormRequest (t.Response, "form1");
+ fr.Controls.Add ("__EVENTTARGET");
+ fr.Controls.Add ("__EVENTARGUMENT");
+ fr.Controls.Add ("ListBox1");
+ fr.Controls["__EVENTTARGET"].Value = "ListBox1";
+ fr.Controls["__EVENTARGUMENT"].Value = "";
+ fr.Controls["ListBox1"].Value = "2";
+ t.Request = fr;
+ string html = t.Run ();
+
+ if (html.IndexOf ("Validate_validation_group") == -1)
+ Assert.Fail ("Validate not created");
+ if (html.IndexOf ("MyValidationGroup") == -1)
+ Assert.Fail ("Wrong validation group");
+ }
+
+ [Test]
+ public void OnTextChanged ()
+ {
+ ListControlPoker p = new ListControlPoker ();
+ p.TextChanged += new EventHandler (p_TextChanged);
+ Assert.AreEqual (false, eventTextChanged, "Before");
+ p.OnTextChanged (new EventArgs ());
+ Assert.AreEqual (true, eventTextChanged, "After");
+ }
+
+ bool eventTextChanged;
+ void p_TextChanged (object sender, EventArgs e)
+ {
+ eventTextChanged = true;
+ }
+
+ [Test]
+ public void PerformDataBind_PerformSelect ()
+ {
+ Poker p = new Poker ();
+ p.DataBind ();
+ string html = p.Render ();
+#region #1
+ string orig = @"<select type=""MyType"" name=""MyName""
value=""MyValue"">
+ <option selected=""selected""
value=""1"">1</option>
+ <option value=""2"">2</option>
+ <option value=""3"">3</option>
+ </select>";
+#endregion
+ HtmlDiff.AssertAreEqual (orig, html, "PerformDataBind");
+ }
+
+ [Test]
+ [Category("NotWorking")] //Not implemented
+ public void SetPostDataSelection ()
+ {
+ Poker p = new Poker ();
+ ListItem foo = new ListItem ("foo");
+ ListItem bar = new ListItem ("bar");
+ p.Items.Add (foo);
+ p.Items.Add (bar);
+ p.SetPostDataSelection (1);
+ Assert.AreEqual (1, p.SelectedIndex,
"SetPostDataSelection");
+ }
+
+ [Test]
+ public void Text ()
+ {
+ Poker p = new Poker ();
+ ListItem foo = new ListItem ("foo");
+ ListItem bar = new ListItem ("bar");
+ p.Items.Add (foo);
+ p.Items.Add (bar);
+ Assert.AreEqual (string.Empty, p.Text, "Text#1");
+ p.SelectedIndex = 1;
+ Assert.AreEqual ("bar", p.Text, "Text#2");
+ }
+
+ #region HelpListForMultiple
+ class PokerL : ListBox
+ {
+ public PokerL ()
+ {
+ InitializeMyListBox ();
+ }
+ private void InitializeMyListBox ()
+ {
+ // Add items to the ListBox.
+ Items.Add ("A");
+ Items.Add ("C");
+ Items.Add ("E");
+ Items.Add ("F");
+ Items.Add ("G");
+ Items.Add ("D");
+ Items.Add ("B");
+
+ // Set the SelectionMode to select multiple
items.
+ SelectionMode = ListSelectionMode.Multiple;
+
+ Items[0].Selected = true;
+ Items[2].Selected = true;
+ }
+
+ public void TrackState ()
+ {
+ TrackViewState ();
+ }
+
+ public object SaveState ()
+ {
+ return SaveViewState ();
+ }
+
+ public void LoadState (object state)
+ {
+ LoadViewState (state);
+ }
+
+ public object ViewStateValue (string name)
+ {
+ return ViewState[name];
+ }
+
+ public string Render ()
+ {
+ StringWriter sw = new StringWriter ();
+ sw.NewLine = "\n";
+ HtmlTextWriter writer = new HtmlTextWriter (sw);
+ base.Render (writer);
+ return writer.InnerWriter.ToString ();
+ }
+ }
+ #endregion
+ [Test]
+ public void Multiple ()
+ {
+ PokerL p = new PokerL ();
+ Assert.AreEqual (true, p.Items[0].Selected,
"MultipleSelect#1");
+ Assert.AreEqual (true, p.Items[2].Selected,
"MultipleSelect#2");
+ string html = p.Render ();
+ #region origin
+ string orig = @"<select size=""4""
multiple=""multiple"">
+ <option selected=""selected""
value=""A"">A</option>
+ <option value=""C"">C</option>
+ <option selected=""selected""
value=""E"">E</option>
+ <option value=""F"">F</option>
+ <option value=""G"">G</option>
+ <option value=""D"">D</option>
+ <option value=""B"">B</option>
+ </select>";
+ #endregion
+ HtmlDiff.AssertAreEqual (orig, html,
"MultipleSelect#3");
+ }
+#endif
+
+
+
+ [Test]
public void CleanProperties ()
{
ListControlPoker p = new ListControlPoker ();
@@ -568,6 +869,23 @@
Assert.AreEqual(null, p.SelectedItem, "SelectedItem");
Assert.AreEqual(-1, p.SelectedIndex, "SelectedIndex");
}
+#if NET_2_0
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (HttpException))]
+ public void VerifyMultiSelect_Exception ()
+ {
+ ListControlPoker p = new ListControlPoker ();
+ p.VerifyMultiSelect ();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown ()
+ {
+ WebTest.Unload ();
+ }
+#endif
+
}
}
Added:
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ListControlPage.aspx
===================================================================
---
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ListControlPage.aspx
2006-11-29 12:14:23 UTC (rev 68658)
+++
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ListControlPage.aspx
2006-11-29 12:15:58 UTC (rev 68659)
@@ -0,0 +1,32 @@
+<%@ Page Language="C#" AutoEventWireup="true" %>
+<%@ Import Namespace="MonoTests.SystemWeb.Framework" %>
+
+<!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>
+ <script runat="server">
+ public override void Validate (string validationGroup)
+ {
+ Response.Write ("Validate_validation_group" + " " +
validationGroup);
+ }
+
+ public override void Validate ()
+ {
+ Response.Write ("Validate");
+ }
+</script>
+
+</head>
+<body>
+ <form id="form1" runat="server">
+ <div>
+ <asp:ListBox ID="ListBox1" runat="server" CausesValidation="true"
ValidationGroup="MyValidationGroup" AutoPostBack="true">
+ <asp:ListItem>1</asp:ListItem>
+ <asp:ListItem>2</asp:ListItem>
+ </asp:ListBox>
+ </div>
+ </form>
+</body>
+</html>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches