Author: gonzalo
Date: 2005-09-27 21:37:36 -0400 (Tue, 27 Sep 2005)
New Revision: 50903

Modified:
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
   trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataGridTest.cs
Log:
2005-09-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * DataGridTest.cs: more tests that add a TemplateColumn.



Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2005-09-28 01:29:00 UTC (rev 50902)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog 
2005-09-28 01:37:36 UTC (rev 50903)
@@ -1,5 +1,9 @@
 2005-09-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
+       * DataGridTest.cs: more tests that add a TemplateColumn.
+
+2005-09-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
        * EditCommandColumnTest.cs: added a test here for datagrid, as this was
        the file whose test failed because the id of the datagrid generated
        table.

Modified: 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataGridTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataGridTest.cs   
2005-09-28 01:29:00 UTC (rev 50902)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/DataGridTest.cs   
2005-09-28 01:37:36 UTC (rev 50903)
@@ -3,6 +3,7 @@
 //
 // Author:
 //     Jackson Harper ([EMAIL PROTECTED])
+//     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
 //
 //
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
@@ -54,6 +55,16 @@
                        return TagName;
                }
 
+               public void CreateCH (bool use_ds)
+               {
+                       CreateControlHierarchy (use_ds);
+               }
+
+               public void PrepareCH ()
+               {
+                       PrepareControlHierarchy ();
+               }
+
                public string Render ()
                {
                        StringWriter sw = new StringWriter ();
@@ -68,7 +79,7 @@
                        return ViewState;
                }
 
-               public Style ControlStyle ()
+               public new Style ControlStyle ()
                {
                        return CreateControlStyle ();
                }
@@ -1317,7 +1328,80 @@
                        Assert.AreEqual (0, p.DataKeys.Count, "A3");
                }
 
+               class MyTemplate : ITemplate {
+                       string text;
+                       public MyTemplate (string text)
+                       {
+                               this.text = text;
+                       }
+
+                       public void InstantiateIn (Control control)
+                       {
+                               control.Controls.Add (new LiteralControl 
(text));       
+                       }
+               }
+
                [Test]
+               public void OneTemplateColumn1 ()
+               {
+                       DataGridPoker p = new DataGridPoker ();
+                       TemplateColumn tc = new TemplateColumn ();
+                       tc.ItemTemplate = new MyTemplate ("hola");
+                       p.Columns.Add (tc);
+                       p.CreateControls (true);
+                       Assert.AreEqual (1, p.Columns.Count, "columns");
+                       Assert.AreEqual (0, p.Controls.Count, "controls");
+                       string render = p.Render ();
+                       // no items, even with a templated column.
+                       // The table is not added if DataSource == null
+                       Assert.IsTrue (-1 == render.IndexOf ("hola"), 
"template");
+               }
+
+               [Test]
+               public void OneTemplateColumn2 ()
+               {
+                       DataGridPoker p = new DataGridPoker ();
+                       p.ShowFooter = true;
+                       p.AutoGenerateColumns = false;
+                       p.DataSource = new ArrayList ();
+                       TemplateColumn tc = new TemplateColumn ();
+                       tc.HeaderText = " ";
+                       tc.FooterTemplate = new MyTemplate ("hola");
+                       p.Columns.Add (tc);
+                       Assert.AreEqual (1, p.Columns.Count, "columns-1");
+                       Assert.AreEqual (0, p.Controls.Count, "controls-1");
+                       p.CreateCH (true);
+                       // This time we have the table there. Thanks to the 
empty ArrayList
+                       Assert.AreEqual (1, p.Columns.Count, "columns-2");
+                       Assert.AreEqual (1, p.Controls.Count, "controls-2");
+                       p.PrepareCH ();
+                       Assert.AreEqual (1, p.Columns.Count, "columns-3");
+                       Assert.AreEqual (1, p.Controls.Count, "controls-3");
+               }
+
+               [Test]
+               public void OneTemplateColumn3 ()
+               {
+                       DataGridPoker p = new DataGridPoker ();
+                       p.ShowFooter = true;
+                       p.AutoGenerateColumns = false;
+                       p.DataSource = new ArrayList ();
+                       TemplateColumn tc = new TemplateColumn ();
+                       tc.FooterTemplate = new MyTemplate ("hola");
+                       p.Columns.Add (tc);
+                       p.DataBind ();
+
+                       StringWriter sw = new StringWriter ();
+                       HtmlTextWriter tw = new HtmlTextWriter (sw);
+                       Assert.AreEqual (1, p.Columns.Count, "columns");
+                       Assert.AreEqual (1, p.Controls.Count, "controls");
+
+                       string render = p.Render ();
+                       // no items, but we have a footer
+                       Assert.IsTrue (-1 != render.IndexOf ("hola"), 
"template");
+               }
+
+               [Test]
                public void CreateControls ()
                {
                        DataGridPoker p = new DataGridPoker ();

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

Reply via email to