svn path=/trunk/mcs/; revision=73100
authorYoni Klain <yonik@mono-cvs.ximian.com>
Mon, 19 Feb 2007 09:26:30 +0000 (09:26 -0000)
committerYoni Klain <yonik@mono-cvs.ximian.com>
Mon, 19 Feb 2007 09:26:30 +0000 (09:26 -0000)
mcs/class/System.Web/ChangeLog
mcs/class/System.Web/System.Web_test.dll.sources
mcs/class/System.Web/Test/System.Web.UI.WebControls/BulletedListTest.cs
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangePasswordTest.cs

index 939ad93b239d31f25d544d998d206939642b2edd..f6b1e1c74a9e0785dc2be4b8a7f484ecb433b17a 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-19  YonikKalin  <yonik@mainsoft.com>
+
+       * Add System.Web_test.dll.sources add ChangePasswordTest.cs 
+
 2007-02-18  Eyal Alaluf  <eyala@mainsoft.com>
 
        * run-mono-tests.bat: Add J2EE jar to classpath.
index 5f605d78eca7ea9d9e2b44cc4ffa4c40c700c188..ba867c53924bea5bd3e7d409ad978e212deba7e2 100644 (file)
@@ -145,6 +145,7 @@ System.Web.UI.WebControls/ButtonTest.cs
 System.Web.UI.WebControls/CalendarDayTest.cs
 System.Web.UI.WebControls/CalendarTest.cs
 System.Web.UI.WebControls/CallBackTest.cs
+System.Web.UI.WebControls/ChangePasswordTest.cs
 System.Web.UI.WebControls/CheckBoxFieldTest.cs
 System.Web.UI.WebControls/CheckBoxListTest.cs
 System.Web.UI.WebControls/CheckBoxTest.cs
index d04455d0174a065d0d62486e17f57fa5af715030..e884d2ca32f79ef411f275bf2dd108d3affaa66b 100644 (file)
@@ -37,6 +37,9 @@ using System.Globalization;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;
+using MonoTests.SystemWeb.Framework;
+using MonoTests.stand_alone.WebHarness;
+
 
 namespace MonoTests.System.Web.UI.WebControls
 {
@@ -97,6 +100,12 @@ namespace MonoTests.System.Web.UI.WebControls
        [TestFixture]
        public class BulletedListTest
        {
+               [TestFixtureSetUp]
+               public void SetUp ()
+               {
+                       WebTest.CopyResource (GetType (), "NoEventValidation.aspx", "NoEventValidation.aspx");
+               }
+
                [Test]
                public void BulletedList_DefaultProperties ()
                {
@@ -315,6 +324,61 @@ namespace MonoTests.System.Web.UI.WebControls
                        Assert.AreEqual (true, clicked, "BeforeClick");
                }
 
+               //PostBack raise event
+               [Test]
+               [Category ("NunitWeb")]
+               public void BulletedList_PostBackEvent ()
+               {
+                       WebTest t = new WebTest ("NoEventValidation.aspx");
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEvent));
+                       string html = t.Run ();
+                       if (html.IndexOf ("Test_Item") < 0)
+                               Assert.Fail ("BulletedList not created");
+
+                       FormRequest fr = new FormRequest (t.Response, "form1");
+                       fr.Controls.Add ("__EVENTTARGET");
+                       fr.Controls.Add ("__EVENTARGUMENT");
+                       fr.Controls["__EVENTTARGET"].Value = "BL";
+                       fr.Controls["__EVENTARGUMENT"].Value = "0";
+                       t.Request = fr;
+                       html = t.Run ();
+                       if (t.UserData == null || (string) t.UserData != "list_Click Fired_0")
+                               Assert.Fail ("list_Click Not Fired");
+               }
+
+               #region _PostBackEvent_helper
+               public static void _PostBackEvent (Page p)
+               {
+                       BulletedList list = new BulletedList ();
+                       list.ID = "BL";
+                       list.DisplayMode = BulletedListDisplayMode.LinkButton;
+                       list.Items.Add (new ListItem ("Test_Item", "Test_Value", true));
+                       list.Click += new BulletedListEventHandler (list_Click);
+                       p.Controls.Add (list);
+               }
+
+               static void list_Click (object sender, BulletedListEventArgs e)
+               {
+                       WebTest.CurrentTest.UserData = "list_Click Fired_" + e.Index.ToString();
+               }
+               #endregion
+
+               [Test]
+               [ExpectedException (typeof (HttpException))]
+               public void VerifyMultiSelectTest ()
+               {
+                       VerifyMultiSelectBulletedList list = new VerifyMultiSelectBulletedList ();
+                       list.VerifyMultiSelect ();
+               }
+       
+
+               [TestFixtureTearDown]
+               public void TearDown ()
+               {
+                       WebTest.Unload ();
+               }
+
+               // Help class for DS creation
                private void AddListItems (PokerBulletedList b)
                {
                        ListItem item1 = new ListItem ("Item1", "Item1");
@@ -338,14 +402,6 @@ 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();
-        }
        }
 }
 
