[SRE] Improved token fixups processing.
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / RepeatInfoTest.gen.cs
1 //
2 // Autogen RepeatInfoTest.auto.cs
3 //
4 // Authors:
5 //      Ben Maurer <bmaurer@novell.com>
6 //      Marek Habersack <mhabersack@novell.com>
7 //
8 // Copyright (C) 2005-2010 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 //
29
30 using System.Web;
31 using System.Web.UI;
32 using System.Web.UI.WebControls;
33 using System;
34 using System.IO;
35 using System.Text;
36
37 using MonoTests.Helpers;
38
39 class X {
40         static string GetLayoutName (RepeatLayout layout)
41         {
42                 switch (layout) {
43                         case RepeatLayout.Flow:
44                                 return "flow";
45
46                         case RepeatLayout.Table:
47                                 return "tbl";
48 #if NET_4_0
49                         case RepeatLayout.OrderedList:
50                                 return "ol";
51
52                         case RepeatLayout.UnorderedList:
53                                 return "ul";
54 #endif
55                         default:
56                                 throw new InvalidOperationException ("Unsupported layout value: " + layout);
57                 }
58         }
59
60         static void Main ()
61         {
62 #if NET_4_0
63                 Console.WriteLine ("#if NET_4_0");
64 #else
65                 Console.WriteLine ("#if NET_2_0 && !NET_4_0");
66 #endif
67                 bool isMono = Type.GetType ("Mono.Runtime", false) != null;
68
69                 Console.WriteLine (@"
70 // THIS IS AUTOGENERATED DO NOT EDIT
71 //
72 // Generated on {0} runtime v{1}
73 //
74 // Authors:
75 //    Ben Maurer (bmaurer@novell.com)
76 //
77 // Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
78 //
79 // Permission is hereby granted, free of charge, to any person obtaining
80 // a copy of this software and associated documentation files (the
81 // ""Software""), to deal in the Software without restriction, including
82 // without limitation the rights to use, copy, modify, merge, publish,
83 // distribute, sublicense, and/or sell copies of the Software, and to
84 // permit persons to whom the Software is furnished to do so, subject to
85 // the following conditions:
86 // 
87 // The above copyright notice and this permission notice shall be
88 // included in all copies or substantial portions of the Software.
89 // 
90 // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
91 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
92 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
93 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
94 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
95 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
96 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
97 //
98
99 using System;
100 using System.Collections;
101 using System.ComponentModel;
102 using System.Drawing;
103 using System.IO;
104 using System.Web;
105 using System.Web.UI;
106 using System.Web.UI.WebControls;
107
108 using NUnit.Framework;
109 using MonoTests.Helpers;
110
111 namespace MonoTests.System.Web.UI.WebControls {{
112 [TestFixture]
113 public class RepeatInfo_Autogen {{
114 ", isMono ? "Mono" : "Microsoft .NET", Environment.Version);            
115                 int num = 0;
116                 int [][] combos = {
117                         new int [] {0, 0},
118                         new int [] {0, 1},
119                         new int [] {0, 2},
120                         new int [] {0, 5},
121                         new int [] {1, 0},
122                         new int [] {1, 5},
123                         new int [] {2, 4},
124                         new int [] {2, 7},
125                         new int [] {3, 9},
126                         new int [] {3, 7}
127                 };
128 #if NET_4_0
129                 int ntests = 1 << 7;
130                 int lcount = -1;
131 #else
132                 int ntests = 1 << 6;
133 #endif
134                 RepeatDirection d;
135                 RepeatLayout l;
136                 bool oti, hdr, ftr, sep;
137                 StringBuilder sb = new StringBuilder ();
138
139                 for (int i = 0; i < ntests; i ++) {
140                         d = (RepeatDirection) (i & (1 << 0));
141 #if NET_4_0
142                         if ((i % 2) == 0)
143                                 lcount++;
144                         l = (RepeatLayout) (lcount % 4);
145 #else
146                         l = (RepeatLayout) ((i & (1 << 1)) >> 1);
147 #endif
148                         oti = (i & (1 << 3)) == 0;
149                         hdr = (i & (1 << 4)) == 0;
150                         ftr = (i & (1 << 5)) == 0;
151                         sep = (i & (1 << 6)) == 0;
152
153                         foreach (int [] col_cnt in combos) {
154                                 string nm = String.Format ("RepeatInfo_{0}cols_{1}itms_{2}_{3}{4}{5}{6}{7}",
155                                                 col_cnt [0],
156                                                 col_cnt [1],
157                                                 d == RepeatDirection.Vertical ? "vert" : "horiz",
158                                                 GetLayoutName (l),
159                                                 oti ? "_otrtblimp" : String.Empty,
160                                                 hdr ? "_hdr" : String.Empty,
161                                                 ftr ? "_ftr" : String.Empty,
162                                                 sep ? "_sep" : String.Empty);
163                                 sb.Length = 0;
164                                 sb.AppendFormat (@"
165         public void {0} ()
166         {{
167                 // cols              : {1}
168                 // cnt               : {2}
169                 // RepeatDirection   : {3}
170                 // RepeatLayout      : {4}
171                 // OuterTableImplied : {5}
172                 // Header            : {6}
173                 // Footer            : {7}
174                 // Separator         : {8}
175 ",
176                                                 nm,
177                                                 col_cnt [0],
178                                                 col_cnt [1],
179                                                 d,
180                                                 l,
181                                                 oti,
182                                                 hdr,
183                                                 ftr,
184                                                 sep
185                                         );
186                                 try {
187                                         string exp = RepeatInfoUser.DoTest (col_cnt [0], col_cnt [1], d, l, oti, hdr, ftr, sep).Replace (@"""", @"""""");
188                                         BuildTestCode (sb, null, col_cnt [0], col_cnt [1], d, l, oti, hdr, ftr, sep, exp, num++);
189                                 } catch (Exception ex) {
190                                         BuildTestCode (sb, ex, col_cnt [0], col_cnt [1], d, l, oti, hdr, ftr, sep, null, num++);
191                                 }
192                                 Console.WriteLine (sb.ToString ());
193                         }
194                 }
195                 Console.WriteLine (@"
196 }
197 }
198 #endif");
199         }
200
201         static void BuildTestCode (StringBuilder sb, Exception ex, int cols, int cnt, RepeatDirection d, RepeatLayout l, bool oti, bool hdr, bool ftr, bool sep, string exp, int num)
202         {
203                 if (ex == null) {
204                         sb.Insert (0, "\t[Test]");
205                 } else {
206                         sb.Insert (0, String.Format ("\t[ExpectedException (typeof (global::{0}))]", ex.GetType ().FullName));
207                         sb.Insert (0, "\t[Test]\n");
208                 }
209
210                 sb.AppendFormat (@"
211                 string v = global::MonoTests.Helpers.RepeatInfoUser.DoTest ({0}, {1}, RepeatDirection.{2}, RepeatLayout.{3}, {4}, {5}, {6}, {7});
212 ",
213                         cols,
214                         cnt,
215                         d,
216                         l,
217                         oti ? "true" : "false",
218                         hdr ? "true" : "false",
219                         ftr ? "true" : "false",
220                         sep ? "true" : "false");
221                 if (ex == null) {
222                         sb.AppendFormat (@"             string exp = @""{0}"";
223                 Assert.AreEqual (exp, v, ""#{1}"");
224         }}
225 ", exp, num);
226                 } else {
227                         sb.AppendFormat (@"
228                 // Exception: {0} (""{1}"")
229         }}
230 ", ex.GetType ().FullName, ex.Message);
231                 }
232         }
233 }