2 // Tests for System.Web.UI.WebControls.DataSourceControlTest.cs
5 // Yoni Klein (yonik@mainsoft.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
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.
35 using System.Web.UI.WebControls;
36 using System.Collections;
37 using System.ComponentModel;
38 using NUnit.Framework;
41 namespace MonoTests.System.Web.UI.WebControls
43 public class PokerDataSource : DataSourceControl
46 public PokerDataSource ()
52 public ICollection DoGetViewNames()
54 return base.GetViewNames();
57 public ControlCollection DoCreateControlCollection ()
59 return base.CreateControlCollection ();
61 public void DoRaiseDataSourceChangedEvent (EventArgs e)
63 base.RaiseDataSourceChangedEvent (e);
66 protected override DataSourceView GetView (string viewName)
68 throw new Exception ("The method or operation is not implemented.");
73 public class DataSourceControlTest
77 public void DataSourceControl_DefaultProperty ()
79 PokerDataSource ds = new PokerDataSource ();
80 Assert.AreEqual (null, ds.ClientID, "ClientID");
81 Assert.IsNotNull (ds.Controls, "Controls#1");
82 Assert.AreEqual ( 0 , ds.Controls.Count , "Controls#2");
83 Assert.AreEqual (false, ds.Visible, "Visible");
87 public void DataSourceControl_DefaultPropertyNotWorking ()
89 PokerDataSource ds = new PokerDataSource ();
90 Assert.AreEqual (false, ds.EnableTheming, "EnableTheming");
94 public void DataSourceControl_ApplyStyleSheetSkin ()
96 // DataSourceControl EnableTheme property always set to false
97 // and have no render issue - this method would do nothing
101 public void DataSourceControl_FindControl ()
103 // DataSourceControl cannot have child controls on ControlCollection
104 // this method cannot be applyed
108 [ExpectedException (typeof (NotSupportedException))]
109 public void DataSourceControl_Focus ()
111 PokerDataSource ds = new PokerDataSource ();
116 public void DataSourceControl_HasControls ()
118 //Always return false
119 PokerDataSource ds = new PokerDataSource ();
120 Assert.AreEqual (false, ds.HasControls (), "HasControls");
124 public void DataSourceControl_CreateControlCollection ()
126 PokerDataSource ds = new PokerDataSource ();
127 ControlCollection collection = ds.DoCreateControlCollection ();
128 Assert.IsNotNull (collection, "CreateControlCollection#1");
129 Assert.AreEqual (0, collection.Count ,"CreateControlCollection#2");
133 public void DataSourceControl_GetViewNames ()
135 PokerDataSource ds = new PokerDataSource ();
136 ICollection viewnames = ds.DoGetViewNames ();
137 Assert.IsNull (viewnames, "GetViewNames#1");
142 [ExpectedException (typeof (HttpException))]
143 public void DataSourceControl_Controls ()
145 Button bt = new Button ();
147 PokerDataSource ds = new PokerDataSource ();
148 ds.Controls.Add (bt);
153 [ExpectedException (typeof (NotSupportedException))]
154 public void DataSourceControl_EnableThemingException ()
156 PokerDataSource ds = new PokerDataSource ();
157 ds.EnableTheming = true;
161 [ExpectedException (typeof (NotSupportedException))]
162 public void DataSourceControl_VisibleException ()
164 PokerDataSource ds = new PokerDataSource ();
170 public void DataSourceControl_Events ()
172 PokerDataSource ds = new PokerDataSource ();
173 ((IDataSource) ds).DataSourceChanged += new EventHandler (Eventchecker);
174 ds.DoRaiseDataSourceChangedEvent (new EventArgs ());
175 Eventassert("RaiseDataSourceChangedEventFail");
179 // Helper for event checking
180 private bool event_checker;
182 private void Eventchecker (object o, EventArgs e)
184 event_checker = true;
187 private void Eventassert (string message)
189 Assert.IsTrue (event_checker, message);
190 event_checker = false;