Author: yonik
Date: 2006-08-28 05:10:52 -0400 (Mon, 28 Aug 2006)
New Revision: 64464

Added:
   trunk/mcs/class/System.Web/Test/System.Web.UI/ClientScriptManagerTest.cs
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ClientScript.js
   
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest1.aspx
   
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest2.aspx
Modified:
   trunk/mcs/class/System.Web/ChangeLog
   trunk/mcs/class/System.Web/Makefile
   trunk/mcs/class/System.Web/System.Web_test.dll.sources
   trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
Log:
Add new test ClientScriptManagerTest.cs and resources: ClientScript.js , 
EventValidationTest1.aspx ,EventValidationTest2.aspx

Modified: trunk/mcs/class/System.Web/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/ChangeLog        2006-08-28 08:16:05 UTC (rev 
64463)
+++ trunk/mcs/class/System.Web/ChangeLog        2006-08-28 09:10:52 UTC (rev 
64464)
@@ -1,3 +1,11 @@
+2006-08-28 Yoni Klain <[EMAIL PROTECTED]>
+
+    * System.Web_test.dll.sources: add new 
\System.Web.UI\ClientScriptManagerTest.cs
+    * MakeFile: add new resources for ClientScriptMenagerTest.cs
+    Test/mainsoft/NunitWebResources/EventValidationTest2.aspx \
+       Test/mainsoft/NunitWebResources/EventValidationTest1.aspx \
+       Test/mainsoft/NunitWebResources/ClientScript.js \
+
 2006-08-27 Hagit Yidov <[EMAIL PROTECTED]>
 
        * TreeNodeBindingCollectionTest.cs: New test was added
@@ -7,10 +15,6 @@
        * TreeNodeTest.cs: New test was added
        * TreeViewTest.cs: Test was updated
 
-=======
-=======
-<<<<<<< .mine
-<<<<<<< .mine
 2006-08-10 Hagit Yidov <[EMAIL PROTECTED]>
 
        * ImageMapTest.cs: New test was added
@@ -20,8 +24,6 @@
        * RectangleHotSpot.cs: New test was added
        * PolygonHotSpot.cs: New test was added
 
-=======
-=======
 2006-08-23 Igor Zelmanovich <[EMAIL PROTECTED]>
 
        * MenuTest.cs: added tests 

Modified: trunk/mcs/class/System.Web/Makefile
===================================================================
--- trunk/mcs/class/System.Web/Makefile 2006-08-28 08:16:05 UTC (rev 64463)
+++ trunk/mcs/class/System.Web/Makefile 2006-08-28 09:10:52 UTC (rev 64464)
@@ -102,6 +102,9 @@
        Test/mainsoft/NunitWebResources/WebLogin.config \
        Test/mainsoft/NunitWebResources/CallbackTest1.aspx \
        Test/mainsoft/NunitWebResources/CallbackTest2.aspx \
+       Test/mainsoft/NunitWebResources/EventValidationTest2.aspx \
+       Test/mainsoft/NunitWebResources/EventValidationTest1.aspx \
+       Test/mainsoft/NunitWebResources/ClientScript.js \
        Test/mainsoft/MainsoftWebTest/nunitweb_config.xml 
 
 NUNIT_RESOURCE_FILES = $(TEST_RESOURCE_FILES)

Modified: trunk/mcs/class/System.Web/System.Web_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-08-28 
08:16:05 UTC (rev 64463)
+++ trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-08-28 
09:10:52 UTC (rev 64464)
@@ -85,6 +85,7 @@
 System.Web.UI/AttributeCollectionTest.cs
 System.Web.UI/ChtmlTextWriterTest.cs
 System.Web.UI/CleanHtmlTextWriter.cs
+System.Web.UI/ClientScriptManagerTest.cs
 System.Web.UI/ControlTest.cs
 System.Web.UI/ControlCollectionTest.cs
 System.Web.UI/DataBindingCollectionTest.cs

