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.
32 using System.Collections.Generic;
34 using NUnit.Framework;
35 using MonoTests.SystemWeb.Framework;
37 using System.Threading;
39 namespace MonoTests.System.Web.UI.WebControls
44 public class CallBackTest
50 WebTest.CopyResource (GetType (), "MonoTests.System.Web.UI.WebControls.Resources.CallbackTest1.aspx", "CallbackTest1.aspx");
51 WebTest.CopyResource (GetType (), "MonoTests.System.Web.UI.WebControls.Resources.CallbackTest2.aspx", "CallbackTest2.aspx");
53 WebTest.CopyResource (GetType (), "CallbackTest1.aspx", "CallbackTest1.aspx");
54 WebTest.CopyResource (GetType (), "CallbackTest2.aspx", "CallbackTest2.aspx");
59 public void SetupTestCase ()
65 [Category("NunitWeb")]
66 [Category("NotWorking")]
67 public void CallBackResulrValues ()
69 WebTest t = new WebTest ("CallbackTest1.aspx");
70 string html = t.Run ();
71 PageDelegates pd = new PageDelegates ();
73 t.Invoker = new PageInvoker (pd);
75 FormRequest fr = new FormRequest (t.Response, "form1");
76 fr.Controls.Add ("__EVENTTARGET");
77 fr.Controls.Add ("__EVENTARGUMENT");
78 fr.Controls.Add ("__CALLBACKID");
79 fr.Controls.Add ("__CALLBACKPARAM");
80 fr.Controls["__EVENTTARGET"].Value = "";
81 fr.Controls["__EVENTARGUMENT"].Value = "";
82 fr.Controls["__CALLBACKID"].Value = "__Page";
83 fr.Controls["__CALLBACKPARAM"].Value = "monitor";
88 // Into result string the last 2 variables shows if events been done
89 // first - RaiseCallbackEvent
90 // second - GetCallbackResult
92 Assert.AreEqual ("0|12|true|true", html, "CallBack#1");
94 fr.Controls["__EVENTTARGET"].Value = "";
95 fr.Controls["__EVENTARGUMENT"].Value = "";
96 fr.Controls["__CALLBACKID"].Value = "__Page";
97 fr.Controls["__CALLBACKPARAM"].Value = "laptop";
102 // Into result string the last 2 variables shows if events been done
103 // first - RaiseCallbackEvent
104 // second - GetCallbackResult
106 Assert.AreEqual ("0|10|true|true", html, "CallBack#2");
109 public static void Load (Page p)
111 Assert.AreEqual (true, p.IsCallback, "IsCallbackDoneFail");
115 [Category ("NunitWeb")]
116 [Category ("NotWorking")]
117 public void CallBackFlow ()
119 WebTest t = new WebTest ("CallbackTest2.aspx");
120 string html = t.Run ();
122 PageDelegates pd = new PageDelegates ();
123 pd.Load = callBackFlow_Load;
124 t.Invoker = new PageInvoker (pd);
126 FormRequest fr = new FormRequest (t.Response, "form1");
127 fr.Controls.Add ("__EVENTTARGET");
128 fr.Controls.Add ("__EVENTARGUMENT");
129 fr.Controls.Add ("__CALLBACKID");
130 fr.Controls.Add ("__CALLBACKPARAM");
131 fr.Controls["__EVENTTARGET"].Value = "";
132 fr.Controls["__EVENTARGUMENT"].Value = "";
133 fr.Controls["__CALLBACKID"].Value = "__Page";
134 fr.Controls["__CALLBACKPARAM"].Value = "";
139 // GetCallbackResult return string contained all flow functions name
141 Assert.AreEqual ("0||PreInit|Init|InitComplete|PreLoad|Load|LoadComplete|RaiseCallbackEvent|GetCallbackResult", html, "CallBackPageFlow");
144 public static void callBackFlow_Load (Page p)
146 Assert.AreEqual (true, p.IsCallback, "IsCallbackDoneFail");
149 [TestFixtureTearDown]
150 public void Unload ()