4.0/2.0 metadata updates + some test updates
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / CheckBoxFieldTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.CheckBoxFieldTest.cs
3 //
4 // Author:
5 //      Yoni Klein (yonik@mainsoft.com)
6 //
7 //
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 //
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:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
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.
28
29
30 #if NET_2_0
31
32
33 using System;
34 using System.Collections.Generic;
35 using System.Text;
36 using System.Web;
37 using System.Web.UI;
38 using System.Web.UI.WebControls;
39 using System.IO;
40 using System.Drawing;
41 using System.Collections;
42 using System.Collections.Specialized;
43 using NUnit.Framework;
44 using System.Data;
45
46 using MonoTests.SystemWeb.Framework;
47 using MonoTests.stand_alone.WebHarness;
48
49 namespace MonoTests.System.Web.UI.WebControls
50 {
51         class PokerCheckBoxField : CheckBoxField
52         {
53                 // View state Stuff
54                 public PokerCheckBoxField ()
55                         : base ()
56                 {
57                         TrackViewState ();
58                 }
59
60                 public object SaveState ()
61                 {
62                         return SaveViewState ();
63                 }
64
65                 public void LoadState (object o)
66                 {
67                         LoadViewState (o);
68                 }
69
70                 public StateBag StateBag
71                 {
72                         get { return base.ViewState; }
73                 }
74
75                 public bool GetSupportsHtmlEncode
76                 {
77                         get
78                         {
79                                 return base.SupportsHtmlEncode;
80                         }
81                 }
82
83                 public void DoCopyProperties (DataControlField newField)
84                 {
85                         base.CopyProperties (newField);
86                 }
87
88                 public DataControlField DoCreateField ()
89                 {
90                         return base.CreateField ();
91                 }
92
93                 public object DoGetDesignTimeValue ()
94                 {
95                         return base.GetDesignTimeValue ();
96                 }
97
98                 public void DoInitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState)
99                 {
100                         this.InitializeDataCell (cell, rowState);
101                 }
102
103                 protected override void OnDataBindField (object sender, EventArgs e)
104                 {
105                         base.OnDataBindField (sender, e);
106                         CheckBoxFieldTest.databound += 1;
107                 }
108         }
109         
110         [TestFixture]
111         public class CheckBoxFieldTest
112         {
113                 public const string FIELDNAME  = "checkbox";
114                 public const string WRONGFIELD = "str";
115                 public static int databound;
116
117                 [TestFixtureSetUp]
118                 public void SetUp ()
119                 {
120                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_0.aspx", "CheckBoxField_Bug595568_0.aspx");
121                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_1.aspx", "CheckBoxField_Bug595568_1.aspx");
122                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_2.aspx", "CheckBoxField_Bug595568_2.aspx");
123                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_5.aspx", "CheckBoxField_Bug595568_5.aspx");
124                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_6.aspx", "CheckBoxField_Bug595568_6.aspx");
125                         WebTest.CopyResource (GetType (), "CheckBoxField_Bug595568_7.aspx", "CheckBoxField_Bug595568_7.aspx");
126                 }
127
128                 [Test (Description="Bug 595568 #0")]
129                 public void CheckBoxField_Bug595568_0 ()
130                 {
131 #if NET_4_0
132                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
133 #else
134                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl02_ctl00\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl03_ctl00\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><span title=\"Dummy\"><input id=\"gridView_ctl04_ctl00\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
135 #endif
136                         WebTest t = new WebTest ("CheckBoxField_Bug595568_0.aspx");
137                         string pageHtml = t.Run ();
138                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
139
140                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
141                 }
142
143                 [Test (Description="Bug 595568 #1")]
144                 public void CheckBoxField_Bug595568_1 ()
145                 {
146 #if NET_4_0
147                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
148 #else
149                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl02_ctl01\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl03_ctl01\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><span title=\"Dummy\"><input id=\"gridView_ctl04_ctl01\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
150 #endif
151                         WebTest t = new WebTest ("CheckBoxField_Bug595568_1.aspx");
152                         string pageHtml = t.Run ();
153                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
154
155                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
156                 }
157
158                 [Test (Description="Bug 595568 #2")]
159                 public void CheckBoxField_Bug595568_2 ()
160                 {
161 #if NET_4_0
162                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span><input id=\"gridView_ctl02_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span><input id=\"gridView_ctl02_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span><input id=\"gridView_ctl02_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl02\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
163 #else
164                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl02_ctl00\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl02_ctl01\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" checked=\"checked\" /></span><input id=\"gridView_ctl02_ctl02\" type=\"checkbox\" name=\"gridView$ctl02$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl03_ctl00\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl03_ctl01\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></span><input id=\"gridView_ctl03_ctl02\" type=\"checkbox\" name=\"gridView$ctl03$ctl02\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl04_ctl00\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><span title=\"Dummy\"><input id=\"gridView_ctl04_ctl01\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></span><input id=\"gridView_ctl04_ctl02\" type=\"checkbox\" name=\"gridView$ctl04$ctl02\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
165 #endif
166                         
167                         WebTest t = new WebTest ("CheckBoxField_Bug595568_2.aspx");
168                         string pageHtml = t.Run ();
169                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
170
171                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
172                 }
173
174                 [Test (Description="Bug 595568 #5")]
175                 public void CheckBoxField_Bug595568_5 ()
176                 {
177                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
178
179                         WebTest t = new WebTest ("CheckBoxField_Bug595568_5.aspx");
180                         string pageHtml = t.Run ();
181                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
182
183                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
184                 }
185                 
186                 [Test (Description="Bug 595568 #6")]
187                 public void CheckBoxField_Bug595568_6 ()
188                 {       
189 #if NET_4_0
190                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl01_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
191 #else
192                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl02$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl02_ctl01\" type=\"checkbox\" name=\"gridView$ctl02$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl03$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl03_ctl01\" type=\"checkbox\" name=\"gridView$ctl03$ctl01\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><select size=\"4\" name=\"gridView$ctl04$ctl00\">\r\n\r\n\t\t\t</select><input id=\"gridView_ctl04_ctl01\" type=\"checkbox\" name=\"gridView$ctl04$ctl01\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
193 #endif
194
195                         WebTest t = new WebTest ("CheckBoxField_Bug595568_6.aspx");
196                         string pageHtml = t.Run ();
197                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
198
199                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
200                 }
201
202                 [Test (Description="Bug 595568 #7")]
203                 public void CheckBoxField_Bug595568_7 ()
204                 {
205 #if NET_4_0
206                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_0\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><select size=\"4\" name=\"gridView$ctl02$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_1\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><select size=\"4\" name=\"gridView$ctl03$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl00_2\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><select size=\"4\" name=\"gridView$ctl04$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
207 #else
208                         string originalHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\">&nbsp;</th>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl02_ctl00\" type=\"checkbox\" name=\"gridView$ctl02$ctl00\" /><select size=\"4\" name=\"gridView$ctl02$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl03_ctl00\" type=\"checkbox\" name=\"gridView$ctl03$ctl00\" /><select size=\"4\" name=\"gridView$ctl03$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td><input id=\"gridView_ctl04_ctl00\" type=\"checkbox\" name=\"gridView$ctl04$ctl00\" /><select size=\"4\" name=\"gridView$ctl04$ctl01\">\r\n\r\n\t\t\t</select></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
209 #endif
210                         WebTest t = new WebTest ("CheckBoxField_Bug595568_7.aspx");             
211                         string pageHtml = t.Run ();
212                         string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
213
214                         HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
215                 }
216                 
217                 [Test]
218                 public void CheckBoxField_DefaultProperty ()
219                 {
220                         PokerCheckBoxField field = new PokerCheckBoxField ();
221                         Assert.AreEqual ("", field.DataField, "DataField");
222                         Assert.AreEqual ("", field.Text, "Text");
223                         Assert.AreEqual (false, field.GetSupportsHtmlEncode, "SupportsHtmlEncode"); 
224                 }
225
226                 [Test]
227                 public void CheckBoxField_AssignProperty ()
228                 {
229                         PokerCheckBoxField field = new PokerCheckBoxField ();
230                         field.DataField = "test";
231                         Assert.AreEqual ("test", field.DataField, "DataField");
232                         field.Text = "test";
233                         Assert.AreEqual ("test", field.Text, "Text");
234                 }
235
236                 public void CheckBoxField_ExtractValuesFromCell ()
237                 {
238                         PokerCheckBoxField field = new PokerCheckBoxField ();
239                         OrderedDictionary dictionary = new OrderedDictionary ();
240                         DataControlFieldCell cell = new DataControlFieldCell (null);
241                         cell.Controls.Add (new CheckBox ());
242                         field.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
243                         Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount#1");
244                         Assert.AreEqual ("False", dictionary[0].ToString (), "ExtractValuesFromCellValueFalse");
245                         CheckBox cb = new CheckBox ();
246                         cb.Checked = true;
247                         cell.Controls.Clear ();
248                         cell.Controls.Add (cb);
249                         field.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
250                         Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount#2");
251                         Assert.AreEqual ("True", dictionary[0].ToString (), "ExtractValuesFromCellValueTrue");
252                 }
253
254                 [Test]
255                 public void CheckBoxField_ValidateSupportsCallback ()
256                 {
257                         PokerCheckBoxField field = new PokerCheckBoxField ();
258                         field.ValidateSupportsCallback ();
259                 }
260
261                 [Test]
262                 public void CheckBoxField_CopyProperties()
263                 {
264                         PokerCheckBoxField field = new PokerCheckBoxField ();
265                         CheckBoxField copy = new CheckBoxField();
266                         field.DataField = "test";
267                         field.Text = "test";
268                         field.DoCopyProperties (copy);
269                         Assert.AreEqual ("test", copy.Text, "Text");
270                         Assert.AreEqual ("test", copy.DataField, "DataField");
271                 }
272
273                 [Test]
274                 public void CheckBoxField_CreateField ()
275                 {
276                         PokerCheckBoxField field = new PokerCheckBoxField ();
277                         CheckBoxField blank = (CheckBoxField)field.DoCreateField ();
278                         Assert.IsNotNull (blank, "CreateField");
279                 }
280
281                 [Test]
282                 public void CheckBoxField_GetDesignTimeValue ()
283                 {
284                         PokerCheckBoxField field = new PokerCheckBoxField ();
285                         bool result = (bool)field.DoGetDesignTimeValue ();
286                         Assert.AreEqual (true, result, "GetDesignTimeValue");
287                 }
288
289                 [Test]
290                 public void CheckBoxField_InitializeDataCell ()
291                 {
292                         PokerCheckBoxField field = new PokerCheckBoxField ();
293                         field.HeaderText = "headertest";
294                         DataControlFieldCell cell = new DataControlFieldCell (null);
295                         DataControlRowState state = DataControlRowState.Edit;
296                         Assert.AreEqual (0, cell.Controls.Count, "InitializeDataCellControlsBeforeInit");
297                         field.DoInitializeDataCell (cell, state);
298                         Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
299                         Assert.AreEqual ("headertest", ((CheckBox)cell.Controls[0]).ToolTip, "InitializeDataCellControlsData");
300
301                         cell.Controls.Clear ();
302                         field.DataField = "fake";
303                         field.Text = "celltext";
304                         state = DataControlRowState.Normal;
305                         field.DoInitializeDataCell (cell, state);
306                         Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
307                         Assert.AreEqual ("celltext", ((CheckBox) cell.Controls[0]).Text, "InitializeDataCellControlsData");
308                 }
309
310                 [Test]
311                 public void CheckBoxField_OnDataBindField ()
312                 {
313                         Page page = new Page ();
314                         GridView grid = new GridView ();
315                         page.Controls.Add (grid);
316                         grid.DataSource = this.CreateDataSource ();
317                         grid.AutoGenerateColumns = false;
318                         PokerCheckBoxField field = new PokerCheckBoxField ();
319                         field.HeaderText = "field_header";
320                         field.FooterText = "field_footer";
321                         field.DataField = FIELDNAME;
322                         grid.Columns.Add (field);
323                         grid.DataBind ();
324                         Assert.AreEqual (2, databound, "DataBindField");
325                         Assert.AreEqual (4, ((Control) grid.Controls[0]).Controls.Count, "DataBindFieldRowCountr");
326                 }
327
328                 [Test]
329                 [ExpectedException (typeof (HttpException))]
330                 public void CheckBoxField_OnDataBindFieldException ()
331                 {
332                         Page page = new Page ();
333                         GridView grid = new GridView ();
334                         page.Controls.Add (grid);
335                         grid.DataSource = this.CreateDataSource ();
336                         grid.AutoGenerateColumns = false;
337                         PokerCheckBoxField field = new PokerCheckBoxField ();
338                         field.HeaderText = "field_header";
339                         field.FooterText = "field_footer";
340                         field.DataField = WRONGFIELD;
341                         grid.Columns.Add (field);
342                         grid.DataBind ();
343                 }
344
345                 [Test]
346                 [ExpectedException(typeof(NotSupportedException))]
347                 public void CheckBoxField_GetApplyFormatInEditModeExeption ()
348                 {
349                         PokerCheckBoxField field = new PokerCheckBoxField ();
350                         bool stab = field.ApplyFormatInEditMode;
351                 }
352
353                 [Test]
354                 [ExpectedException (typeof (NotSupportedException))]
355                 public void CheckBoxField_SetApplyFormatInEditModeExeption ()
356                 {
357                         PokerCheckBoxField field = new PokerCheckBoxField ();
358                         field.ApplyFormatInEditMode = true;
359                 }
360
361                 [Test]
362                 [ExpectedException (typeof (NotSupportedException))]
363                 public void CheckBoxField_GetConvertEmptyStringToNull ()
364                 {
365                         PokerCheckBoxField field = new PokerCheckBoxField ();
366                         bool stab = field.ConvertEmptyStringToNull;
367                 }
368
369                 [Test]
370                 [ExpectedException (typeof (NotSupportedException))]
371                 public void CheckBoxField_SetConvertEmptyStringToNull ()
372                 {
373                         PokerCheckBoxField field = new PokerCheckBoxField ();
374                         field.ConvertEmptyStringToNull = true;
375                 }
376
377                 [Test]
378                 [ExpectedException (typeof (NotSupportedException))]
379                 public void CheckBoxField_SetDataFormatString ()
380                 {
381                         PokerCheckBoxField field = new PokerCheckBoxField ();
382                         field.DataFormatString = "";
383                 }
384
385                 [Test]
386                 [ExpectedException (typeof (NotSupportedException))]
387                 public void CheckBoxField_GetDataFormatString ()
388                 {
389                         PokerCheckBoxField field = new PokerCheckBoxField ();
390                         string res = field.DataFormatString;
391                 }
392
393                 [Test]
394                 [ExpectedException (typeof (NotSupportedException))]
395                 public void CheckBoxField_SetHtmlEncode ()
396                 {
397                         PokerCheckBoxField field = new PokerCheckBoxField ();
398                         field.HtmlEncode = true;
399                 }
400
401                 [Test]
402                 [ExpectedException (typeof (NotSupportedException))]
403                 public void CheckBoxField_GetHtmlEncode ()
404                 {
405                         PokerCheckBoxField field = new PokerCheckBoxField ();
406                         bool res = field.HtmlEncode;
407                 }
408
409                 [Test]
410                 [ExpectedException (typeof (NotSupportedException))]
411                 public void CheckBoxField_SetNullDisplayText ()
412                 {
413                         PokerCheckBoxField field = new PokerCheckBoxField ();
414                         field.NullDisplayText = "";
415                 }
416
417                 [Test]
418                 [ExpectedException (typeof (NotSupportedException))]
419                 public void CheckBoxField_GetNullDisplayText ()
420                 {
421                         PokerCheckBoxField field = new PokerCheckBoxField ();
422                         string res = field.NullDisplayText;
423                 }
424
425                 public  DataTable CreateDataSource ()
426                 {
427                         DataTable aTable = new DataTable ("A");
428                         DataColumn dtCol;
429                         DataRow dtRow;
430                         // Create ID column and add to the DataTable.
431                         dtCol = new DataColumn ();
432                         dtCol.DataType = Type.GetType ("System.Boolean");
433                         dtCol.ColumnName = FIELDNAME;
434                         dtCol.Caption = FIELDNAME;
435                         dtCol.ReadOnly = true;
436
437                         // Add the column to the DataColumnCollection.
438                         aTable.Columns.Add (dtCol);
439
440
441                         dtCol = new DataColumn ();
442                         dtCol.DataType = Type.GetType ("System.String");
443                         dtCol.ColumnName = WRONGFIELD;
444                         dtCol.Caption = WRONGFIELD;
445                         dtCol.ReadOnly = true;
446                         
447
448                         // Add the column to the DataColumnCollection.
449                         aTable.Columns.Add (dtCol);
450
451                         // Create 2 rows to the table
452                         dtRow = aTable.NewRow ();
453                         dtRow[FIELDNAME] = true;
454                         dtRow[WRONGFIELD] = "1";
455                         aTable.Rows.Add (dtRow);
456
457                         dtRow = aTable.NewRow ();
458                         dtRow[FIELDNAME] = false;
459                         dtRow[WRONGFIELD] = "1";
460                         aTable.Rows.Add (dtRow);
461                         return aTable;
462                 }
463         }
464 }
465 #endif