* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / ContentTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.ContentTest.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 NUnit.Framework;
34 using System;
35 using System.Collections.Generic;
36 using System.Text;
37 using System.Web;
38 using System.Web.UI;
39 using System.Web.UI.WebControls;
40 using System.IO;
41 using System.Drawing;
42 using MyWebControl = System.Web.UI.WebControls;
43 using System.Collections;
44 using MonoTests.stand_alone.WebHarness;
45
46
47 namespace MonoTests.System.Web.UI.WebControls
48 {
49
50
51         class PokerContent : Content
52         {
53                 public PokerContent ()
54                 {
55                         TrackViewState ();
56                 }
57                 public void DoOnDataBinding ()
58                 {
59                         base.OnDataBinding(new EventArgs()) ;
60                 }
61                 public void DoOnInit ()
62                 {
63                         base.OnInit (new EventArgs ());
64                 }
65                 public void DoOnLoad ()
66                 {
67                         base.OnLoad (new EventArgs ());
68                 }
69                 public void DoOnPreRender ()
70                 {
71                         base.OnPreRender (new EventArgs ());
72                 }
73                 public void DoOnUnLoad ()
74                 {
75                         base.OnUnload (new EventArgs ());
76                 }
77         }
78
79         
80         [TestFixture]
81         public class ContentTest
82         {
83                 [Test]
84                 public void Content_DefaultProperty ()
85                 {
86                         PokerContent pc = new PokerContent();
87                         Assert.AreEqual (String.Empty, pc.ContentPlaceHolderID, "ContentPlaceHolderID");
88                 }
89
90                 private bool OnDataBinding;
91                 private bool OnInit;
92                 private bool OnLoad;
93                 private bool OnPreRender;
94                 private bool OnUnLoad;
95
96                 private void OnUnLoadHendler (Object sender, EventArgs args)
97                 {
98                         OnUnLoad = true;
99                 }
100
101                 private void OnPreRenderHendler (Object sender, EventArgs args)
102                 {
103                         OnPreRender = true;
104                 }
105
106                 private void OnLoadHandler (Object sender, EventArgs args)
107                 {
108                         OnLoad = true;
109                 }
110
111                 private void OnDataBindingHandler (Object sender, EventArgs args)
112                 {
113                         OnDataBinding = true;
114                 }
115                 private void OnInitHandler (Object sender, EventArgs args)
116                 {
117                         OnInit = true;
118                 }
119
120                 [Test]
121                 public void Events_DataBinding ()
122                 {
123                         PokerContent pc = new PokerContent ();
124                         pc.DataBinding += new EventHandler (OnDataBindingHandler);
125                         // DataBiding event
126                         Assert.AreEqual (false, OnDataBinding, "BeforeDataBinding");
127                         pc.DoOnDataBinding ();
128                         Assert.AreEqual (true, OnDataBinding, "AfterDataBinding");
129                 }
130
131                 [Test]
132                 public void Events_Init ()
133                 {
134                         PokerContent pc = new PokerContent ();
135                         pc.Init += new EventHandler (OnInitHandler);
136                         // Init event
137                         Assert.AreEqual (false, OnInit, "BeforeInit");
138                         pc.DoOnInit ();
139                         Assert.AreEqual (true, OnInit, "AfterInit");
140                 }
141
142                 [Test]
143                 public void Events_PreRender ()
144                 {
145                         PokerContent pc = new PokerContent ();
146                         pc.PreRender += new EventHandler (OnPreRenderHendler);
147                         // PreRender event
148                         Assert.AreEqual (false, OnPreRender, "BeforePreRender");
149                         pc.DoOnPreRender ();
150                         Assert.AreEqual (true, OnPreRender, "AfterPreRender");
151                 }
152
153                 [Test]
154                 public void Events_Load ()
155                 {
156                         PokerContent pc = new PokerContent ();
157                         pc.Load += new EventHandler (OnLoadHandler);
158                         // Load event
159                         Assert.AreEqual (false, OnLoad, "BeforeLoad");
160                         pc.DoOnLoad ();
161                         Assert.AreEqual (true, OnLoad, "AfterLoad");
162                 }
163
164                 [Test]
165                 public void Events_Unload ()
166                 {
167                         PokerContent pc = new PokerContent ();
168                         pc.Unload += new EventHandler (OnUnLoadHendler);
169                         // Unload event
170                         Assert.AreEqual (false, OnUnLoad, "BeforeUnLoad");
171                         pc.DoOnUnLoad ();
172                         Assert.AreEqual (true, OnUnLoad, "AfterUnLoad");
173                 }
174                         
175                 [Test]
176                 [ExpectedException (typeof(NotSupportedException))]
177                 public void Content_PropertyExeption ()
178                 {
179                         PokerContent pc = new PokerContent ();
180                         pc.ContentPlaceHolderID = "fake";
181                 }
182
183         }
184 }
185 #endif