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