2 // Tests for System.Web.UI.WebControls.TextBox.cs
5 // Ben Maurer (bmaurer@novell.com)
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
31 using NUnit.Framework;
34 using System.Globalization;
37 using System.Web.UI.WebControls;
39 namespace MonoTests.System.Web.UI.WebControls {
42 public class TextBoxTest {
43 class Poker : TextBox {
44 public new void AddParsedSubObject (object o)
46 base.AddParsedSubObject (o);
49 public void TrackState ()
54 public object SaveState ()
56 foreach (string s in ViewState.Keys)
57 Console.WriteLine ("{0}: {1}", s, ViewState[s]);
59 return SaveViewState ();
62 public void LoadState (object o)
67 public string Render ()
69 StringWriter sw = new StringWriter ();
71 HtmlTextWriter writer = new HtmlTextWriter (sw);
73 return writer.InnerWriter.ToString ();
78 [Category ("NotWorking")]
79 public void MultilineRenderEscape ()
81 Poker t = new Poker ();
82 t.TextMode = TextBoxMode.MultiLine;
83 t.Text = "</textarea>";
85 string exp = "<textarea rows=\"2\" cols=\"20\"></textarea></textarea>";
87 string exp = "<textarea name></textarea></textarea>";
90 Assert.AreEqual (exp, t.Render ());
96 public void ValidationProperties ()
98 Poker t = new Poker ();
101 Assert.AreEqual (false, t.CausesValidation, "A1");
102 Assert.AreEqual ("", t.ValidationGroup, "A2");
104 t.ValidationGroup = "VG";
105 Assert.AreEqual ("VG", t.ValidationGroup, "A3");
107 t.CausesValidation = true;
108 Assert.IsTrue (t.CausesValidation, "A4");
112 public void ViewState ()
114 Poker t = new Poker ();
118 t.ValidationGroup = "VG";
119 t.CausesValidation = true;
121 object s = t.SaveState ();
122 Console.WriteLine ("state = {0}", s == null ? "null" : "not-null");
124 Poker copy = new Poker ();
128 Assert.AreEqual ("VG", copy.ValidationGroup, "A1");
129 Assert.IsTrue (copy.CausesValidation, "A2");
133 [Category ("NotWorking")]
134 public void ValidationRender ()
136 /* test to show that the validation settings
137 * have no effect on downlevel rendering */
138 Poker t = new Poker ();
142 t.ValidationGroup = "VG";
143 t.CausesValidation = true;
144 t.TextMode = TextBoxMode.MultiLine;
146 string exp = "<textarea rows=\"2\" cols=\"20\"></textarea>";
147 Assert.AreEqual (exp, t.Render ());