Modified: trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog     2006-08-28 
08:16:05 UTC (rev 64463)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/ChangeLog     2006-08-28 
09:10:52 UTC (rev 64464)
@@ -1,3 +1,7 @@
+2006-08-28  Klain Yoni   <[EMAIL PROTECTED]>
+
+       * ClientScriptManagerTest.cs: new test.
+
 2006-04-26  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * ControlTest.cs : fix r59834: both the build and the coding style.

Added: trunk/mcs/class/System.Web/Test/System.Web.UI/ClientScriptManagerTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI/ClientScriptManagerTest.cs    
2006-08-28 08:16:05 UTC (rev 64463)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI/ClientScriptManagerTest.cs    
2006-08-28 09:10:52 UTC (rev 64464)
@@ -0,0 +1,576 @@
+//
+// Tests for System.Web.UI.ClientScriptManagerTest.cs
+//
+// Author:
+//     Yoni Klein ([EMAIL PROTECTED])
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+#if NET_2_0
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using NUnit.Framework;
+using MonoTests.stand_alone.WebHarness;
+using MonoTests.SystemWeb.Framework;
+using System.Text;
+using System.Threading;
+
+namespace MonoTests.System.Web.UI.WebControls
+{
+
+       public class MyPage : Page, ICallbackEventHandler
+       {
+               #region ICallbackEventHandler Members
+
+               public string GetCallbackResult ()
+               {
+                       throw new Exception ("The method or operation is not 
implemented.");
+               }
+
+               public void RaiseCallbackEvent (string eventArgument)
+               {
+                       throw new Exception ("The method or operation is not 
implemented.");
+               }
+
+               #endregion
+       }
+
+       [TestFixture]
+       public class ClientScriptManagerTest
+       {
+               [TestFixtureSetUp]
+               public void Set_Up ()
+               {
+#if DOT_NET
+                       WebTest.CopyResource (GetType (), 
"MonoTests.System.Web.UI.WebControls.Resources.EventValidationTest1.aspx", 
"EventValidationTest1.aspx");
+                       WebTest.CopyResource (GetType (), 
"MonoTests.System.Web.UI.WebControls.Resources.EventValidationTest2.aspx", 
"EventValidationTest2.aspx");
+#else
+                       WebTest.CopyResource (GetType (), 
"EventValidationTest1.aspx", "EventValidationTest1.aspx");
+                       WebTest.CopyResource (GetType (), 
"EventValidationTest2.aspx", "EventValidationTest2.aspx");
+#endif
+               }
+
+               [SetUp]
+               public void SetupTestCase ()
+               {
+                       Thread.Sleep (100);
+               }
+
+               [Test]
+               [Category("NotWorking")]
+               public void ClientScriptManager_GetCallbackEventReference_1 ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       StringBuilder context1 = new StringBuilder ();
+                       context1.Append ("function ReceiveServerData1(arg, 
context)");
+                       context1.Append ("{");
+                       context1.Append ("Message1.innerText =  arg;");
+                       context1.Append ("value1 = arg;");
+                       context1.Append ("}");
+
+                       // Define callback references.
+                       String cbReference = cs.GetCallbackEventReference (p, 
"arg",
+                           "ReceiveServerData1", context1.ToString ());
+                       Assert.AreEqual 
("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function 
ReceiveServerData1(arg, context){Message1.innerText =  arg;value1 = 
arg;},null,false)", cbReference, "GetCallbackEventReferenceFail1");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_GetCallbackEventReference_2 ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       StringBuilder context1 = new StringBuilder ();
+                       context1.Append ("function ReceiveServerData1(arg, 
context)");
+                       context1.Append ("{");
+                       context1.Append ("Message1.innerText =  arg;");
+                       context1.Append ("value1 = arg;");
+                       context1.Append ("}");
+
+                       // Define callback references.
+                       String cbReference = cs.GetCallbackEventReference (p, 
"arg",
+                           "ReceiveServerData1", context1.ToString (), true);
+                       Assert.AreEqual 
("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function 
ReceiveServerData1(arg, context){Message1.innerText =  arg;value1 = 
arg;},null,true)", cbReference, "GetCallbackEventReferenceFail2");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_GetCallbackEventReference_3 ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       StringBuilder context1 = new StringBuilder ();
+                       context1.Append ("function ReceiveServerData1(arg, 
context)");
+                       context1.Append ("{");
+                       context1.Append ("Message1.innerText =  arg;");
+                       context1.Append ("value1 = arg;");
+                       context1.Append ("}");
+
+                       // Define callback references.
+                       String cbReference = cs.GetCallbackEventReference (p, 
"arg",
+                           "ReceiveServerData1", context1.ToString (), 
"ErrorCallback", false);
+                       Assert.AreEqual 
("WebForm_DoCallback('__Page',arg,ReceiveServerData1,function 
ReceiveServerData1(arg, context){Message1.innerText =  arg;value1 = 
arg;},ErrorCallback,false)", cbReference, "GetCallbackEventReferenceFail3");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_GetPostBackEventReference_1 ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String result = cs.GetPostBackEventReference (new 
PostBackOptions (p, "args"));
+                       Assert.AreEqual ("__doPostBack('__Page','args')", 
result, "GetPostBackEventReference#1");
+               }
+
+               [Test]
+               public void ClientScriptManager_GetPostBackEventReference_2 ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String result = cs.GetPostBackEventReference (p, 
"args");
+                       Assert.AreEqual ("__doPostBack('__Page','args')", 
result, "GetPostBackEventReference#2");
+               }
+
+               [Test]
+               public void ClientScriptManager_GetPostBackClientHyperlink ()
+               {
+                       MyPage p = new MyPage ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String hyperlink = cs.GetPostBackClientHyperlink (p, 
"args");
+                       Assert.AreEqual 
("javascript:__doPostBack('__Page','args')", hyperlink, 
"GetPostBackClientHyperlink");
+               }
+
+               [Test]
+               [Category("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_GetWebResourceUrl ()
+               {
+                       string html = new WebTest (PageInvoker.CreateOnLoad 
(GetWebResourceUrlLoad)).Run();
+               }
+
+               public static void GetWebResourceUrlLoad (Page p)
+               {
+                       ClientScriptManager cs = p.ClientScript;
+                       String cbReference = cs.GetWebResourceUrl (typeof 
(MonoTests.System.Web.UI.WebControls.ClientScriptManagerTest), 
"ClientScript.js");
+                       if (cbReference.IndexOf("/NunitWeb/WebResource.axd?")<0)
+                               Assert.Fail ("GetWebResourceUrlFail");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_IsClientScriptBlockRegistered ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String csname2 = "ButtonClickScript";
+                       Type cstype = p.GetType ();
+                       StringBuilder cstext2 = new StringBuilder ();
+                       cstext2.Append ("<script type=text/javascript> function 
DoClick() {");
+                       cstext2.Append ("alert('Text from client script.')} 
</");
+                       cstext2.Append ("script>");
+                       cs.RegisterClientScriptBlock (cstype, csname2, 
cstext2.ToString ());
+                       Assert.AreEqual (true, cs.IsClientScriptBlockRegistered 
(csname2), "ClientScriptBlockRegisterFail#1");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_IsRegisterClientScriptInclude ()
+               {
+                       Page p = new Page ();
+                       String csname = "ButtonClickScript";
+                       String csurl = "ClientScript.js";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterClientScriptInclude (cstype, csname, csurl);
+                       bool registry = cs.IsClientScriptIncludeRegistered 
(csname);
+                       Assert.AreEqual (true, registry, 
"RegisterClientScriptIncludeFail");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_IsRegisterOnSubmitStatement ()
+               {
+                       Page p = new Page ();
+                       String csname = "ButtonClickScript";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterClientScriptInclude (cstype, csname, 
"document.write('Text from OnSubmit statement');");
+                       bool registry = cs.IsClientScriptIncludeRegistered 
(csname);
+                       Assert.AreEqual (true, registry, 
"RegisterClientScriptIncludeFail");
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_RegisterOnSubmitStatement ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterOnSubmitStatement));
+                       string html = t.Run ();
+                       if (html.IndexOf ("WebForm_OnSubmit()") < 0)
+                               Assert.Fail ("RegisterOnSubmitStatement");
+               }
+
+               public static void RegisterOnSubmitStatement (Page p)
+               {
+                       String csname = "OnSubmitScript";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String cstext = "document.write('Text from OnSubmit 
statement');";
+                       cs.RegisterOnSubmitStatement (cstype, csname, cstext);
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               public void ClientScriptManager_RegisterClientScriptInclude ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterClientScriptInclude));
+                       string html = t.Run ();
+                       if (html.IndexOf ("script_include.js") < 0)
+                               Assert.Fail ("RegisterClientScriptIncludeFail");
+               }
+
+               public static void RegisterClientScriptInclude (Page p)
+               {
+                       String csname = "ButtonClickScript";
+                       String csurl = "script_include.js";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterClientScriptInclude (cstype, csname, csurl);
+               }
+
+               [Test]
+               [Category("NunitWeb")]
+               public void ClientScriptManager_ClientScriptBlockRegister()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(ClientScriptBlockRegister));
+                       string html = t.Run ();
+                       if( html.IndexOf("DoClick()") < 0)
+                               Assert.Fail ("ClientScriptBlockRegisterFail#2");
+               }
+
+               public static void ClientScriptBlockRegister (Page p)
+               {
+                       ClientScriptManager cs = p.ClientScript;
+                       String csname2 = "ButtonClickScript";
+                       Type cstype = p.GetType ();
+                       StringBuilder cstext2 = new StringBuilder ();
+                       cstext2.Append ("<script type=text/javascript> function 
DoClick() {");
+                       cstext2.Append ("alert('Text from client script.')} 
</");
+                       cstext2.Append ("script>");
+                       cs.RegisterClientScriptBlock (cstype, csname2, 
cstext2.ToString ());
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_IsRegisterStartupScript ()
+               {
+                       Page p = new Page ();
+                       String csname1 = "PopupScript";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String cstext1 = "alert('Hello World');";
+                       cs.RegisterStartupScript (cstype, csname1, cstext1);
+                       Assert.AreEqual 
(true,cs.IsStartupScriptRegistered(csname1) , "StartupScriptRegisteredFail");   
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               public void ClientScriptManager_RegisterStartupScript ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterStartupScript));
+                       string html = t.Run ();
+                       if (html.IndexOf ("alert('Hello World');") < 0)
+                               Assert.Fail ("RegisterStartupScriptFail#1");
+               }
+
+               public static void RegisterStartupScript (Page p)
+               {
+                       String csname1 = "PopupScript";
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String cstext1 = "alert('Hello World');";
+                       cs.RegisterStartupScript (cstype, csname1, 
cstext1,true);
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               public void ClientScriptManager_RegisterArrayDeclaration ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterArrayDeclaration));
+                       string html = t.Run ();
+                       if (html.IndexOf ("var MyArray =  new Array(\"1\", 
\"2\", \"text\");") < 0)
+                               Assert.Fail ("RegisterArrayDeclarationFail#1");
+               }
+
+               public static void RegisterArrayDeclaration (Page p)
+               {
+                       Type cstype = p.GetType ();
+                       ClientScriptManager cs = p.ClientScript;
+
+                       String arrName = "MyArray";
+                       String arrValue = "\"1\", \"2\", \"text\"";
+
+                       // Register the array with the Page class.
+                       cs.RegisterArrayDeclaration (arrName, arrValue);
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_RegisterExpandAttribute ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterExpandAttribute));
+                       string html = t.Run ();
+                       if (html.IndexOf ("Message.title = \"New title from 
client script.\"") < 0)
+                               Assert.Fail ("RegisterExpandAttributeFail");
+               }
+
+               public static void RegisterExpandAttribute (Page p)
+               {
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterExpandoAttribute ("Message", "title", "New 
title from client script.", true);
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_RegisterHiddenField ()
+               {
+                       WebTest t = new WebTest (PageInvoker.CreateOnLoad 
(RegisterHiddenField));
+                       string html = t.Run ();
+                       if (html.IndexOf ("<input type=\"hidden\" 
name=\"MyHiddenField\" id=\"MyHiddenField\" value=\"3\" />") < 0)
+                               Assert.Fail ("RegisterHiddenFieldFail");
+               }
+
+               public static void RegisterHiddenField (Page p)
+               {
+                       ClientScriptManager cs = p.ClientScript;
+                       // Define the hidden field name and initial value.
+                       String hiddenName = "MyHiddenField";
+                       String hiddenValue = "3";
+                       // Register the hidden field with the Page class.
+                       cs.RegisterHiddenField (hiddenName, hiddenValue);
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_RegisterForEventValidation_1 ()
+               {
+                       WebTest t = new WebTest ("EventValidationTest1.aspx");
+                       string html = t.Run ();
+                       
+                       FormRequest fr = new FormRequest (t.Response, "form1");
+                       fr.Controls.Add ("__EVENTTARGET");
+                       fr.Controls.Add ("__EVENTARGUMENT");
+                       fr.Controls.Add ("__CALLBACKID");
+                       fr.Controls.Add ("__CALLBACKPARAM");
+                       fr.Controls["__EVENTTARGET"].Value = "";
+                       fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls["__CALLBACKID"].Value = "__Page";
+                       t.Request = fr;
+                       html = t.Run ();
+
+                       if(html.IndexOf("Correct event raised callback.")<0)
+                               Assert.Fail 
("RegisterForEventValidationFail#1");
+               }
+
+               [Test]
+               [Category ("NunitWeb")]
+               [Category ("NotWorking")]
+               public void ClientScriptManager_RegisterForEventValidation_2 ()
+               {
+                       WebTest t = new WebTest ("EventValidationTest2.aspx");
+                       string html = t.Run ();
+                       
+                       FormRequest fr = new FormRequest (t.Response, "form1");
+                       fr.Controls.Add ("__EVENTTARGET");
+                       fr.Controls.Add ("__EVENTARGUMENT");
+                       fr.Controls.Add ("__CALLBACKID");
+                       fr.Controls.Add ("__CALLBACKPARAM");
+                       fr.Controls["__EVENTTARGET"].Value = "";
+                       fr.Controls["__EVENTARGUMENT"].Value = "";
+                       fr.Controls["__CALLBACKID"].Value = "__Page";
+                       t.Request = fr;
+                       html = t.Run ();
+
+                       if (html.IndexOf ("Incorrect event raised callback.") < 
0)
+                               Assert.Fail 
("RegisterForEventValidationFail#2");
+               }
+
+               // Expected Exceptions
+
+               // TODO --> No RegisterForEventValidation Method
+               //[Test]
+               //[ExpectedException (typeof (InvalidOperationException))]
+               //public void 
ClientScriptManager_RegisterForEventValidationException ()
+               //{
+               //        Page p = new Page ();
+               //        ClientScriptManager cs = p.ClientScript;
+               //        cs.RegisterForEventValidation ("ID", "args");
+               //}
+
+               // TODO --> No ValidateEvent Method
+               //[Test]
+               //[ExpectedException (typeof (ArgumentException))]
+               //public void ClientScriptManager_ValidateEventException_1 ()
+               //{
+               //        Page p = new Page ();
+               //        ClientScriptManager cs = p.ClientScript;
+               //        cs.ValidateEvent ("Exception");
+               //}
+
+               // TODO --> No ValidateEvent Method             
+               //[Test]
+               //[ExpectedException (typeof (ArgumentException))]
+               //public void ClientScriptManager_ValidateEventException_2 ()
+               //{
+               //        Page p = new Page ();
+               //        ClientScriptManager cs = p.ClientScript;
+               //        cs.ValidateEvent ("Exception", "args");
+               //}
+
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_IsRegisterStartupScriptException ()
+               {
+                       Page p = new Page ();
+                       String csname1 = "PopupScript";
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterStartupScript (null, csname1, "");
+               }
+               
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_RegisterOnSubmitStatementException ()
+               {
+                       Page p = new Page ();
+                       String csname = "OnSubmitScript";
+                       ClientScriptManager cs = p.ClientScript;
+                       String cstext = "document.write('Text from OnSubmit 
statement');";
+                       cs.RegisterOnSubmitStatement (null, csname, cstext);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_RegisterClientScriptIncludeException_1 ()
+               {
+                       Page p = new Page ();
+                       String csname = "ButtonClickScript";
+                       Type cstype = p.GetType ();
+                       String csurl = "";
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterClientScriptInclude (null, csname, csurl);
+                       bool registry = cs.IsClientScriptIncludeRegistered 
(csname);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_RegisterClientScriptIncludeException_2 ()
+               {
+                       Page p = new Page ();
+                       String csname = "ButtonClickScript";
+                       String csurl = "ClientScript.js";
+                       ClientScriptManager cs = p.ClientScript;
+                       cs.RegisterClientScriptInclude (null, csname, csurl);
+                       bool registry = cs.IsClientScriptIncludeRegistered 
(csname);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_ClientScriptBlockRegisterException_2 ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String csname2 = "ButtonClickScript";
+                       cs.RegisterClientScriptBlock (null, csname2, "");
+                       Assert.AreEqual (true, cs.IsClientScriptBlockRegistered 
(csname2), "ClientScriptBlockRegisterFail");
+               }
+
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientScriptManager_GetWebResourceUrlException_1 ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String cbReference = cs.GetWebResourceUrl (null, 
"test");
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void ClientScriptManager_GetWebResourceUrlException_2 ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+                       String cbReference = cs.GetWebResourceUrl (typeof 
(ClientScriptManagerTest), "");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void 
ClientScriptManager_GetCallbackEventReferenceException_1 ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+
+                       // Define callback references.
+                       String cbReference = cs.GetCallbackEventReference (p, 
"arg",
+                           "ReceiveServerData1", "");
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void 
ClientScriptManager_GetCallbackEventReferenceException_2 ()
+               {
+                       Page p = new Page ();
+                       ClientScriptManager cs = p.ClientScript;
+
+                       // Define callback references.
+                       String cbReference = cs.GetCallbackEventReference 
(null, "arg",
+                           "ReceiveServerData1", "");
+               }
+
+               [TestFixtureTearDown]
+               public void Unload()
+               {
+                       WebTest.Unload();
+               }
+       }
+}
+#endif
+
+

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ClientScript.js
===================================================================
--- trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ClientScript.js  
2006-08-28 08:16:05 UTC (rev 64463)
+++ trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/ClientScript.js  
2006-08-28 09:10:52 UTC (rev 64464)
@@ -0,0 +1,2 @@
+function DoClick() {Form1.Message.value='Text from include script.'}
+

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest1.aspx
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest1.aspx
        2006-08-28 08:16:05 UTC (rev 64463)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest1.aspx
        2006-08-28 09:10:52 UTC (rev 64464)
@@ -0,0 +1,85 @@
+<%@ Page Language="C#"  %>
+<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
+<!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"; >
+<script runat="server" >
+    
+    string _eventName = "Test";    
+    string _cbMessage = "";
+    // Define method that processes the callbacks on server.
+    public void RaiseCallbackEvent(String eventArgument)
+    {
+        try {
+            this.ClientScript.ValidateEvent (_eventName, this.ToString ());
+            _cbMessage = "Correct event raised callback.";
+        }
+        catch (Exception ex) {
+            _cbMessage = "Incorrect event raised callback.";
+        }
+    }
+
+    // Define method that returns callback result.
+    public string GetCallbackResult()
+    {
+        return _cbMessage;
+    }
+
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (!IsPostBack)
+        {
+            ClientScriptManager cs = Page.ClientScript;
+            String cbReference = cs.GetCallbackEventReference ("'" +
+               Page.UniqueID + "'", "arg", "ReceiveServerData", "",
+               "ProcessCallBackError", false);
+            String callbackScript = "function CallTheServer(arg, context) {" +
+               cbReference + "; }";
+            cs.RegisterClientScriptBlock (this.GetType (), "CallTheServer",
+               callbackScript, true);
+        }
+    }
+    
+    
+    protected override void Render(HtmlTextWriter writer)
+    {
+        this.ClientScript.RegisterForEventValidation("Test", this.ToString());
+        base.Render(writer);
+    }
+
+</script>
+
+<script type="text/javascript">
+var value1 = new Date();
+function ReceiveServerData(arg, context)
+{
+    Message.innerText = arg;
+    Label1.innerText = "Callback completed at " + value1;
+    value1 = new Date();
+}
+function ProcessCallBackError(arg, context)
+{
+    Message.innerText = 'An error has occurred.';
+}
+</script>
+
+<html  >
+<head id="Head1" runat="server">
+    <title>CallBack Event Validation Example</title>
+</head>
+<body>
+    <form id="Form1" runat="server">
+    <div>
+      Callback result: <span id="Message"></span>
+      <br /> <br />
+      <input type="button"
+             id="button1" 
+             runat="server"
+             value="ClientCallBack" 
+             onclick="CallTheServer(value1, null )"/>
+      <br /> <br />
+      <asp:Label id="Label1" runat="server"/>
+    </div>
+    </form>
+</body>
+</html>

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest2.aspx
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest2.aspx
        2006-08-28 08:16:05 UTC (rev 64463)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWebResources/EventValidationTest2.aspx
        2006-08-28 09:10:52 UTC (rev 64464)
@@ -0,0 +1,85 @@
+<%@ Page Language="C#"  %>
+<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
+<!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"; >
+<script runat="server" >
+    
+    string _eventName = "Fail";    
+    string _cbMessage = "";
+    // Define method that processes the callbacks on server.
+    public void RaiseCallbackEvent(String eventArgument)
+    {
+        try {
+            this.ClientScript.ValidateEvent (_eventName, this.ToString ());
+            _cbMessage = "Correct event raised callback.";
+        }
+        catch (Exception ex) {
+            _cbMessage = "Incorrect event raised callback.";
+        }
+    }
+
+    // Define method that returns callback result.
+    public string GetCallbackResult()
+    {
+        return _cbMessage;
+    }
+
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        if (!IsPostBack)
+        {
+            ClientScriptManager cs = Page.ClientScript;
+            String cbReference = cs.GetCallbackEventReference ("'" +
+               Page.UniqueID + "'", "arg", "ReceiveServerData", "",
+               "ProcessCallBackError", false);
+            String callbackScript = "function CallTheServer(arg, context) {" +
+               cbReference + "; }";
+            cs.RegisterClientScriptBlock (this.GetType (), "CallTheServer",
+               callbackScript, true);
+        }
+    }
+    
+    
+    protected override void Render(HtmlTextWriter writer)
+    {
+        this.ClientScript.RegisterForEventValidation("Test", this.ToString());
+        base.Render(writer);
+    }
+
+</script>
+
+<script type="text/javascript">
+var value1 = new Date();
+function ReceiveServerData(arg, context)
+{
+    Message.innerText = arg;
+    Label1.innerText = "Callback completed at " + value1;
+    value1 = new Date();
+}
+function ProcessCallBackError(arg, context)
+{
+    Message.innerText = 'An error has occurred.';
+}
+</script>
+
+<html  >
+<head id="Head1" runat="server">
+    <title>CallBack Event Validation Example</title>
+</head>
+<body>
+    <form id="Form1" runat="server">
+    <div>
+      Callback result: <span id="Message"></span>
+      <br /> <br />
+      <input type="button"
+             id="button1" 
+             runat="server"
+             value="ClientCallBack" 
+             onclick="CallTheServer(value1, null )"/>
+      <br /> <br />
+      <asp:Label id="Label1" runat="server"/>
+    </div>
+    </form>
+</body>
+</html>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to