3 // Ben Maurer <bmaurer@novell.com>
5 // Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Web.UI.WebControls;
32 namespace MonoTests.Helpers
34 public class RepeatInfoUser : IRepeatInfoUser
42 public RepeatInfoUser (bool header, bool footer, bool separators, int count)
46 this.separators = separators;
50 static HtmlTextWriter GetWriter ()
52 StringWriter sw = new StringWriter ();
54 return new HtmlTextWriter (sw);
57 public static string DoTest (int cols, int cnt, RepeatDirection d, RepeatLayout l, bool OuterTableImplied, bool hdr, bool ftr, bool sep)
59 HtmlTextWriter htw = GetWriter ();
60 RepeatInfo ri = new RepeatInfo ();
61 ri.RepeatColumns = cols;
62 ri.RepeatDirection = d;
64 ri.OuterTableImplied = OuterTableImplied;
65 // get some variation in if we use style or not
66 Style s = new Style ();
68 s.CssClass = "mainstyle";
70 ri.RenderRepeater (htw, new RepeatInfoUser (hdr, ftr, sep, cnt), s, new DataList ());
71 return htw.InnerWriter.ToString ();
75 public bool HasFooter {
76 get { return footer; }
79 public bool HasHeader {
80 get { return header; }
83 public bool HasSeparators {
84 get { return separators; }
87 public int RepeatedItemCount {
91 public Style GetItemStyle (ListItemType itemType, int repeatIndex)
93 Style s = new Style ();
94 s.CssClass = String.Format ("{0}{1}", itemType, repeatIndex);
98 public void RenderItem (ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
100 writer.Write ("({0},{1},{2})", counter++, itemType, repeatIndex);