2 // Tests for System.Web.UI.WebControls.Repeater.cs
5 // Chris Toshok (toshok@novell.com)
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
31 using NUnit.Framework;
34 using System.Globalization;
37 using System.Web.UI.WebControls;
\r
38 using MonoTests.SystemWeb.Framework;
\r
39 using System.Collections;
41 namespace MonoTests.System.Web.UI.WebControls
44 public class RepeaterTest {
45 class Poker : Repeater {
47 public void TrackState ()
52 public object SaveState ()
54 return SaveViewState ();
57 public void LoadState (object o)
63 public DataSourceSelectArguments GetSelectArguments()
65 return SelectArguments;
68 public DataSourceSelectArguments DoCreateDataSourceSelectArguments ()
70 return base.CreateDataSourceSelectArguments();
73 public new void EnsureDataBound ()
\r
75 base.EnsureDataBound ();
\r
78 public global::System.Collections.IEnumerable DoGetData ()
\r
80 return base.GetData ();
\r
83 public new bool Initialized
\r
85 get { return base.Initialized; }
\r
88 public new bool IsBoundUsingDataSourceID
\r
90 get { return base.IsBoundUsingDataSourceID; }
\r
93 protected override void OnDataPropertyChanged ()
\r
95 eventChecker = true;
\r
96 base.OnDataPropertyChanged ();
\r
99 public void DoOnDataSourceViewChanged (object sender, EventArgs e)
\r
101 base.OnDataSourceViewChanged (sender, e);
\r
104 public new bool RequiresDataBinding
\r
106 get { return base.RequiresDataBinding; }
\r
107 set { base.RequiresDataBinding = value; }
\r
111 public bool EventChecker
\r
113 get { return eventChecker; }
\r
114 set { throw new NotImplementedException (); }
\r
117 public void clearEvents ()
\r
119 eventChecker = false;
\r
126 public void Repeater_DefaultsSelectArguments ()
128 Poker p = new Poker ();
129 DataSourceSelectArguments args, args2;
131 args = p.GetSelectArguments();
132 args2 = p.DoCreateDataSourceSelectArguments();
134 Assert.AreEqual (args, args2, "call == prop");
136 Assert.IsNotNull (args, "property null check");
137 Assert.IsTrue (args != DataSourceSelectArguments.Empty, "property != Empty check");
138 Assert.IsTrue (args.Equals (DataSourceSelectArguments.Empty), "property but they are empty check");
140 Assert.IsNotNull (args2, "method null check");
141 Assert.IsTrue (args2 != DataSourceSelectArguments.Empty, "method != Empty check");
142 Assert.IsTrue (args2.Equals (DataSourceSelectArguments.Empty), "method but they are empty check");
144 /* check to see whether multiple calls give us different refs */
145 args = p.DoCreateDataSourceSelectArguments();
147 Assert.AreEqual (args, args2, "multiple calls, same ref");
\r
148 Assert.AreEqual (string.Empty, p.DataSourceID, "DataSourceID");
\r
149 Assert.AreEqual (false, p.RequiresDataBinding, "RequiresDataBinding");
153 [Category ("NotWorking")]
\r
154 public void Repeater_DefaultsNotWorking ()
\r
156 Poker p = new Poker ();
\r
157 Assert.AreEqual (true, p.EnableTheming, "EnableTheming");
\r
163 [Category("NunitWeb")]
\r
164 [ExpectedException(typeof(HttpException))]
\r
165 public void EnsureDataBound ()
\r
167 WebTest t = new WebTest (PageInvoker.CreateOnInit (EnsureDataBound_Init));
\r
168 string html = t.Run ();
\r
171 public static void EnsureDataBound_Init (Page p)
\r
173 Poker r = new Poker ();
\r
174 r.DataSourceID = "Fake";
\r
175 p.Form.Controls.Add (r);
\r
176 r.EnsureDataBound ();
\r
180 [Category ("NotWorking")]
\r
181 public void GetData ()
\r
183 Poker p = new Poker ();
\r
184 p.DataSource = Databound ();
\r
185 ArrayList data = (ArrayList)p.DoGetData ();
\r
186 Assert.AreEqual (3, data.Count, "GetData#1");
\r
187 Assert.AreEqual (1, data[0], "GetData#2");
\r
191 static ArrayList Databound ()
\r
193 ArrayList list = new ArrayList ();
\r
202 [Category ("NotWorking")]
\r
203 [Category ("NunitWeb")]
\r
204 public void Initialized ()
\r
206 WebTest t = new WebTest ();
\r
207 PageDelegates pd = new PageDelegates ();
\r
208 pd.Init = new PageDelegate (Initialized_Init);
\r
209 pd.Load = new PageDelegate (Initialized_Load);
\r
210 t.Invoker = new PageInvoker (pd);
\r
211 string html = t.Run ();
\r
214 public static void Initialized_Init (Page p)
\r
216 Poker r = new Poker ();
\r
218 Assert.AreEqual (false, r.Initialized, "Initialized#1");
\r
219 r.DataSource = Databound ();
\r
220 p.Form.Controls.Add (r);
\r
223 public static void Initialized_Load (Page p)
\r
225 Poker r = p.FindControl ("Rep") as Poker;
\r
226 Assert.AreEqual (true, r.Initialized, "Initialized#2");
\r
230 public void IsBoundUsingDataSourceID ()
\r
232 Poker p = new Poker ();
\r
233 Assert.AreEqual (false, p.IsBoundUsingDataSourceID, "IsBoundUsingDataSourceID#1");
\r
234 p.DataSourceID = "Fake";
\r
235 Assert.AreEqual (true, p.IsBoundUsingDataSourceID, "IsBoundUsingDataSourceID#2");
\r
239 public void OnDataPropertyChanged ()
\r
241 Poker p = new Poker ();
\r
243 p.DataSourceID = "Fake";
\r
244 Assert.AreEqual (true, p.EventChecker, "OnDataPropertyChanged#1");
\r
248 public void OnDataSourceViewChanged ()
\r
250 Poker p = new Poker ();
\r
251 Assert.AreEqual (false, p.RequiresDataBinding, "OnDataSourceViewChanged#1");
\r
252 p.DoOnDataSourceViewChanged (p, new EventArgs ());
\r
253 Assert.AreEqual (true, p.RequiresDataBinding, "OnDataSourceViewChanged#2");
\r
256 #region help_class_for_select_args
\r
257 class PokerS : Repeater
\r
260 public void TrackState ()
\r
265 public object SaveState ()
\r
267 return SaveViewState ();
\r
270 public void LoadState (object o)
\r
276 public DataSourceSelectArguments GetSelectArguments ()
\r
278 return SelectArguments;
\r
281 protected override DataSourceSelectArguments CreateDataSourceSelectArguments ()
\r
283 DataSourceSelectArguments arg = new DataSourceSelectArguments ("SortExp");
\r
291 [Category ("NotWorking")]
\r
292 public void GetSelectArguments ()
\r
294 PokerS p = new PokerS ();
\r
295 DataSourceSelectArguments arg = p.GetSelectArguments ();
\r
296 Assert.AreEqual ("SortExp", arg.SortExpression, "GetSelectArguments");
\r
299 [TestFixtureTearDown]
\r
300 public void TearDown ()
\r