3 // - Unit tests for System.Web.UI.WebControls.BaseDataList
6 // Sebastien Pouliot <sebastien@ximian.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.
31 using System.Collections;
32 using System.Collections.Specialized;
33 using System.ComponentModel;
37 using System.Web.UI.WebControls;
39 using NUnit.Framework;
41 namespace MonoTests.System.Web.UI.WebControls {
43 public class TestBaseDataList : BaseDataList {
45 private bool dataBindingCalled;
48 public TestBaseDataList ()
54 get { return base.TagName; }
57 public StateBag StateBag {
58 get { return base.ViewState; }
61 public bool IsDataBoundByDataSourceId {
62 get { return base.IsBoundUsingDataSourceID; }
65 public bool IsInitialized {
66 get { return base.Initialized; }
69 public bool RequiresDataBind {
70 get { return base.RequiresDataBinding; }
73 public DataSourceSelectArguments Arguments {
74 get { return base.SelectArguments; }
77 public void Add (object o)
79 base.AddParsedSubObject (o);
82 public string Render ()
84 StringWriter sw = new StringWriter ();
86 HtmlTextWriter writer = new HtmlTextWriter (sw);
88 return writer.InnerWriter.ToString ();
91 protected override void CreateControlHierarchy (bool useDataSource)
95 protected override void PrepareControlHierarchy ()
99 public void DoSelectedIndexChanged (EventArgs e)
101 OnSelectedIndexChanged (e);
104 public DataSourceSelectArguments CreateArguments ()
106 return base.CreateDataSourceSelectArguments ();
109 public IEnumerable Data ()
111 return base.GetData ();
114 public void DataBindBool (bool raise)
119 public void Ensure ()
121 base.EnsureDataBound ();
124 public bool DataBindingCalled {
125 get { return dataBindingCalled; }
126 set { dataBindingCalled = value; }
129 protected override void OnDataBinding (EventArgs e)
131 dataBindingCalled = true;
132 base.OnDataBinding (e);
135 private bool dataPropertyChangedCalled;
136 private bool dataSourceViewChangedCalled;
137 private bool initCalled;
138 private bool loadCalled;
139 private bool preRenderCalled;
141 public bool DataPropertyChangedCalled {
142 get { return dataPropertyChangedCalled; }
143 set { dataPropertyChangedCalled = value; }
146 protected override void OnDataPropertyChanged ()
148 dataPropertyChangedCalled = true;
149 base.OnDataPropertyChanged ();
152 public bool DataSourceViewChangedCalled {
153 get { return dataSourceViewChangedCalled; }
154 set { dataSourceViewChangedCalled = value; }
157 protected override void OnDataSourceViewChanged (object sender, EventArgs e)
159 dataSourceViewChangedCalled = true;
160 base.OnDataSourceViewChanged (sender, e);
163 public void BaseOnDataSourceViewChanged (object sender, EventArgs e)
165 base.OnDataSourceViewChanged (sender, e);
168 public bool InitCalled {
169 get { return initCalled; }
170 set { initCalled = value; }
173 protected override void OnInit (EventArgs e)
179 public void BaseOnInit (EventArgs e)
184 public bool LoadCalled {
185 get { return loadCalled; }
186 set { loadCalled = value; }
189 protected override void OnLoad (EventArgs e)
195 public void BaseOnLoad (EventArgs e)
200 public bool PreRenderCalled {
201 get { return preRenderCalled; }
202 set { preRenderCalled = value; }
205 protected override void OnPreRender (EventArgs e)
207 preRenderCalled = true;
208 base.OnPreRender (e);
211 public void BaseOnPreRender (EventArgs e)
213 base.OnPreRender (e);
218 public class TestDataSource : IListSource {
220 private ArrayList list;
223 public TestDataSource (ArrayList al)
229 public bool ContainsListCollection {
233 public IList GetList ()
240 public class Test2DataSource : WebControl, IDataSource {
242 public DataSourceView GetView (string viewName)
244 return new Test2DataSourceView (this, String.Empty);
247 public ICollection GetViewNames ()
252 public event EventHandler DataSourceChanged;
255 public class Test2DataSourceView : DataSourceView {
257 public Test2DataSourceView (IDataSource owner, string viewName)
258 : base (owner, viewName)
262 protected override IEnumerable ExecuteSelect (DataSourceSelectArguments arguments)
264 ArrayList al = new ArrayList (3);
265 for (int i=0; i < 3; i++)
273 public class BaseDataListTest {
275 private HtmlTextWriter GetWriter ()
277 StringWriter sw = new StringWriter ();
279 return new HtmlTextWriter (sw);
282 // IEnumerable (and IList) based
283 private IEnumerable GetData (int n)
285 ArrayList al = new ArrayList ();
286 for (int i = 0; i < n; i++) {
287 al.Add (i.ToString ());
289 return (IEnumerable) al;
293 private TestDataSource GetDataSource (int n)
295 return new TestDataSource ((ArrayList)GetData (n));
299 public void DefaultProperties ()
301 TestBaseDataList bdl = new TestBaseDataList ();
302 Assert.AreEqual ("span", bdl.Tag, "TagName");
304 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-1");
305 Assert.AreEqual (0, bdl.StateBag.Count, "ViewState.Count-1");
307 Assert.AreEqual (String.Empty, bdl.Caption, "Caption");
308 Assert.AreEqual (TableCaptionAlign.NotSet, bdl.CaptionAlign, "CaptionAlign");
309 Assert.AreEqual (-1, bdl.CellPadding, "CellPadding");
310 Assert.AreEqual (0, bdl.CellSpacing, "CellSpacing");
311 Assert.AreEqual (0, bdl.Controls.Count, "Controls.Count");
312 Assert.AreEqual (String.Empty, bdl.DataKeyField, "DataKeyField");
313 Assert.AreEqual (String.Empty, bdl.DataMember, "DataMember");
314 Assert.IsNull (bdl.DataSource, "DataSource");
315 Assert.AreEqual (GridLines.Both, bdl.GridLines, "GridLines");
316 Assert.AreEqual (HorizontalAlign.NotSet, bdl.HorizontalAlign, "HorizontalAlign");
317 Assert.IsFalse (bdl.UseAccessibleHeader, "UseAccessibleHeader");
319 Assert.AreEqual (String.Empty, bdl.DataSourceID, "DataSourceID");
321 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-2");
322 Assert.AreEqual (0, bdl.StateBag.Count, "ViewState.Count-2");
324 Assert.AreEqual (0, bdl.DataKeys.Count, "DataKeys.Count");
325 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-3");
326 // triggered by DataKeys, which makes DataKeysArray store its value.
327 Assert.AreEqual (1, bdl.StateBag.Count, "ViewState.Count-3");
328 Assert.AreEqual (typeof (ArrayList), bdl.StateBag ["DataKeys"].GetType (), "ViewState.Value-1");
332 public void NullProperties ()
334 TestBaseDataList bdl = new TestBaseDataList ();
335 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-1");
336 Assert.AreEqual (0, bdl.StateBag.Count, "ViewState.Count-1");
339 Assert.AreEqual (String.Empty, bdl.Caption, "Caption");
340 bdl.CaptionAlign = TableCaptionAlign.NotSet;
341 Assert.AreEqual (TableCaptionAlign.NotSet, bdl.CaptionAlign, "CaptionAlign");
342 Assert.AreEqual (1, bdl.StateBag.Count, "ViewState.Count-2");
344 // many properties can't be set without causing a InvalidCastException
346 bdl.DataKeyField = null;
347 Assert.AreEqual (String.Empty, bdl.DataKeyField, "DataKeyField");
348 bdl.DataMember = null;
349 Assert.AreEqual (String.Empty, bdl.DataMember, "DataMember");
350 bdl.DataSource = null;
351 Assert.IsNull (bdl.DataSource, "DataSource");
352 bdl.UseAccessibleHeader = false;
353 Assert.IsFalse (bdl.UseAccessibleHeader, "UseAccessibleHeader");
355 bdl.DataSourceID = String.Empty;
356 Assert.AreEqual (String.Empty, bdl.DataSourceID, "DataSourceID");
357 Assert.AreEqual (3, bdl.StateBag.Count, "ViewState.Count-3");
359 Assert.AreEqual (2, bdl.StateBag.Count, "ViewState.Count-3");
361 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-2");
365 public void CleanProperties ()
367 TestBaseDataList bdl = new TestBaseDataList ();
369 bdl.Caption = "Mono";
370 Assert.AreEqual ("Mono", bdl.Caption, "Caption");
371 bdl.CaptionAlign = TableCaptionAlign.Top;
372 Assert.AreEqual (TableCaptionAlign.Top, bdl.CaptionAlign, "CaptionAlign");
373 // many properties can't be set without causing a InvalidCastException
374 bdl.DataKeyField = "key";
375 Assert.AreEqual ("key", bdl.DataKeyField, "DataKeyField");
376 bdl.DataMember = "member";
377 Assert.AreEqual ("member", bdl.DataMember, "DataMember");
378 bdl.DataSource = GetData (2);
379 Assert.IsNotNull (bdl.DataSource, "DataSource");
380 bdl.UseAccessibleHeader = true;
381 Assert.IsTrue (bdl.UseAccessibleHeader, "UseAccessibleHeader");
383 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-1");
384 Assert.AreEqual (5, bdl.StateBag.Count, "ViewState.Count-1");
387 Assert.AreEqual (String.Empty, bdl.Caption, "-Caption");
388 bdl.CaptionAlign = TableCaptionAlign.NotSet;
389 Assert.AreEqual (TableCaptionAlign.NotSet, bdl.CaptionAlign, "-CaptionAlign");
390 // many properties can't be set without causing a InvalidCastException
391 bdl.DataKeyField = null;
392 Assert.AreEqual (String.Empty, bdl.DataKeyField, "-DataKeyField");
393 bdl.DataMember = null;
394 Assert.AreEqual (String.Empty, bdl.DataMember, "-DataMember");
395 bdl.DataSource = null;
396 Assert.IsNull (bdl.DataSource, "-DataSource");
397 bdl.UseAccessibleHeader = false;
398 Assert.IsFalse (bdl.UseAccessibleHeader, "-UseAccessibleHeader");
400 Assert.AreEqual (0, bdl.Attributes.Count, "Attributes.Count-2");
401 // CaptionAlign and UseAccessibleHeader aren't removed
402 Assert.AreEqual (2, bdl.StateBag.Count, "ViewState.Count-2");
406 public void TableCaption ()
408 TestBaseDataList bdl = new TestBaseDataList ();
409 foreach (TableCaptionAlign tca in Enum.GetValues (typeof (TableCaptionAlign))) {
410 bdl.CaptionAlign = tca;
415 [ExpectedException (typeof (ArgumentOutOfRangeException))]
416 public void TableCaption_Int32MaxValue ()
418 TestBaseDataList bdl = new TestBaseDataList ();
419 bdl.CaptionAlign = (TableCaptionAlign)Int32.MaxValue;
423 public void DataSource_IEnumerable ()
425 TestBaseDataList bdl = new TestBaseDataList ();
426 bdl.DataSource = GetData (2);
427 Assert.IsNotNull (bdl.DataSource, "DataSource");
431 public void DataSource_IListSource ()
433 TestBaseDataList bdl = new TestBaseDataList ();
434 bdl.DataSource = GetDataSource (3);
435 Assert.IsNotNull (bdl.DataSource, "DataSource");
439 [ExpectedException (typeof (ArgumentException))]
440 public void DataSource_Other ()
442 TestBaseDataList bdl = new TestBaseDataList ();
443 bdl.DataSource = new object ();
446 // CreateControlStyle isn't overriden so we can't assign it's properties
449 [ExpectedException (typeof (InvalidCastException))]
450 public void CellPadding_InvalidCastException ()
452 TestBaseDataList bdl = new TestBaseDataList ();
453 Assert.AreEqual (-1, bdl.CellPadding, "CellPadding");
454 bdl.CellPadding = -1;
458 [ExpectedException (typeof (InvalidCastException))]
459 public void CellSpacing_InvalidCastException ()
461 TestBaseDataList bdl = new TestBaseDataList ();
462 Assert.AreEqual (0, bdl.CellSpacing, "CellSpacing");
467 [ExpectedException (typeof (InvalidCastException))]
468 public void GridLines_InvalidCastException ()
470 TestBaseDataList bdl = new TestBaseDataList ();
471 Assert.AreEqual (GridLines.Both, bdl.GridLines, "GridLines");
472 bdl.GridLines = GridLines.Both;
476 [ExpectedException (typeof (InvalidCastException))]
477 public void HorizontalAlign_InvalidCastException ()
479 TestBaseDataList bdl = new TestBaseDataList ();
480 Assert.AreEqual (HorizontalAlign.NotSet, bdl.HorizontalAlign, "HorizontalAlign");
481 bdl.HorizontalAlign = HorizontalAlign.NotSet;
485 [ExpectedException (typeof (NullReferenceException))]
486 public void IsBindableType_Null ()
488 BaseDataList.IsBindableType (null);
492 public void AddParsedSubObject ()
494 TestBaseDataList bdl = new TestBaseDataList ();
496 bdl.Add (new LiteralControl ("mono"));
497 bdl.Add (new DataListItem (0, ListItemType.Item));
498 bdl.Add (String.Empty);
499 bdl.Add (new Control ());
500 Assert.AreEqual (0, bdl.Controls.Count, "Controls");
501 Assert.AreEqual (0, bdl.StateBag.Count, "StateBag");
505 public void Render_Empty ()
507 TestBaseDataList bdl = new TestBaseDataList ();
508 Assert.AreEqual (String.Empty, bdl.Render ());
512 public void Render ()
514 TestBaseDataList bdl = new TestBaseDataList ();
515 bdl.DataSource = GetDataSource (3);
517 Assert.AreEqual (String.Empty, bdl.Render ());
520 private bool selectedIndexChangedEvent;
522 private void SelectedIndexChangedHandler (object sender, EventArgs e)
524 selectedIndexChangedEvent = true;
528 public void Events ()
530 TestBaseDataList bdl = new TestBaseDataList ();
531 selectedIndexChangedEvent = false;
532 bdl.SelectedIndexChanged += new EventHandler (SelectedIndexChangedHandler);
533 bdl.DoSelectedIndexChanged (new EventArgs ());
534 Assert.IsTrue (selectedIndexChangedEvent, "selectedIndexChangedEvent");
538 public void OnDataBinding ()
540 // does DataBind calls base.OnDataBinding (like most sample do)
541 // or does it call the overriden OnDataBinding (which seems logical)
542 TestBaseDataList bdl = new TestBaseDataList ();
543 Assert.IsFalse (bdl.DataBindingCalled, "Before DataBind");
544 bdl.DataSource = GetDataSource (3);
546 Assert.IsTrue (bdl.DataBindingCalled, "After DataBind");
550 public void DataSourceID ()
552 TestBaseDataList bdl = new TestBaseDataList ();
553 Assert.IsFalse (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID-1");
554 bdl.DataSourceID = "mono";
555 Assert.IsTrue (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID-2");
557 Assert.IsTrue (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID-3");
561 // LAMESPEC ??? [ExpectedException (typeof (HttpException))]
562 [ExpectedException (typeof (InvalidOperationException))]
563 public void DataSourceID_WithDataSource ()
565 Page p = new Page ();
566 TestBaseDataList bdl = new TestBaseDataList ();
568 bdl.DataSource = GetDataSource (1);
570 Test2DataSource ds = new Test2DataSource ();
574 p.Controls.Add (bdl);
575 bdl.DataSourceID = "mono";
576 Assert.IsNotNull (bdl.Data (), "GetData");
580 [ExpectedException (typeof (HttpException))]
581 [Ignore ("LAMESPEC -and/or- bad test")]
582 public void DataSource_WithDataSourceID ()
584 Test2DataSource ds = new Test2DataSource ();
586 TestBaseDataList bdl = new TestBaseDataList ();
587 Page p = new Page ();
591 p.Controls.Add (bdl);
592 bdl.DataSourceID = "mono";
593 Assert.IsNotNull (bdl.Data (), "GetData");
595 bdl.DataSource = GetDataSource (1);
600 public void EnsureDataBound_WithoutDataSourceID ()
602 TestBaseDataList bdl = new TestBaseDataList ();
603 Assert.IsFalse (bdl.DataBindingCalled, "Before EnsureDataBound");
605 Assert.IsFalse (bdl.DataBindingCalled, "After EnsureDataBound");
609 public void EnsureDataBound_WithDataSourceID ()
611 XmlDataSource ds = new XmlDataSource ();
614 TestBaseDataList bdl = new TestBaseDataList ();
615 Page p = new Page ();
618 p.Controls.Add (bdl);
619 bdl.DataSourceID = "mono";
621 Assert.IsFalse (bdl.DataBindingCalled, "Before EnsureDataBound");
623 Assert.IsFalse (bdl.DataBindingCalled, "After EnsureDataBound");
625 bdl.BaseOnLoad (EventArgs.Empty);
627 Assert.IsTrue (bdl.DataBindingCalled, "After BaseOnLoad|RequiresDataBinding");
631 public void GetData ()
633 Test2DataSource ds = new Test2DataSource ();
635 TestBaseDataList bdl = new TestBaseDataList ();
636 Page p = new Page ();
640 p.Controls.Add (bdl);
641 bdl.DataSourceID = "mono";
642 Assert.IsNotNull (bdl.Data (), "GetData");
646 public void GetData_WithoutDataSourceID ()
648 TestBaseDataList bdl = new TestBaseDataList ();
649 Assert.IsNull (bdl.Data (), "GetData");
653 [ExpectedException (typeof (HttpException))]
654 public void GetData_WithUnexistingDataSourceID ()
656 TestBaseDataList bdl = new TestBaseDataList ();
657 bdl.Page = new Page ();
658 bdl.DataSourceID = "mono";
663 public void OnDataBinding_True ()
665 TestBaseDataList bdl = new TestBaseDataList ();
666 Assert.IsFalse (bdl.DataBindingCalled, "Before DataBind");
667 bdl.DataSource = GetDataSource (3);
668 bdl.DataBindBool (true);
669 Assert.IsTrue (bdl.DataBindingCalled, "After DataBind");
673 public void OnDataBinding_False ()
675 TestBaseDataList bdl = new TestBaseDataList ();
676 Assert.IsFalse (bdl.DataBindingCalled, "Before DataBind");
677 bdl.DataSource = GetDataSource (3);
678 bdl.DataBindBool (false);
679 Assert.IsFalse (bdl.DataBindingCalled, "After DataBind");
683 public void OnDataPropertyChanged ()
685 TestBaseDataList bdl = new TestBaseDataList ();
686 bdl.DataPropertyChangedCalled = false;
687 bdl.DataMember = String.Empty;
688 Assert.IsTrue (bdl.DataPropertyChangedCalled, "OnDataPropertyChanged-DataMember");
689 Assert.IsFalse (bdl.IsInitialized, "Initialized-DataMember");
691 bdl.DataPropertyChangedCalled = false;
692 bdl.DataSource = null;
693 Assert.IsTrue (bdl.DataPropertyChangedCalled, "OnDataPropertyChanged-DataSource");
694 Assert.IsFalse (bdl.IsInitialized, "Initialized-DataSource");
696 bdl.DataPropertyChangedCalled = false;
697 bdl.DataSourceID = String.Empty;
698 Assert.IsTrue (bdl.DataPropertyChangedCalled, "OnDataPropertyChanged-DataSourceID");
699 Assert.IsFalse (bdl.IsInitialized, "Initialized-DataSourceID");
703 public void OnInit ()
705 TestBaseDataList bdl = new TestBaseDataList ();
706 Assert.IsFalse (bdl.IsInitialized, "Initialized-1");
707 bdl.BaseOnInit (EventArgs.Empty);
708 Assert.IsFalse (bdl.IsInitialized, "Initialized-2");
709 // OnInit doesn't set Initialized to true
713 public void OnDataSourceViewChanged ()
715 TestBaseDataList bdl = new TestBaseDataList ();
716 Assert.IsFalse (bdl.RequiresDataBind, "RequiresDataBind-1");
717 bdl.BaseOnDataSourceViewChanged (this, EventArgs.Empty);
718 Assert.IsTrue (bdl.RequiresDataBind, "RequiresDataBind-2");
722 public void OnLoad_WithoutPage ()
724 TestBaseDataList bdl = new TestBaseDataList ();
726 Assert.IsFalse (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID");
727 Assert.IsTrue (bdl.EnableViewState, "EnabledViewState");
728 Assert.IsNull (bdl.Page, "Page");
729 bdl.BaseOnLoad (EventArgs.Empty);
730 Assert.IsTrue (bdl.IsInitialized, "IsInitialized");
731 Assert.IsFalse (bdl.RequiresDataBind, "RequiresDataBind");
735 public void OnLoad_WithoutPageWithoutViewState ()
737 TestBaseDataList bdl = new TestBaseDataList ();
738 bdl.EnableViewState = false;
740 Assert.IsFalse (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID");
741 Assert.IsFalse (bdl.EnableViewState, "EnabledViewState");
742 Assert.IsNull (bdl.Page, "Page");
743 bdl.BaseOnLoad (EventArgs.Empty);
744 Assert.IsTrue (bdl.IsInitialized, "IsInitialized");
745 Assert.IsFalse (bdl.RequiresDataBind, "RequiresDataBind");
749 public void OnLoad_WithPage ()
751 TestBaseDataList bdl = new TestBaseDataList ();
752 Page p = new Page ();
754 Assert.IsFalse (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID-2");
755 Assert.IsTrue (bdl.EnableViewState, "EnabledViewState-2");
756 Assert.IsFalse (bdl.Page.IsPostBack, "IsPostBack-2");
757 bdl.BaseOnLoad (EventArgs.Empty);
758 Assert.IsTrue (bdl.IsInitialized, "IsInitialized-2");
759 Assert.IsTrue (bdl.RequiresDataBind, "RequiresDataBind-2");
763 public void OnLoad_WithPageWithoutViewState ()
765 TestBaseDataList bdl = new TestBaseDataList ();
766 Page p = new Page ();
768 bdl.EnableViewState = false;
769 Assert.IsFalse (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID");
770 Assert.IsFalse (bdl.EnableViewState, "EnabledViewState");
771 Assert.IsFalse (bdl.Page.IsPostBack, "IsPostBack");
772 bdl.BaseOnLoad (EventArgs.Empty);
773 Assert.IsTrue (bdl.IsInitialized, "IsInitialized");
774 Assert.IsTrue (bdl.RequiresDataBind, "RequiresDataBind");
778 public void OnLoad_WithDataSource ()
780 XmlDataSource ds = new XmlDataSource ();
782 TestBaseDataList bdl = new TestBaseDataList ();
783 Page p = new Page ();
786 p.Controls.Add (bdl);
787 bdl.DataSourceID = "mono";
788 Assert.IsTrue (bdl.IsDataBoundByDataSourceId, "IsBoundUsingDataSourceID");
789 Assert.IsTrue (bdl.EnableViewState, "EnabledViewState");
790 Assert.IsFalse (bdl.Page.IsPostBack, "IsPostBack");
791 bdl.BaseOnLoad (EventArgs.Empty);
792 Assert.IsTrue (bdl.IsInitialized, "IsInitialized");
793 Assert.IsTrue (bdl.RequiresDataBind, "RequiresDataBind");
797 public void IsBindableType ()
800 Assert.IsTrue (BaseDataList.IsBindableType (typeof (bool)), "bool");
801 Assert.IsTrue (BaseDataList.IsBindableType (typeof (byte)), "byte");
802 Assert.IsTrue (BaseDataList.IsBindableType (typeof (sbyte)), "sbyte");
803 Assert.IsTrue (BaseDataList.IsBindableType (typeof (short)), "short");
804 Assert.IsTrue (BaseDataList.IsBindableType (typeof (ushort)), "ushort");
805 Assert.IsTrue (BaseDataList.IsBindableType (typeof (int)), "int");
806 Assert.IsTrue (BaseDataList.IsBindableType (typeof (uint)), "uint");
807 Assert.IsTrue (BaseDataList.IsBindableType (typeof (long)), "long");
808 Assert.IsTrue (BaseDataList.IsBindableType (typeof (ulong)), "ulong");
809 Assert.IsTrue (BaseDataList.IsBindableType (typeof (char)), "char");
810 Assert.IsTrue (BaseDataList.IsBindableType (typeof (double)), "double");
811 Assert.IsTrue (BaseDataList.IsBindableType (typeof (float)), "float");
812 Assert.IsTrue (BaseDataList.IsBindableType (typeof (DateTime)), "DateTime");
813 Assert.IsTrue (BaseDataList.IsBindableType (typeof (decimal)), "decimal");
814 Assert.IsTrue (BaseDataList.IsBindableType (typeof (string)), "string");
815 // and others (from TypeCode)
816 Assert.IsFalse (BaseDataList.IsBindableType (typeof (object)), "object");
817 Assert.IsFalse (BaseDataList.IsBindableType (typeof (DBNull)), "DBNull");
819 Assert.IsFalse (BaseDataList.IsBindableType (this.GetType ()), "this");