Merge pull request #1840 from ludovic-henry/iolayer-thread-interrupt
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / EditCommandColumnTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.EditCommandColumn.cs 
3 //
4 // Author:
5 //      Peter Dennis Bartok (pbartok@novell.com)
6 //
7
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.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.Collections;
34 using System.Data;
35 using System.IO;
36 using System.Globalization;
37 using System.Text;
38 using System.Web;
39 using System.Web.UI;
40 using System.Web.UI.WebControls;
41 using MonoTests.stand_alone.WebHarness;
42 using MonoTests.SystemWeb.Framework;
43
44 namespace MonoTests.System.Web.UI.WebControls
45 {
46
47         
48         
49         [TestFixture]   
50         public class EditCommandColumnTest {
51
52                 private class DataGridTest : DataGrid {
53                         public ArrayList CreateColumns (PagedDataSource data_source, bool use_data_source) {
54                                 return CreateColumnSet (data_source, use_data_source);
55                         }
56
57                         public void CreateControls (bool use_data_source) {
58                                 CreateControlHierarchy (use_data_source);
59                         }
60                 }
61                 
62                 [Test]
63                 public void Defaults ()
64                 {
65                         EditCommandColumn       e;
66
67                         e = new EditCommandColumn();
68
69                         Assert.AreEqual(ButtonColumnType.LinkButton, e.ButtonType, "D1");
70                         Assert.AreEqual(string.Empty, e.CancelText, "D2");
71                         Assert.AreEqual(string.Empty, e.EditText, "D3");
72                         Assert.AreEqual(string.Empty, e.UpdateText, "D4");
73                         Assert.AreEqual (true, e.CausesValidation, "CausesValidation");
74                         Assert.AreEqual (string.Empty, e.ValidationGroup, "ValidationGroup");
75                 }
76
77                 [Test]
78                 public void Properties () {
79                         EditCommandColumn       e;
80
81                         e = new EditCommandColumn();
82
83                         e.ButtonType = ButtonColumnType.PushButton;
84                         Assert.AreEqual(ButtonColumnType.PushButton, e.ButtonType, "P1");
85
86                         e.CancelText = "Cancel this!";
87                         Assert.AreEqual("Cancel this!", e.CancelText, "D2");
88
89                         e.EditText = "Edit me good";
90                         Assert.AreEqual("Edit me good", e.EditText, "D3");
91
92                         e.UpdateText = "Update? What update?";
93                         Assert.AreEqual("Update? What update?", e.UpdateText, "D4");
94                         e.CausesValidation = false;
95                         Assert.AreEqual (false, e.CausesValidation, "CausesValidation");
96                         e.ValidationGroup = "test";
97                         Assert.AreEqual ("test", e.ValidationGroup, "ValidationGroup");
98                 }
99
100                 private string ControlMarkup(Control c) {
101                         StringWriter sw = new StringWriter ();
102                         HtmlTextWriter tw = new CleanHtmlTextWriter (sw);
103
104                         c.RenderControl (tw);
105                         return sw.ToString ();
106                 }
107
108                 private void ShowControlsRecursive (Control c, int depth) {
109                          StringWriter sw = new StringWriter ();
110                          HtmlTextWriter tw = new CleanHtmlTextWriter (sw);
111
112                          c.RenderControl (tw);
113                          Console.WriteLine (sw.ToString ());
114
115                         Console.WriteLine (c);
116
117                         foreach (Control child in c.Controls)
118                                 ShowControlsRecursive (child, depth + 5);
119                 }
120
121                 [Test]
122                 public void InitializeCell () 
123                 {
124                         string origHtml = "<table><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Edit</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
125                         DataGridTest    p = new DataGridTest ();
126                         DataTable       table = new DataTable ();
127                         EditCommandColumn       e;
128                         string                  markup;
129
130                         e = new EditCommandColumn();
131                         e.ButtonType = ButtonColumnType.LinkButton;
132                         e.CancelText = "Cancel";
133                         e.EditText = "Edit";
134                         e.UpdateText = "Update";                        
135
136                         table.Columns.Add (new DataColumn ("one", typeof (string)));
137                         table.Columns.Add (new DataColumn ("two", typeof (string)));
138                         table.Columns.Add (new DataColumn ("three", typeof (string)));
139                         table.Rows.Add (new object [] { "1", "2", "3" });
140
141                         p.DataSource = new DataView (table);
142                         p.Columns.Add(e);
143
144                         e = new EditCommandColumn();
145                         e.ButtonType = ButtonColumnType.PushButton;
146                         e.CancelText = "Abbrechen";
147                         e.EditText = "Bearbeiten";
148                         e.UpdateText = "Refresh";                       
149                         p.Columns.Add(e);
150
151                         // This will trigger EditCommandColumn.InitializeCell, without any EditItem set, tests the EditText render
152                         p.CreateControls (true);
153                         p.ID = "sucker";
154
155                         Assert.AreEqual (2, p.Columns.Count, "I1");
156                         markup = ControlMarkup(p.Controls[0]);
157                         markup = markup.Replace("\t", "");
158                         markup = markup.Replace ("\r", "");
159                         markup = markup.Replace ("\n", "");
160
161                         HtmlDiff.AssertAreEqual (origHtml, markup, "I2");
162
163                         //ShowControlsRecursive (p.Controls [0], 1);
164                 }
165
166                 [Test]
167                 public void ThisIsADGTest () 
168                 {
169                         string origHtml = "<table id=\"sucker_tbl\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Edit</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Bearbeiten\" /></td><td>1</td><td>2</td><td>3</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
170                         DataGridTest    p = new DataGridTest ();
171                         DataTable       table = new DataTable ();
172                         EditCommandColumn       e;
173                         string                  markup;
174
175                         e = new EditCommandColumn();
176                         e.ButtonType = ButtonColumnType.LinkButton;
177                         e.CancelText = "Cancel";
178                         e.EditText = "Edit";
179                         e.UpdateText = "Update";                        
180
181                         table.Columns.Add (new DataColumn ("one", typeof (string)));
182                         table.Columns.Add (new DataColumn ("two", typeof (string)));
183                         table.Columns.Add (new DataColumn ("three", typeof (string)));
184                         table.Rows.Add (new object [] { "1", "2", "3" });
185
186                         p.DataSource = new DataView (table);
187                         p.Columns.Add(e);
188
189                         e = new EditCommandColumn();
190                         e.ButtonType = ButtonColumnType.PushButton;
191                         e.CancelText = "Abbrechen";
192                         e.EditText = "Bearbeiten";
193                         e.UpdateText = "Refresh";                       
194                         p.Columns.Add(e);
195
196                         p.CreateControls (true);
197                         // This is the test we want to run: setting the ID of the table created by
198                         // the datagrid overrides the using the ID of the datagrid itself and uses
199                         // the table ClientID instead.
200                         p.ID = "sucker";
201                         p.Controls [0].ID = "tbl";
202
203                         Assert.AreEqual (2, p.Columns.Count, "I1");
204                         markup = ControlMarkup(p.Controls[0]);
205                         markup = markup.Replace("\t", "");
206                         markup = markup.Replace ("\r", "");
207                         markup = markup.Replace ("\n", "");
208                         
209                         HtmlDiff.AssertAreEqual (origHtml, markup, "I2");
210                 }
211
212                 static void GetHierarchy (ControlCollection coll, int level, StringBuilder sb)
213                 {
214                         foreach (Control c in coll) {
215                                 sb.AppendFormat ("{0}{1}\n", new string (' ', 2 * level), c.GetType ());
216                                 GetHierarchy (c.Controls, level + 1, sb);
217                         }
218                 }
219
220                 [Test]
221                 public void InitializeEditCell () 
222                 {
223                         string origHtml = "<table><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" />&nbsp;<input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
224                         DataGridTest    p = new DataGridTest ();
225                         DataTable       table = new DataTable ();
226                         EditCommandColumn       e;
227                         string                  markup;
228
229                         e = new EditCommandColumn();
230                         e.ButtonType = ButtonColumnType.LinkButton;
231                         e.CancelText = "Cancel";
232                         e.EditText = "Edit";
233                         e.UpdateText = "Update";                        
234
235                         table.Columns.Add (new DataColumn ("one", typeof (string)));
236                         table.Columns.Add (new DataColumn ("two", typeof (string)));
237                         table.Columns.Add (new DataColumn ("three", typeof (string)));
238                         table.Rows.Add (new object [] { "1", "2", "3" });
239
240                         p.DataSource = new DataView (table);
241                         p.Columns.Add(e);
242
243                         e = new EditCommandColumn();
244                         e.ButtonType = ButtonColumnType.PushButton;
245                         e.CancelText = "Abbrechen";
246                         e.EditText = "Bearbeiten";
247                         e.UpdateText = "Refresh";                       
248                         p.Columns.Add(e);
249
250                         // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render
251                         p.EditItemIndex = 0;
252
253                         // This will trigger EditCommandColumn.InitializeCell
254                         p.CreateControls (true);
255                         p.ID = "sucker";
256
257                         StringBuilder sb = new StringBuilder ();
258                         GetHierarchy (p.Controls, 0, sb);
259                         string h = sb.ToString ();
260                         int x = h.IndexOf (".TextBox");
261                         // These are from the BoundColumns
262                         Assert.IsTrue (x != -1, "textbox1");
263                         x = h.IndexOf (".TextBox", x + 1);
264                         Assert.IsTrue (x != -1, "textbox2");
265                         x = h.IndexOf (".TextBox", x + 1);
266                         Assert.IsTrue (x != -1, "textbox3");
267                         x = h.IndexOf (".TextBox", x + 1);
268                         Assert.IsTrue (x == -1, "textbox-end");
269
270                         markup = ControlMarkup (p.Controls[0]);
271                         markup = markup.Replace ("\t", "");
272                         markup = markup.Replace ("\r", "");
273                         markup = markup.Replace ("\n", "");
274
275 //Console.WriteLine("Markup:>{0}<", markup);
276                         Assert.AreEqual (2, p.Columns.Count, "I1");
277
278                         HtmlDiff.AssertAreEqual (origHtml, markup, "I2");
279                 }
280
281                 [Test]
282                 [Ignore("Unfinished")]
283                 public void InitializeReadOnlyEditCell ()
284                 {
285                         DataGridTest p = new DataGridTest ();
286                         DataTable table = new DataTable ();
287                         EditCommandColumn e;
288                         string markup;
289
290                         e = new EditCommandColumn ();
291                         e.ButtonType = ButtonColumnType.LinkButton;
292                         e.CancelText = "Cancel";
293                         e.EditText = "Edit";
294                         e.UpdateText = "Update";
295
296                         table.Columns.Add (new DataColumn ("one", typeof (string)));
297                         table.Columns.Add (new DataColumn ("two", typeof (string)));
298                         table.Columns.Add (new DataColumn ("three", typeof (string)));
299                         table.Rows.Add (new object[] { "1", "2", "3" });
300
301                         p.DataSource = new DataView (table);
302                         p.Columns.Add (e);
303
304                         e = new EditCommandColumn ();
305                         e.ButtonType = ButtonColumnType.PushButton;
306                         
307                         e.CancelText = "Abbrechen";
308                         e.EditText = "Bearbeiten";
309                         e.UpdateText = "Refresh";
310                         p.Columns.Add (e);
311
312                         // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render
313                         p.EditItemIndex = 0;
314
315                         // This will trigger EditCommandColumn.InitializeCell
316                         p.CreateControls (true);
317                         p.ID = "sucker";
318
319                         markup = ControlMarkup (p.Controls[0]);
320                         markup = markup.Replace ("\t", "");
321                         markup = markup.Replace ("\r", "");
322                         markup = markup.Replace ("\n", "");
323
324                         Assert.AreEqual (2, p.Columns.Count, "I1");
325                         Assert.AreEqual (
326                                 "<table border=\"0\" id=\"sucker\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td>" +
327                                 "</tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name type=\"submit\" value=\"Refresh\" />&nbsp;" +
328                                 "<input name value=\"Abbrechen\" type=\"submit\" /></td>" +
329                                 "<td><input name=\"_ctl2:_ctl0\" type=\"text\" value=\"1\" /></td>" +
330                                 "<td><input name=\"_ctl2:_ctl1\" type=\"text\" value=\"2\" /></td>" +
331                                 "<td><input name=\"_ctl2:_ctl2\" type=\"text\" value=\"3\" /></td>" +
332                                 "</tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>" +
333                                 "</tr></table>", markup, "I2");
334                 }
335
336                 [Test]
337                 [Category ("NunitWeb")]
338                 public void Validation_ValidatingValid () 
339                 {
340                         WebTest t = new WebTest ();
341                         PageDelegates pd = new PageDelegates ();
342                         pd.Load = Validation_Load;
343                         pd.PreRender = Validation_PreRender;
344                         t.Invoker = new PageInvoker (pd);
345                         t.UserData = "ValidatingValid";
346                         string html = t.Run ();
347                         FormRequest fr = new FormRequest (t.Response, "form1");
348
349                         fr.Controls.Add ("__EVENTTARGET");
350                         fr.Controls.Add ("__EVENTARGUMENT");
351                         fr.Controls ["__EVENTTARGET"].Value = (string) t.UserData;
352                         fr.Controls ["__EVENTARGUMENT"].Value = "";
353                         t.Request = fr;
354                         t.UserData = "ValidatingValid";
355                         
356                         html = t.Run ();
357                 }
358
359                 [Test]
360                 [Category ("NunitWeb")]
361                 [Ignore ("Possibly incorrectly constructed test - conflicts with fix for bug #471305")]
362                 public void Validation_ValidatingInvalid () {
363                         WebTest t = new WebTest ();
364                         PageDelegates pd = new PageDelegates ();
365                         pd.Load = Validation_Load;
366                         pd.PreRender = Validation_PreRender;
367                         t.Invoker = new PageInvoker (pd);
368                         t.UserData = "ValidatingInvalid";
369                         string html = t.Run ();
370                         FormRequest fr = new FormRequest (t.Response, "form1");
371
372                         fr.Controls.Add ("__EVENTTARGET");
373                         fr.Controls.Add ("__EVENTARGUMENT");
374                         fr.Controls ["__EVENTTARGET"].Value = (string)t.UserData;
375                         fr.Controls ["__EVENTARGUMENT"].Value = "";
376                         t.Request = fr;
377                         t.UserData = "ValidatingInvalid";
378
379                         html = t.Run ();
380                 }
381
382                 [Test]
383                 [Category ("NunitWeb")]
384                 public void Validation_NotValidatingInvalid () {
385                         WebTest t = new WebTest ();
386                         PageDelegates pd = new PageDelegates ();
387                         pd.Load = Validation_Load;
388                         pd.PreRender = Validation_PreRender;
389                         t.Invoker = new PageInvoker (pd);
390                         t.UserData = "NotValidatingInvalid";
391                         string html = t.Run ();
392                         FormRequest fr = new FormRequest (t.Response, "form1");
393
394                         fr.Controls.Add ("__EVENTTARGET");
395                         fr.Controls.Add ("__EVENTARGUMENT");
396                         fr.Controls ["__EVENTTARGET"].Value = (string) t.UserData;
397                         fr.Controls ["__EVENTARGUMENT"].Value = "";
398                         t.Request = fr;
399                         t.UserData = "NotValidatingInvalid";
400
401                         html = t.Run ();
402                 }
403
404                 [Test]
405                 [Category ("NunitWeb")]
406                 [Ignore ("Possibly incorrectly constructed test - conflicts with fix for bug #471305")]
407                 public void Validation_ValidationGroupIncluded () {
408                         WebTest t = new WebTest ();
409                         PageDelegates pd = new PageDelegates ();
410                         pd.Load = Validation_Load;
411                         pd.PreRender = Validation_PreRender;
412                         t.Invoker = new PageInvoker (pd);
413                         t.UserData = "ValidationGroupIncluded";
414                         string html = t.Run ();
415                         FormRequest fr = new FormRequest (t.Response, "form1");
416
417                         fr.Controls.Add ("__EVENTTARGET");
418                         fr.Controls.Add ("__EVENTARGUMENT");
419                         fr.Controls ["__EVENTTARGET"].Value = (string) t.UserData;
420                         fr.Controls ["__EVENTARGUMENT"].Value = "";
421                         t.Request = fr;
422                         t.UserData = "ValidationGroupIncluded";
423
424                         html = t.Run ();
425                 }
426
427                 [Test]
428                 [Category ("NunitWeb")]
429                 public void Validation_ValidationGroupNotIncluded () {
430                         WebTest t = new WebTest ();
431                         PageDelegates pd = new PageDelegates ();
432                         pd.Load = Validation_Load;
433                         pd.PreRender = Validation_PreRender;
434                         t.Invoker = new PageInvoker (pd);
435                         t.UserData = "ValidationGroupNotIncluded";
436                         string html = t.Run ();
437                         FormRequest fr = new FormRequest (t.Response, "form1");
438
439                         fr.Controls.Add ("__EVENTTARGET");
440                         fr.Controls.Add ("__EVENTARGUMENT");
441                         fr.Controls ["__EVENTTARGET"].Value = (string) t.UserData;
442                         fr.Controls ["__EVENTARGUMENT"].Value = "";
443                         t.Request = fr;
444                         t.UserData = "ValidationGroupNotIncluded";
445
446                         html = t.Run ();
447                 }
448
449                 public static void Validation_Load (Page p) 
450                 {
451                         string testType = (string)WebTest.CurrentTest.UserData;
452                         DataGridTest dg = new DataGridTest ();
453                         dg.ID = "mygrid";
454                         EditCommandColumn e;
455
456                         e = new EditCommandColumn ();
457                         e.ButtonType = ButtonColumnType.LinkButton;
458                         e.CancelText = "Cancel";
459                         e.EditText = "Edit";
460                         e.UpdateText = "Update";
461
462                         switch (testType) {
463                         case "ValidatingValid":
464                         case "ValidatingInvalid":
465                         case "ValidationGroupIncluded":
466                         case "ValidationGroupNotIncluded":
467                                 e.CausesValidation = true;
468                                 break;
469
470                         case "NotValidatingInvalid":
471                                 e.CausesValidation = false;
472                                 break;
473                         }
474
475                         switch (testType) {
476                         case "ValidationGroupIncluded":
477                         case "ValidationGroupNotIncluded":
478                                 e.ValidationGroup = "Group1";
479                                 break;
480
481                         default:
482                                 e.ValidationGroup = "";
483                                 break;
484                         }
485
486                         dg.Columns.Add (e);
487
488                         TextBox tb = new TextBox ();
489                         tb.ID = "Text1";
490                         switch (testType) {
491                         case "ValidatingValid":
492                                 tb.Text = "111";
493                                 break;
494
495                         case "ValidatingInvalid":
496                         case "NotValidatingInvalid":
497                         case "ValidationGroupIncluded":
498                         case "ValidationGroupNotIncluded":
499                                 tb.Text = "";
500                                 break;
501                         }
502
503                         RequiredFieldValidator v = new RequiredFieldValidator ();
504                         v.ControlToValidate = "Text1";
505                         switch (testType) {
506                         case "ValidationGroupIncluded":
507                                 v.ValidationGroup = "Group1";
508                                 break;
509
510                         case "ValidationGroupNotIncluded":
511                                 v.ValidationGroup = "NotGroup1";
512                                 break;
513
514                         default:
515                                 v.ValidationGroup = "";
516                                 break;
517                         }
518                         TemplateColumn tc = new TemplateColumn ();
519                         tc.EditItemTemplate = new ValidatingEditTemplate (tb, v);
520                         dg.Columns.Add (tc);
521
522                         ObjectDataSource ods = new ObjectDataSource ("MyObjectDS", "Select");
523                         ods.UpdateMethod = "Update";
524                         ods.DataObjectTypeName = "MyObjectDS";
525                         ods.ID = "MyDS";
526
527                         p.Form.Controls.Add (ods);
528
529                         dg.DataSource = ods;
530                         //dg.DataKeyField = "i";
531
532                         //DataTable table = new DataTable ();
533                         //table.Columns.Add (new DataColumn ("one", typeof (string)));
534                         //table.Columns.Add (new DataColumn ("two", typeof (string)));
535                         //table.Columns.Add (new DataColumn ("three", typeof (string)));
536                         //table.Rows.Add (new object [] { "1", "2", "3" });
537
538                         //dg.DataSource = new DataView (table);
539
540                         dg.EditItemIndex = 0;
541                         p.Form.Controls.Add (dg);
542
543                         dg.DataBind ();
544                         if (!p.IsPostBack) {
545                                 WebTest.CurrentTest.UserData = dg.Items [0].Cells [0].Controls [0].UniqueID;
546                         }
547                 }
548
549                 public static void Validation_PreRender (Page p) 
550                 {
551                         string testType = (string) WebTest.CurrentTest.UserData;
552
553                         if (p.IsPostBack) {
554                                 switch (testType) {
555                                 case "ValidatingValid":
556                                 case "ValidationGroupNotIncluded":
557                                         Assert.AreEqual (true, p.IsValid, "ValidatingValid");
558                                         break;
559                                 case "ValidatingInvalid":
560                                 case "ValidationGroupIncluded":
561                                         Assert.AreEqual (false, p.IsValid, "ValidatingInvalid");
562                                         break;
563
564                                 case "NotValidatingInvalid":
565                                         bool isValidated = true;
566                                         try {
567                                                 if (p.IsValid) {
568                                                         Assert.Fail ("NotValidatingInvalid IsValid == true");
569                                                 }
570                                         }
571                                         catch (HttpException httpException) {
572                                                 isValidated = false;
573                                         }
574                                         Assert.AreEqual(false, isValidated, "NotValidatingInvalid");
575                                         break;
576                                 }
577                         }
578                 }
579
580                 public class ValidatingEditTemplate : ITemplate
581                 {
582                         public ValidatingEditTemplate (params Control [] templateControls) 
583                         {
584                                 this.templateControls = new Control[templateControls.Length];
585                                 templateControls.CopyTo (this.templateControls, 0);
586                         }
587
588                         #region ITemplate Members
589
590                         public void InstantiateIn (Control container) 
591                         {
592                                 foreach (Control c in templateControls) {
593                                         container.Controls.Add (c);
594                                 }
595                         }
596
597                         #endregion
598
599                         private Control[] templateControls;
600                 }
601         }
602 }
603
604 #region MyObjectDS
605 public class MyObjectDS
606 {
607         public MyObjectDS () {
608                 _i = 0;
609         }
610
611         public MyObjectDS (int value) {
612                 _i = value;
613         }
614
615         private int _i;
616         public int i {
617                 get { return _i; }
618                 set { _i = value; }
619         }
620
621         static MyObjectDS [] myData = null;
622
623         public static IList Select () {
624                 if (myData == null) {
625                         myData = new MyObjectDS [] { new MyObjectDS (1), new MyObjectDS (2), new MyObjectDS (3) };
626                 }
627                 return myData;
628         }
629
630         public static void Update (MyObjectDS instance) {
631         }
632 }
633 #endregion