2 // Tests for System.Web.UI.WebControls.MasterPageTest.cs
\r
5 // Yoni Klein (yonik@mainsoft.com)
\r
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
\r
10 // Permission is hereby granted, free of charge, to any person obtaining
\r
11 // a copy of this software and associated documentation files (the
\r
12 // "Software"), to deal in the Software without restriction, including
\r
13 // without limitation the rights to use, copy, modify, merge, publish,
\r
14 // distribute, sublicense, and/or sell copies of the Software, and to
\r
15 // permit persons to whom the Software is furnished to do so, subject to
\r
16 // the following conditions:
\r
18 // The above copyright notice and this permission notice shall be
\r
19 // included in all copies or substantial portions of the Software.
\r
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
32 using NUnit.Framework;
\r
34 using System.Collections.Generic;
\r
37 using System.Web.UI;
\r
38 using System.Web.UI.WebControls;
\r
40 using System.Drawing;
\r
41 using MyWebControl = System.Web.UI.WebControls;
\r
42 using System.Collections;
\r
43 using MonoTests.SystemWeb.Framework;
\r
44 using MonoTests.stand_alone.WebHarness;
\r
47 namespace MonoTests.System.Web.UI.WebControls
\r
49 class PokerMasterPage : MasterPage
\r
51 public PokerMasterPage ()
\r
55 public StateBag StateBag
\r
57 get { return base.ViewState; }
\r
59 public new IDictionary ContentTemplates ()
\r
61 return base.ContentTemplates;
\r
63 public new void AddContentTemplate (string templateName, ITemplate template)
\r
65 base.AddContentTemplate (templateName, template);
\r
71 public class MasterPageTest
\r
75 [Category ("NotWorking")]
\r
76 public void MasterPage_DefaultProperties ()
\r
78 PokerMasterPage pmp = new PokerMasterPage ();
\r
79 Assert.AreEqual (null, pmp.Master, "Master Property");
\r
80 Assert.AreEqual (null, pmp.MasterPageFile, "MasterPageFile Property");
\r
81 IDictionary i = pmp.ContentTemplates ();
\r
82 Assert.AreEqual (null,i,"ContentTemplates");
\r
86 [Category ("NotWorking")]
\r
87 [Category ("NunitWeb")]
\r
88 public void MasterPage_Render()
\r
90 WebTest t = new WebTest (PageInvoker.CreateOnLoad (_RenderDefault));
\r
91 t.Request.Url = StandardUrl.PAGE_WITH_MASTER;
\r
92 string PageRenderHtml = t.Run ();
\r
93 Assert.AreEqual (-1, PageRenderHtml.IndexOf ("Master header text"), "Master#1");
\r
95 if (PageRenderHtml.IndexOf ("Page main text") < 0) {
\r
96 Assert.Fail ("Master#2");
\r
99 Assert.AreEqual (-1, PageRenderHtml.IndexOf ("Master main text"), "Master#3");
\r
100 Assert.AreEqual (-1, PageRenderHtml.IndexOf ("Master dynamic text"), "Master#4");
\r
102 if (PageRenderHtml.IndexOf ("Page dynamic text") < 0) {
\r
103 Assert.Fail ("Master#5");
\r
106 if (PageRenderHtml.IndexOf ("My master page footer") < 0) {
\r
107 Assert.Fail ("Master#6, result: "+PageRenderHtml);
\r
110 if (PageRenderHtml.IndexOf ("Master page content text") < 0) {
\r
111 Assert.Fail ("Master#7");
\r
117 public static void _RenderDefault (Page p)
\r
119 p.Form.Controls.Add(new LiteralControl("Page dynamic text"));
\r
123 [Category ("NotWorking")]
\r
124 [ExpectedException (typeof(HttpException))]
\r
125 public void MasterPage_AddContentTemplate ()
\r
127 PokerMasterPage pmp = new PokerMasterPage();
\r
128 ITemplate it = null;
\r
129 pmp.AddContentTemplate ("myTemplate", it);
\r
130 pmp.AddContentTemplate ("myTemplate", it);
\r
133 [TestFixtureTearDown]
\r
134 public void TearDown ()
\r