2 // Tests for System.Web.UI.WebControls.CallBackTest.cs
5 // Yoni Klein (yonik@mainsoft.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections.Generic;
33 using NUnit.Framework;
34 using MonoTests.SystemWeb.Framework;
36 using System.Threading;
38 namespace MonoTests.System.Web.UI.WebControls
43 public class CallBackTest
48 WebTest.CopyResource (GetType (), "CallbackTest1.aspx", "CallbackTest1.aspx");
49 WebTest.CopyResource (GetType (), "CallbackTest2.aspx", "CallbackTest2.aspx");
53 public void SetupTestCase ()
59 [Category("NunitWeb")]
60 [Category ("NotDotNet")] // for dot-net use __CALLBACKID insted __CALLBACKTARGET and __CALLBACKARGUMENT insted __CALLBACKPARAM
61 public void CallBackResulrValues ()
63 WebTest t = new WebTest ("CallbackTest1.aspx");
64 string html = t.Run ();
65 PageDelegates pd = new PageDelegates ();
67 t.Invoker = new PageInvoker (pd);
69 FormRequest fr = new FormRequest (t.Response, "form1");
70 fr.Controls.Add ("__EVENTTARGET");
71 fr.Controls.Add ("__EVENTARGUMENT");
72 fr.Controls.Add ("__CALLBACKID");
73 fr.Controls.Add ("__CALLBACKPARAM");
74 fr.Controls["__EVENTTARGET"].Value = "";
75 fr.Controls["__EVENTARGUMENT"].Value = "";
76 fr.Controls ["__CALLBACKID"].Value = "__Page";
77 fr.Controls ["__CALLBACKPARAM"].Value = "monitor";
82 // Into result string the last 2 variables shows if events been done
83 // first - RaiseCallbackEvent
84 // second - GetCallbackResult
86 if (html.IndexOf ("12|true|true") < 0)
87 Assert.Fail ("CallBack#1");
89 fr.Controls["__EVENTTARGET"].Value = "";
90 fr.Controls["__EVENTARGUMENT"].Value = "";
91 fr.Controls ["__CALLBACKID"].Value = "__Page";
92 fr.Controls ["__CALLBACKPARAM"].Value = "laptop";
97 // Into result string the last 2 variables shows if events been done
98 // first - RaiseCallbackEvent
99 // second - GetCallbackResult
101 if (html.IndexOf ("10|true|true") < 0)
102 Assert.Fail ("CallBack#2");
105 public static void Load (Page p)
107 Assert.AreEqual (true, p.IsCallback, "IsCallbackDoneFail");
111 [Category ("NunitWeb")]
112 [Category ("NotDotNet")] // for dot-net use __CALLBACKID insted __CALLBACKTARGET and __CALLBACKARGUMENT insted __CALLBACKPARAM
113 public void CallBackFlow ()
115 WebTest t = new WebTest ("CallbackTest2.aspx");
116 string html = t.Run ();
118 PageDelegates pd = new PageDelegates ();
119 pd.Load = callBackFlow_Load;
120 t.Invoker = new PageInvoker (pd);
122 FormRequest fr = new FormRequest (t.Response, "form1");
123 fr.Controls.Add ("__EVENTTARGET");
124 fr.Controls.Add ("__EVENTARGUMENT");
125 fr.Controls.Add ("__CALLBACKID");
126 fr.Controls.Add ("__CALLBACKPARAM");
127 fr.Controls["__EVENTTARGET"].Value = "";
128 fr.Controls["__EVENTARGUMENT"].Value = "";
129 fr.Controls ["__CALLBACKID"].Value = "__Page";
130 fr.Controls ["__CALLBACKPARAM"].Value = "";
135 // GetCallbackResult return string contained all flow functions name
137 if (html.IndexOf ("|PreInit|Init|InitComplete|PreLoad|Load|LoadComplete|RaiseCallbackEvent|GetCallbackResult") < 0)
138 Assert.Fail ("CallBackPageFlow");
141 public static void callBackFlow_Load (Page p)
143 Assert.AreEqual (true, p.IsCallback, "IsCallbackDoneFail");
146 [TestFixtureTearDown]
147 public void Unload ()