RepeatInfoTest.gen.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. //
  2. // Autogen RepeatInfoTest.auto.cs
  3. //
  4. // Author:
  5. // Ben Maurer <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System.Web;
  29. using System.Web.UI;
  30. using System.Web.UI.WebControls;
  31. using System;
  32. using System.IO;
  33. class X {
  34. //
  35. // KEEP THIS IN SYNC WITH THE ONE IN QUOTES!
  36. //
  37. public class RepeatInfoUser : IRepeatInfoUser {
  38. private bool footer;
  39. private bool header;
  40. private bool separators;
  41. private int count;
  42. private int counter;
  43. public RepeatInfoUser (bool header, bool footer, bool separators, int count)
  44. {
  45. this.footer = footer;
  46. this.header = header;
  47. this.separators = separators;
  48. this.count = count;
  49. }
  50. static HtmlTextWriter GetWriter ()
  51. {
  52. StringWriter sw = new StringWriter ();
  53. sw.NewLine = "\n";
  54. return new HtmlTextWriter (sw);
  55. }
  56. public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
  57. {
  58. HtmlTextWriter htw = GetWriter ();
  59. RepeatInfo ri = new RepeatInfo ();
  60. ri.RepeatColumns = cols;
  61. ri.RepeatDirection = d;
  62. ri.RepeatLayout = l;
  63. ri.OuterTableImplied = OuterTableImplied;
  64. // get some variation in if we use style or not
  65. Style s = new Style ();
  66. if (cols != 3)
  67. s.CssClass = "mainstyle";
  68. ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
  69. return htw.InnerWriter.ToString ();
  70. }
  71. public bool HasFooter {
  72. get { return footer; }
  73. }
  74. public bool HasHeader {
  75. get { return header; }
  76. }
  77. public bool HasSeparators {
  78. get { return separators; }
  79. }
  80. public int RepeatedItemCount {
  81. get { return count; }
  82. }
  83. public Style GetItemStyle (ListItemType itemType, int repeatIndex)
  84. {
  85. Style s = new Style ();
  86. s.CssClass = String.Format ("{0}{1}", itemType, repeatIndex);
  87. return s;
  88. }
  89. public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
  90. {
  91. writer.Write ("({0},{1},{2})", counter++, itemType, repeatIndex);
  92. }
  93. }
  94. static void Main ()
  95. {
  96. #if NET_2_0
  97. Console.WriteLine ("#if NET_2_0");
  98. #else
  99. Console.WriteLine ("#if !NET_2_0");
  100. #endif
  101. Console.WriteLine (@"
  102. // THIS IS AUTOGENERATED DO NOT EDIT
  103. //
  104. // Authors:
  105. // Ben Maurer ([email protected])
  106. //
  107. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  108. //
  109. // Permission is hereby granted, free of charge, to any person obtaining
  110. // a copy of this software and associated documentation files (the
  111. // ""Software""), to deal in the Software without restriction, including
  112. // without limitation the rights to use, copy, modify, merge, publish,
  113. // distribute, sublicense, and/or sell copies of the Software, and to
  114. // permit persons to whom the Software is furnished to do so, subject to
  115. // the following conditions:
  116. //
  117. // The above copyright notice and this permission notice shall be
  118. // included in all copies or substantial portions of the Software.
  119. //
  120. // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
  121. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  122. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  123. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  124. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  125. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  126. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  127. //
  128. using System;
  129. using System.Collections;
  130. using System.ComponentModel;
  131. using System.Drawing;
  132. using System.IO;
  133. using System.Web;
  134. using System.Web.UI;
  135. using System.Web.UI.WebControls;
  136. using NUnit.Framework;
  137. namespace MonoTests.System.Web.UI.WebControls {
  138. [TestFixture]
  139. public class RepeatInfo_Autogen {
  140. public class RepeatInfoUser : IRepeatInfoUser {
  141. private bool footer;
  142. private bool header;
  143. private bool separators;
  144. private int count;
  145. private int counter;
  146. public RepeatInfoUser (bool header, bool footer, bool separators, int count)
  147. {
  148. this.footer = footer;
  149. this.header = header;
  150. this.separators = separators;
  151. this.count = count;
  152. }
  153. static HtmlTextWriter GetWriter ()
  154. {
  155. StringWriter sw = new StringWriter ();
  156. sw.NewLine = ""\n"";
  157. return new HtmlTextWriter (sw);
  158. }
  159. public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
  160. {
  161. HtmlTextWriter htw = GetWriter ();
  162. RepeatInfo ri = new RepeatInfo ();
  163. ri.RepeatColumns = cols;
  164. ri.RepeatDirection = d;
  165. ri.RepeatLayout = l;
  166. ri.OuterTableImplied = OuterTableImplied;
  167. Style s = new Style ();
  168. if (cols != 3)
  169. s.CssClass = ""mainstyle"";
  170. ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
  171. return htw.InnerWriter.ToString ();
  172. }
  173. public bool HasFooter {
  174. get { return footer; }
  175. }
  176. public bool HasHeader {
  177. get { return header; }
  178. }
  179. public bool HasSeparators {
  180. get { return separators; }
  181. }
  182. public int RepeatedItemCount {
  183. get { return count; }
  184. }
  185. public Style GetItemStyle (ListItemType itemType, int repeatIndex)
  186. {
  187. Style s = new Style ();
  188. s.CssClass = String.Format (""{0}{1}"", itemType, repeatIndex);
  189. return s;
  190. }
  191. public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
  192. {
  193. writer.Write (""({0},{1},{2})"", counter++, itemType, repeatIndex);
  194. }
  195. }");
  196. int num = 0;
  197. int [][] combos = {
  198. new int [] {0, 0},
  199. new int [] {0, 1},
  200. new int [] {0, 2},
  201. new int [] {0, 5},
  202. new int [] {1, 0},
  203. new int [] {1, 5},
  204. new int [] {2, 4},
  205. new int [] {2, 7},
  206. new int [] {3, 9},
  207. new int [] {3, 7}
  208. };
  209. for (int i = 0; i < (1 << 6); i ++) {
  210. RepeatDirection d = (RepeatDirection) (i & (1 << 0));
  211. RepeatLayout l = (RepeatLayout) ((i & (1 << 1)) >> 1);
  212. bool oti = (i & (1 << 2)) == 0;
  213. bool hdr = (i & (1 << 3)) == 0;
  214. bool ftr = (i & (1 << 4)) == 0;
  215. bool sep = (i & (1 << 5)) == 0;
  216. foreach (int [] col_cnt in combos) {
  217. string nm = String.Format ("RepeatInfo_{0}cols_{1}itms_{2}_{3}{4}{5}{6}{7}",
  218. col_cnt [0],
  219. col_cnt [1],
  220. d == RepeatDirection.Vertical ? "vert" : "horiz",
  221. l == RepeatLayout.Flow ? "flow" : "tbl",
  222. oti ? "_otrtblimp" : "",
  223. hdr ? "_hdr" : "",
  224. ftr ? "_ftr" : "",
  225. sep ? "_sep" : "");
  226. Console.WriteLine (@"
  227. [Test]
  228. public void {0} ()
  229. {{
  230. // cols : {1}
  231. // cnt : {2}
  232. // RepeatDirection : {3}
  233. // RepeatLayout : {4}
  234. // OuterTableImplied : {5}
  235. // Header : {6}
  236. // Footer : {7}
  237. // Separator : {8}
  238. ",
  239. nm,
  240. col_cnt [0],
  241. col_cnt [1],
  242. d,
  243. l,
  244. oti,
  245. hdr,
  246. ftr,
  247. sep
  248. );
  249. string exp = RepeatInfoUser.DoTest (col_cnt [0], col_cnt [1], d, l, oti, hdr, ftr, sep).Replace (@"""", @"""""");
  250. Console.WriteLine (@"
  251. string v = RepeatInfoUser.DoTest ({0}, {1}, RepeatDirection.{2}, RepeatLayout.{3}, {4}, {5}, {6}, {7});
  252. string exp = @""{8}"";
  253. Assert.AreEqual (exp, v, ""#{9}"");
  254. }}
  255. ",
  256. col_cnt [0],
  257. col_cnt [1],
  258. d,
  259. l,
  260. oti ? "true" : "false",
  261. hdr ? "true" : "false",
  262. ftr ? "true" : "false",
  263. sep ? "true" : "false",
  264. exp,
  265. num ++
  266. );
  267. }
  268. }
  269. Console.WriteLine (@"
  270. }
  271. }
  272. #endif");
  273. }
  274. }