ContentTest.cs 4.7 KB

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