index 387b5601e181c99e5fd6241cfed5d2665126f173..53153bd379410058fc0b18683dad628a387087de 100644 (file)
@@ -1,3 +1,7 @@
+2007-02-19  yonik <yonik@mainsoft.com>
+
+     * ChangePasswordTest.cs,BulletedListTest.cs: Add new tests for PostbackEvents 
+     
 2007-02-19 Igor Zelmanovich <igorz@mainsoft.com>
 
        * GridViewTest:
index f958fca0a4d6ca55be23ae06fc3b6c13a69c5301..db700ff88513f6319f59a3a0ffea8e1eabc200ca 100644 (file)
@@ -41,7 +41,8 @@ using System.Text.RegularExpressions;
 using MonoTests.SystemWeb.Framework;
 using MonoTests.stand_alone.WebHarness;
 
-using NUnit.Framework;
+using NUnit.Framework;\r
+using System.Collections.Specialized;
 
 namespace MonoTests.System.Web.UI.WebControls
 {
@@ -566,31 +567,232 @@ namespace MonoTests.System.Web.UI.WebControls
 
                        test.Request = fr;
                        html = test.Run ();
-
-                       //
-                       // The following fails with the following exception:
-//System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Security.Membership ---&gt; System.Configuration.ConfigurationErrorsException: Could not find type: MonoTests.SystemWeb.Framework.FakeMembershipProvider () ()
-//  at System.Web.Configuration.ProvidersHelper.InstantiateProvider (System.Configuration.ProviderSettings providerSettings, System.Type providerType) [0x00000]
-//  at System.Web.Configuration.ProvidersHelper.InstantiateProviders (System.Configuration.ProviderSettingsCollection configProviders, System.Configuration.Provider.ProviderCollection providers, System.Type providerType) [0x00000]
-//  at System.Web.Security.Membership..cctor () [0x00000] --- End of inner exception stack trace ---
-//
-//  at &lt;0x00000&gt; &lt;unknown method&gt;
-//  at System.Web.UI.WebControls.ChangePassword.InitMemberShipProvider () [0x00000]
-//  at System.Web.UI.WebControls.ChangePassword.get_MembershipProviderInternal () [0x00000]
-//  at System.Web.UI.WebControls.ChangePassword.ProcessChangePasswordEvent (System.Web.UI.WebControls.CommandEventArgs args) [0x00000]
-//  at System.Web.UI.WebControls.ChangePassword.OnBubbleEvent (System.Object source, System.EventArgs e) [0x00000]
-//  at System.Web.UI.Control.RaiseBubbleEvent (System.Object source, System.EventArgs args) [0x00000]
-//  at System.Web.UI.WebControls.Button.OnCommand (System.Web.UI.WebControls.CommandEventArgs e) [0x00000]
-//  at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) [0x00000]
-//  at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (System.String eventArgument) [0x00000]
-//  at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, System.String eventArgument) [0x00000]
-//  at System.Web.UI.Page.RaisePostBackEvents () [0x00000]
-//  at System.Web.UI.Page.InternalProcessRequest () [0x00000]
-//  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] </pre></code>^M
-//
                        Assert.IsTrue (html.IndexOf ("has been changed") > 0, "GetPassword");
-               }
-
+               }\r
+\r
+               [Test]\r
+               [Category ("NotWorking")]\r
+               [Category ("NunitWeb")]\r
+               public void PostBackEventCancel ()\r
+               {\r
+                       WebTest t = new WebTest ();\r
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEventCancel));\r
+                       string html = t.Run ();\r
+                       if (html.IndexOf ("Change Your Password") < 0)\r
+                               Assert.Fail ("ChangePassword not created");\r
+                       FormRequest fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CurrentPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$NewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CancelPushButton");\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$CancelPushButton"].Value = "Cancel";\r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+                       if (t.UserData == null || t.UserData.ToString () != "CancelButtonClick")\r
+                               Assert.Fail ("CancelButtonClick event not fired");\r
+               }\r
+\r
+               public static void _PostBackEventCancel (Page p)\r
+               {\r
+                       ChangePassword w = CreateTestControl (p);\r
+                       w.CancelButtonClick += new EventHandler (w_CancelButtonClick);\r
+               }\r
+\r
+               static void w_CancelButtonClick (object sender, EventArgs e)\r
+               {\r
+                       WebTest.CurrentTest.UserData = "CancelButtonClick";\r
+               }\r
+\r
+\r
+               [Test]\r
+               [Category ("NotWorking")]\r
+               [Category ("NunitWeb")]\r
+               public void PostBackEventChanging ()\r
+               {\r
+                       WebTest t = new WebTest ();\r
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEventChanging));\r
+                       string html = t.Run ();\r
+                       if (html.IndexOf ("Change Your Password") < 0)\r
+                               Assert.Fail ("ChangePassword not created");\r
+                       FormRequest fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+                       \r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CurrentPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$NewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton");\r
+                       \r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$CurrentPassword"].Value = "a";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$NewPassword"].Value = "1";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword"].Value = "1";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton"].Value = "Change+Password";\r
+                               \r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+                       if (t.UserData == null || t.UserData.ToString () != "ChangingPassword")\r
+                               Assert.Fail ("ChangingPassword event not fired");\r
+               }\r
+\r
+               public static void _PostBackEventChanging (Page p)\r
+               {\r
+                       ChangePassword w = CreateTestControl (p);\r
+                       w.DisplayUserName = false;\r
+                       w.ChangingPassword +=new LoginCancelEventHandler(w_ChangingPassword);\r
+               }\r
+\r
+               public static void w_ChangingPassword (object sender, LoginCancelEventArgs e)\r
+               {\r
+                       WebTest.CurrentTest.UserData = "ChangingPassword";\r
+                       e.Cancel = true;\r
+               }\r
+\r
+               [Test]\r
+               [Category ("NotWorking")]\r
+               [Category ("NunitWeb")]\r
+               public void PostBackEventError ()\r
+               {\r
+                       WebTest t = new WebTest ();\r
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEventError));\r
+                       string html = t.Run ();\r
+                       if (html.IndexOf ("Change Your Password") < 0)\r
+                               Assert.Fail ("ChangePassword not created");\r
+                       FormRequest fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$UserName");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CurrentPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$NewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton");\r
+\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$UserName"].Value = "WrongUser";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$CurrentPassword"].Value = "a";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$NewPassword"].Value = "1";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword"].Value = "1";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton"].Value = "Change+Password";\r
+\r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+                       if (t.UserData == null || t.UserData.ToString () != "ChangePasswordError")\r
+                               Assert.Fail ("ChangePasswordError event not fired");\r
+               }\r
+\r
+               public static void _PostBackEventError (Page p)\r
+               {\r
+                       ChangePassword w = CreateTestControl (p);\r
+                       w.ChangePasswordError += new EventHandler (w_ChangePasswordError);\r
+               }\r
+\r
+               public static void w_ChangePasswordError (object sender, EventArgs e)\r
+               {\r
+                       WebTest.CurrentTest.UserData = "ChangePasswordError";\r
+               }\r
+\r
+               \r
+               [Test]\r
+               [Category ("NotWorking")]\r
+               [Category ("NunitWeb")]\r
+               public void PostBackEventChangedPassword ()\r
+               {\r
+                       WebTest t = new WebTest ();\r
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEventChangedPassword));\r
+                       string html = t.Run ();\r
+                       if (html.IndexOf ("Change Your Password") < 0)\r
+                               Assert.Fail ("ChangePassword not created");\r
+                       FormRequest fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CurrentPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$NewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton");\r
+\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$CurrentPassword"].Value = "p@ssword";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$NewPassword"].Value = "123456?";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword"].Value = "123456?";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton"].Value = "Change+Password";\r
+\r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+                       if (t.UserData == null || t.UserData.ToString () != "ChangedPassword")\r
+                               Assert.Fail ("ChangedPassword event not fired");\r
+               }\r
+\r
+               public static void _PostBackEventChangedPassword (Page p)\r
+               {\r
+                       ChangePassword w = CreateTestControl (p);\r
+                       w.DisplayUserName = false;\r
+                       w.ChangedPassword += new EventHandler (w_ChangedPassword);\r
+               }\r
+\r
+               public static void w_ChangedPassword (object sender, EventArgs e)\r
+               {\r
+                       WebTest.CurrentTest.UserData = "ChangedPassword";\r
+               }\r
+\r
+               [Test]\r
+               [Category ("NunitWeb")]\r
+               [Category ("NotWorking")]\r
+               public void PostBackEventContinue ()\r
+               {\r
+                       WebTest t = new WebTest ();\r
+                       t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (_PostBackEventContinue));\r
+                       string html = t.Run ();\r
+                       if (html.IndexOf ("Change Your Password") < 0)\r
+                               Assert.Fail ("ChangePassword not created");\r
+                       FormRequest fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$CurrentPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$NewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword");\r
+                       fr.Controls.Add ("ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton");\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$CurrentPassword"].Value = "p@ssword";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$NewPassword"].Value = "123456?";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ConfirmNewPassword"].Value = "123456?";\r
+                       fr.Controls["ChangePassword1$ChangePasswordContainerID$ChangePasswordPushButton"].Value = "Change+Password";\r
+\r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+                       if (html.IndexOf ("Change Password Complete") < 0)\r
+                               Assert.Fail ("Password has not beeb changed!");\r
+                       \r
+                       fr = new FormRequest (t.Response, "form1");\r
+                       fr.Controls.Add ("__EVENTTARGET");\r
+                       fr.Controls.Add ("__EVENTARGUMENT");\r
+                       fr.Controls.Add ("ChangePassword1$SuccessContainerID$ContinuePushButton");\r
+                       fr.Controls["ChangePassword1$SuccessContainerID$ContinuePushButton"].Value = "Continue";\r
+\r
+                       t.Request = fr;\r
+                       html = t.Run ();\r
+\r
+                       if (t.UserData == null || t.UserData.ToString () != "ContinueButtonClick")\r
+                               Assert.Fail ("ContinueButtonClick event not fired");\r
+               }\r
+\r
+               public static void _PostBackEventContinue (Page p)\r
+               {\r
+                       ChangePassword w = CreateTestControl (p);\r
+                       w.DisplayUserName = false;\r
+                       w.ContinueButtonClick += new EventHandler (w_ContinueButtonClick);\r
+               }\r
+\r
+               public static void w_ContinueButtonClick (object sender, EventArgs e)\r
+               {\r
+                       WebTest.CurrentTest.UserData = "ContinueButtonClick";\r
+               }\r
+\r
+               [TestFixtureTearDown]\r
+               public void TearDown ()\r
+               {\r
+                       WebTest.Unload ();\r
+               }\r
        }
 }