2 // Autogen RepeatInfoTest.auto.cs
5 // Ben Maurer <bmaurer@novell.com>
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
31 using System.Web.UI.WebControls;
38 // KEEP THIS IN SYNC WITH THE ONE IN QUOTES!
40 public class RepeatInfoUser : IRepeatInfoUser {
44 private bool separators;
49 public RepeatInfoUser (bool header, bool footer, bool separators, int count)
53 this.separators = separators;
57 static HtmlTextWriter GetWriter ()
59 StringWriter sw = new StringWriter ();
61 return new HtmlTextWriter (sw);
64 public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
66 HtmlTextWriter htw = GetWriter ();
67 RepeatInfo ri = new RepeatInfo ();
68 ri.RepeatColumns = cols;
69 ri.RepeatDirection = d;
71 ri.OuterTableImplied = OuterTableImplied;
72 // get some variation in if we use style or not
73 Style s = new Style ();
75 s.CssClass = "mainstyle";
77 ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
78 return htw.InnerWriter.ToString ();
82 public bool HasFooter {
83 get { return footer; }
86 public bool HasHeader {
87 get { return header; }
90 public bool HasSeparators {
91 get { return separators; }
94 public int RepeatedItemCount {
98 public Style GetItemStyle (ListItemType itemType, int repeatIndex)
100 Style s = new Style ();
101 s.CssClass = String.Format ("{0}{1}", itemType, repeatIndex);
105 public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
107 writer.Write ("({0},{1},{2})", counter++, itemType, repeatIndex);
114 Console.WriteLine ("#if NET_2_0");
116 Console.WriteLine ("#if !NET_2_0");
119 Console.WriteLine (@"
120 // THIS IS AUTOGENERATED DO NOT EDIT
123 // Ben Maurer (bmaurer@novell.com)
125 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
127 // Permission is hereby granted, free of charge, to any person obtaining
128 // a copy of this software and associated documentation files (the
129 // ""Software""), to deal in the Software without restriction, including
130 // without limitation the rights to use, copy, modify, merge, publish,
131 // distribute, sublicense, and/or sell copies of the Software, and to
132 // permit persons to whom the Software is furnished to do so, subject to
133 // the following conditions:
135 // The above copyright notice and this permission notice shall be
136 // included in all copies or substantial portions of the Software.
138 // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
139 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
140 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
141 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
142 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
143 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
144 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
148 using System.Collections;
149 using System.ComponentModel;
150 using System.Drawing;
154 using System.Web.UI.WebControls;
156 using NUnit.Framework;
157 namespace MonoTests.System.Web.UI.WebControls {
159 public class RepeatInfo_Autogen {
160 public class RepeatInfoUser : IRepeatInfoUser {
164 private bool separators;
169 public RepeatInfoUser (bool header, bool footer, bool separators, int count)
171 this.footer = footer;
172 this.header = header;
173 this.separators = separators;
177 static HtmlTextWriter GetWriter ()
179 StringWriter sw = new StringWriter ();
181 return new HtmlTextWriter (sw);
184 public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
186 HtmlTextWriter htw = GetWriter ();
187 RepeatInfo ri = new RepeatInfo ();
188 ri.RepeatColumns = cols;
189 ri.RepeatDirection = d;
191 ri.OuterTableImplied = OuterTableImplied;
192 Style s = new Style ();
194 s.CssClass = ""mainstyle"";
196 ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
197 return htw.InnerWriter.ToString ();
201 public bool HasFooter {
202 get { return footer; }
205 public bool HasHeader {
206 get { return header; }
209 public bool HasSeparators {
210 get { return separators; }
213 public int RepeatedItemCount {
214 get { return count; }
217 public Style GetItemStyle (ListItemType itemType, int repeatIndex)
219 Style s = new Style ();
220 s.CssClass = String.Format (""{0}{1}"", itemType, repeatIndex);
224 public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
226 writer.Write (""({0},{1},{2})"", counter++, itemType, repeatIndex);
246 for (int i = 0; i < (1 << 6); i ++) {
247 RepeatDirection d = (RepeatDirection) (i & (1 << 0));
248 RepeatLayout l = (RepeatLayout) ((i & (1 << 1)) >> 1);
249 bool oti = (i & (1 << 2)) == 0;
250 bool hdr = (i & (1 << 3)) == 0;
251 bool ftr = (i & (1 << 4)) == 0;
252 bool sep = (i & (1 << 5)) == 0;
254 foreach (int [] col_cnt in combos) {
255 string nm = String.Format ("RepeatInfo_{0}cols_{1}itms_{2}_{3}{4}{5}{6}{7}",
258 d == RepeatDirection.Vertical ? "vert" : "horiz",
259 l == RepeatLayout.Flow ? "flow" : "tbl",
260 oti ? "_otrtblimp" : "",
264 Console.WriteLine (@"
270 // RepeatDirection : {3}
271 // RepeatLayout : {4}
272 // OuterTableImplied : {5}
287 string exp = RepeatInfoUser.DoTest (col_cnt [0], col_cnt [1], d, l, oti, hdr, ftr, sep).Replace (@"""", @"""""");
288 Console.WriteLine (@"
289 string v = RepeatInfoUser.DoTest ({0}, {1}, RepeatDirection.{2}, RepeatLayout.{3}, {4}, {5}, {6}, {7});
290 string exp = @""{8}"";
291 Assert.AreEqual (exp, v, ""#{9}"");
299 oti ? "true" : "false",
300 hdr ? "true" : "false",
301 ftr ? "true" : "false",
302 sep ? "true" : "false",
308 Console.WriteLine (@"