Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / class / System.Web / Test / System.Web.UI / PostBackOptionsTest.cs
1 //
2 // Tests for System.Web.UI.PostBackOptions.cs 
3 //
4 // Author:
5 //      Igor Zelmanovich (igorz@mainsoft.com)
6 //
7
8 //
9 // Copyright (C) 2006 Mainsoft, Inc (http://www.mainsoft.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using NUnit.Framework;
32 using System;
33 using System.IO;
34 using System.Globalization;
35 using System.Web;
36 using System.Web.UI;
37 using System.Web.UI.WebControls;
38 using System.Collections;
39
40 namespace MonoTests.System.Web.UI
41 {
42         [TestFixture]
43         public class PostBackOptionsTest
44         {
45                 [Test]
46                 public void Constructors () {
47                         Control c = new WebControl(HtmlTextWriterTag.A);
48                         c.Page = new Page ();
49                         PostBackOptions options=new PostBackOptions(c);
50                         Assert.IsFalse (options.PerformValidation);
51                         Assert.IsFalse (options.AutoPostBack);
52                         Assert.IsFalse (options.TrackFocus);
53                         Assert.IsTrue (options.ClientSubmit);
54                         // MSDN: The default value is true, BUT FALSE
55                         Assert.IsFalse (options.RequiresJavaScriptProtocol);
56                         // MSDN: The default value is an empty string (""), BUT NULL
57                         Assert.AreEqual (null, options.Argument);
58                         // MSDN: The default value is an empty string (""), BUT NULL
59                         Assert.AreEqual (null, options.ActionUrl);
60                         // MSDN: The default value is an empty string (""), BUT NULL
61                         Assert.AreEqual (null, options.ValidationGroup);
62
63                         options = new PostBackOptions (c, null);
64                         Assert.IsFalse (options.PerformValidation);
65                         Assert.IsFalse (options.AutoPostBack);
66                         Assert.IsFalse (options.TrackFocus);
67                         Assert.IsTrue (options.ClientSubmit);
68                         Assert.IsFalse (options.RequiresJavaScriptProtocol);
69                         Assert.AreEqual (null, options.Argument);
70                         Assert.AreEqual (null, options.ActionUrl);
71                         Assert.AreEqual (null, options.ValidationGroup);
72
73                         options = new PostBackOptions (c, null, null, false, false, false, false, false, null);
74                         Assert.IsFalse (options.PerformValidation);
75                         Assert.IsFalse (options.AutoPostBack);
76                         Assert.IsFalse (options.TrackFocus);
77                         Assert.IsFalse (options.ClientSubmit);
78                         Assert.IsFalse (options.RequiresJavaScriptProtocol);
79                         Assert.AreEqual (null, options.Argument);
80                         Assert.AreEqual (null, options.ActionUrl);
81                         Assert.AreEqual (null, options.ValidationGroup);
82
83                         options = new PostBackOptions (c, "ARG");
84                         Assert.IsFalse (options.PerformValidation);
85                         Assert.IsFalse (options.AutoPostBack);
86                         Assert.IsFalse (options.TrackFocus);
87                         Assert.IsTrue (options.ClientSubmit);
88                         Assert.IsFalse (options.RequiresJavaScriptProtocol);
89                         Assert.AreEqual ("ARG", options.Argument);
90                         Assert.AreEqual (null, options.ActionUrl);
91                         Assert.AreEqual (null, options.ValidationGroup);
92
93                         options = new PostBackOptions (c, "ARG", "Page.aspx", true, true, false, false, false, "VG");
94                         Assert.IsFalse (options.PerformValidation);
95                         Assert.IsTrue (options.AutoPostBack);
96                         Assert.IsFalse (options.TrackFocus);
97                         Assert.IsFalse (options.ClientSubmit);
98                         Assert.IsTrue (options.RequiresJavaScriptProtocol);
99                         Assert.AreEqual ("ARG", options.Argument);
100                         Assert.AreEqual ("Page.aspx", options.ActionUrl);
101                         Assert.AreEqual ("VG", options.ValidationGroup);
102                 }
103         }
104 }