2007-02-05 Adar Wesley <adarw@mainsoft.com>
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / RepeatInfoTest.gen.cs
1 //
2 // Autogen RepeatInfoTest.auto.cs
3 //
4 // Author:
5 //      Ben Maurer <bmaurer@novell.com>
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
29 using System.Web;
30 using System.Web.UI;
31 using System.Web.UI.WebControls;
32 using System;
33 using System.IO;
34
35
36 class X {
37         //
38         // KEEP THIS IN SYNC WITH THE ONE IN QUOTES!
39         //
40         public class RepeatInfoUser : IRepeatInfoUser {
41
42                 private bool footer;
43                 private bool header;
44                 private bool separators;
45                 private int count;
46                 private int counter;
47
48
49                 public RepeatInfoUser (bool header, bool footer, bool separators, int count)
50                 {
51                         this.footer = footer;
52                         this.header = header;
53                         this.separators = separators;
54                         this.count = count;
55                 }
56
57                 static HtmlTextWriter GetWriter ()
58                 {
59                         StringWriter sw = new StringWriter ();
60                         sw.NewLine = "\n";
61                         return new HtmlTextWriter (sw);
62                 }
63
64                 public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
65                 {
66                         HtmlTextWriter htw = GetWriter ();
67                         RepeatInfo ri = new RepeatInfo ();
68                         ri.RepeatColumns = cols;
69                         ri.RepeatDirection = d;
70                         ri.RepeatLayout = l;
71                         ri.OuterTableImplied = OuterTableImplied;
72                         // get some variation in if we use style or not
73                         Style s = new Style ();
74                         if (cols != 3)
75                                 s.CssClass = "mainstyle";
76                         
77                         ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
78                         return htw.InnerWriter.ToString ();
79                 }
80
81
82                 public bool HasFooter {
83                         get { return footer; }
84                 }
85
86                 public bool HasHeader {
87                         get { return header; }
88                 }
89                 
90                 public bool HasSeparators {
91                         get { return separators; }
92                 }
93
94                 public int RepeatedItemCount {
95                         get { return count; }
96                 }
97
98                 public Style GetItemStyle (ListItemType itemType, int repeatIndex)
99                 {
100                         Style s = new Style ();
101                         s.CssClass = String.Format ("{0}{1}", itemType, repeatIndex);
102                         return s;
103                 }
104
105                 public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
106                 {
107                         writer.Write ("({0},{1},{2})", counter++, itemType, repeatIndex);
108                 }
109         }
110
111         static void Main ()
112         {
113 #if NET_2_0
114           Console.WriteLine ("#if NET_2_0");
115 #else
116           Console.WriteLine ("#if !NET_2_0");
117 #endif
118
119                 Console.WriteLine (@"
120 // THIS IS AUTOGENERATED DO NOT EDIT
121 //
122 // Authors:
123 //    Ben Maurer (bmaurer@novell.com)
124 //
125 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
126 //
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:
134 // 
135 // The above copyright notice and this permission notice shall be
136 // included in all copies or substantial portions of the Software.
137 // 
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.
145 //
146
147 using System;
148 using System.Collections;
149 using System.ComponentModel;
150 using System.Drawing;
151 using System.IO;
152 using System.Web;
153 using System.Web.UI;
154 using System.Web.UI.WebControls;
155
156 using NUnit.Framework;
157 namespace MonoTests.System.Web.UI.WebControls {
158 [TestFixture]
159 public class RepeatInfo_Autogen {
160         public class RepeatInfoUser : IRepeatInfoUser {
161
162                 private bool footer;
163                 private bool header;
164                 private bool separators;
165                 private int count;
166                 private int counter;
167
168
169                 public RepeatInfoUser (bool header, bool footer, bool separators, int count)
170                 {
171                         this.footer = footer;
172                         this.header = header;
173                         this.separators = separators;
174                         this.count = count;
175                 }
176
177                 static HtmlTextWriter GetWriter ()
178                 {
179                         StringWriter sw = new StringWriter ();
180                         sw.NewLine = ""\n"";
181                         return new HtmlTextWriter (sw);
182                 }
183
184                 public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
185                 {
186                         HtmlTextWriter htw = GetWriter ();
187                         RepeatInfo ri = new RepeatInfo ();
188                         ri.RepeatColumns = cols;
189                         ri.RepeatDirection = d;
190                         ri.RepeatLayout = l;
191                         ri.OuterTableImplied = OuterTableImplied;
192                         Style s = new Style ();
193                         if (cols != 3)
194                                 s.CssClass = ""mainstyle"";
195
196                         ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
197                         return htw.InnerWriter.ToString ();
198                 }
199
200
201                 public bool HasFooter {
202                         get { return footer; }
203                 }
204
205                 public bool HasHeader {
206                         get { return header; }
207                 }
208                 
209                 public bool HasSeparators {
210                         get { return separators; }
211                 }
212
213                 public int RepeatedItemCount {
214                         get { return count; }
215                 }
216
217                 public Style GetItemStyle (ListItemType itemType, int repeatIndex)
218                 {
219                         Style s = new Style ();
220                         s.CssClass = String.Format (""{0}{1}"", itemType, repeatIndex);
221                         return s;
222                 }
223
224                 public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
225                 {
226                         writer.Write (""({0},{1},{2})"", counter++, itemType, repeatIndex);
227                 }
228         }");
229                 
230                 
231                 int num = 0;
232                 int [][] combos = {
233                         new int [] {0, 0},
234                         new int [] {0, 1},
235                         new int [] {0, 2},
236                         new int [] {0, 5},
237                         new int [] {1, 0},
238                         new int [] {1, 5},
239                         new int [] {2, 4},
240                         new int [] {2, 7},
241                         new int [] {3, 9},
242                         new int [] {3, 7}
243                 };
244                 
245                 
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;
253
254                         foreach (int [] col_cnt in combos) {
255                                 string nm = String.Format ("RepeatInfo_{0}cols_{1}itms_{2}_{3}{4}{5}{6}{7}",
256                                                 col_cnt [0],
257                                                 col_cnt [1],
258                                                 d == RepeatDirection.Vertical ? "vert" : "horiz",
259                                                 l == RepeatLayout.Flow ? "flow" : "tbl",
260                                                 oti ? "_otrtblimp" : "",
261                                                 hdr ? "_hdr" : "",
262                                                 ftr ? "_ftr" : "",
263                                                 sep ? "_sep" : "");
264                                 Console.WriteLine (@"
265         [Test]
266         public void {0} ()
267         {{
268                 // cols              : {1}
269                 // cnt               : {2}
270                 // RepeatDirection   : {3}
271                 // RepeatLayout      : {4}
272                 // OuterTableImplied : {5}
273                 // Header            : {6}
274                 // Footer            : {7}
275                 // Separator         : {8}
276 ",
277                                                 nm,
278                                                 col_cnt [0],
279                                                 col_cnt [1],
280                                                 d,
281                                                 l,
282                                                 oti,
283                                                 hdr,
284                                                 ftr,
285                                                 sep
286                                         );
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}"");
292         }}
293 ",
294                                                 
295                                                 col_cnt [0],
296                                                 col_cnt [1],
297                                                 d,
298                                                 l,
299                                                 oti ? "true" : "false",
300                                                 hdr ? "true" : "false",
301                                                 ftr ? "true" : "false",
302                                                 sep ? "true" : "false",
303                                                 exp,
304                                                 num ++
305                                         );
306                         }
307                 }
308                 Console.WriteLine (@"
309 }
310 }
311 #endif");
312         }
313 }