New test.
[mono.git] / mcs / class / System.Web / Test / System.Web.UI.WebControls / StyleTest.cs
1 //
2 // Tests for System.Web.UI.WebControls.Style.cs 
3 //
4 // Author:
5 //      Peter Dennis Bartok (pbartok@novell.com)
6 //
7
8 //
9 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using NUnit.Framework;
32 using System;
33 using System.Collections;
34 using System.Drawing;
35 using System.IO;
36 using System.Globalization;
37 using refl = System.Reflection;
38 using System.Web;
39 using System.Web.UI;
40 using System.Web.UI.WebControls;
41 using MonoTests.SystemWeb.Framework;
42 using MonoTests.stand_alone.WebHarness;
43
44 namespace MonoTests.System.Web.UI.WebControls
45 {
46         public class StyleTestClass : Style {
47
48                 public StyleTestClass ()
49                         : base ()
50                 {
51                 }
52
53                 public StyleTestClass (StateBag bag)
54                         : base (bag)
55                 {
56                 }
57
58                 public StateBag StateBag {
59                         get { return base.ViewState; }
60                 }
61
62                 public bool Empty {
63                         get { return base.IsEmpty; }
64                 }
65
66                 public bool IsTracking {
67                         get { return base.IsTrackingViewState; }
68                 }
69 #if NET_2_0
70                 public void SetCssClass(string name) {
71                         Type style = typeof (Style);
72                         if (style != null) {    
73                                 refl.MethodInfo methodInfo = style.GetMethod("SetRegisteredCssClass",refl.BindingFlags.NonPublic | refl.BindingFlags.Instance);
74                                 if (methodInfo != null) {
75                                         object[] parameters =  new object[] {name};
76                                         methodInfo.Invoke(this, parameters);
77                                 }
78                         }
79                 }
80
81                 public override void AddAttributesToRender (HtmlTextWriter writer, WebControl owner) {
82                         base.AddAttributesToRender (writer, owner);
83                 }
84
85                 protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver) {
86                         base.FillStyleAttributes (attributes, urlResolver);
87                         attributes.Add ("FillStyleAttributes", "FillStyleAttributes");
88                 }
89 #endif
90
91                 public string[] KeyValuePairs() {
92                         IEnumerator     e;
93                         string[]        result;
94                         int             item;
95
96                         e = ViewState.GetEnumerator();
97                         result = new string[ViewState.Keys.Count];
98                         item = 0;
99
100                         while (e.MoveNext()) {
101                                 DictionaryEntry d;
102                                 StateItem       si;
103
104                                 d = (DictionaryEntry)e.Current;
105                                 si = (StateItem)d.Value;
106
107                                 if (si.Value is String[]) {
108                                         string[] values;
109
110                                         values = (string[]) si.Value;
111                                         result[item] = d.Key.ToString() + "=";
112                                         if (values.Length > 0) {
113                                                 result[item] += values[0];
114
115                                                 for (int i = 1; i < values.Length; i++) {
116                                                         result[item] += ", " + values[i];
117                                                 }
118                                         }
119                                 } else {
120                                         result[item] =  d.Key.ToString() + "=" + si.Value;
121                                 }
122                                 item++;
123                         }
124
125                         return result;
126                 }
127
128                 public bool SetBitCalledFlag = false;
129                 public int SetBitCalledValue = 0;
130                 protected override void SetBit (int bit) {
131                         SetBitCalledFlag = true;
132                         SetBitCalledValue = bit;
133                         base.SetBit (bit);
134                 }
135         }
136
137         [TestFixture]   
138         public class StyleTest {
139                 private static HtmlTextWriter GetWriter () {
140                         StringWriter sw = new StringWriter ();
141                         sw.NewLine = "\n";
142                         return new HtmlTextWriter (sw);
143                 }
144
145                 private void SetSomeValues(Style s) {
146                         s.BackColor = Color.Red;
147                         s.ForeColor = Color.Green;
148                         s.Width = new Unit(10);
149                         s.Font.Bold = true;
150                 }
151
152                 private void SetAllValues(Style s) {
153                         s.BackColor = Color.Red;
154                         s.BorderColor = Color.Green;
155                         s.BorderStyle = BorderStyle.None;
156                         s.BorderWidth = new Unit(1);
157                         s.CssClass = "Boing";
158                         s.Font.Bold = true;
159                         s.Font.Italic = true;
160                         s.Font.Names = new string[2] {"namelist1", "namelist2"};
161                         //s.Font.Name = string.Empty;
162                         //s.Font.Names = new string[0];
163                         //Console.WriteLine("Font name after setting name: {0}", s.Font.ToString());
164                         s.Font.Overline = true;
165                         s.Font.Size = new FontUnit(1);
166                         //Console.WriteLine("Font name after setting size: {0}", s.Font.ToString());
167                         s.Font.Strikeout = true;
168                         s.Font.Underline = true;
169                         s.ForeColor = Color.Blue;
170                         s.Height = new Unit(2);
171                         s.Width = new Unit(3);
172                 }
173
174                 private bool IsEqual(object[] a1, object[] a2, string assertion) {
175                         int     matches;
176                         bool[]  notfound;       
177
178                         if (a1.Length != a2.Length) {
179                                 if (assertion != null) {
180                                         Assert.Fail(assertion + "( different length )");
181                                 }
182                                 return false;
183                         }
184
185                         matches = 0;
186                         notfound = new bool[a1.Length];
187
188                         for (int i = 0; i < a1.Length; i++) {
189                                 for (int j = 0; j < a2.Length; j++) {
190                                         if (a1[i].Equals(a2[j])) {
191                                                 matches++;
192                                                 break;
193                                         }
194                                 }
195                                 if ((assertion != null) && (matches != i+1)) {
196                                         Assert.Fail(assertion + "( missing " + a1[i].ToString() + " )");
197                                 }
198                         }
199
200                         return matches == a1.Length;
201                 }
202
203                 [Test]
204                 public void Style_Defaults ()
205                 {
206                         Style s = new Style ();
207
208                         Assert.AreEqual (s.BackColor, Color.Empty, "Default1");
209                         Assert.AreEqual (s.BorderColor, Color.Empty, "Default22");
210                         Assert.AreEqual (s.BorderStyle, BorderStyle.NotSet, "Default3");
211                         Assert.AreEqual (s.BorderWidth, Unit.Empty, "Default4");
212                         Assert.AreEqual (s.CssClass, string.Empty, "Default5");
213                         Assert.AreEqual (s.ForeColor, Color.Empty, "Default6");
214                         Assert.AreEqual (s.Height, Unit.Empty, "Default7");
215                         Assert.AreEqual (s.Width, Unit.Empty, "Default8");
216                 }
217
218
219                 [Test]
220                 public void Style_State () {
221                         string[]        keyvalues;
222                         string[]        expect1 = {
223                                                 "BorderStyle=None",
224                                                 "Font_Bold=True",
225                                                 "Font_Italic=True",
226                                                 "Height=2px",
227                                                 "CssClass=Boing",
228                                                 "BorderWidth=1px",
229                                                 "ForeColor=Color [Blue]",
230                                                 "Font_Size=1pt",
231                                                 "Font_Overline=True",
232                                                 "Width=3px",
233                                                 "BorderColor=Color [Green]",
234                                                 "Font_Names=namelist1, namelist2",
235                                                 "Font_Underline=True",
236                                                 "BackColor=Color [Red]",
237                                                 "Font_Strikeout=True" };
238                         string[]        expect2 = {
239                                                 "BorderStyle=None",
240                                                 "Font_Bold=True",
241                                                 "Font_Italic=True",
242                                                 "Height=2px",
243                                                 "CssClass=Boing",
244                                                 "BorderWidth=1px",
245                                                 "ForeColor=Color [Blue]",
246                                                 "Font_Size=1pt",
247                                                 "Font_Overline=True",
248                                                 "Width=3px",
249                                                 "BorderColor=Color [Green]",
250                                                 "Font_Underline=True",
251                                                 "BackColor=Color [Red]",
252                                                 "Font_Strikeout=True" };
253                         string[]        expect3 = {
254                                                 "BorderStyle=None",
255                                                 "Font_Bold=True",
256                                                 "Font_Italic=True",
257                                                 "Height=2px",
258                                                 "CssClass=Boing",
259                                                 "BorderWidth=1px",
260                                                 "ForeColor=Color [Blue]",
261                                                 "Font_Size=1pt",
262                                                 "Font_Overline=True",
263                                                 "Width=3px",
264                                                 "BorderColor=Color [Green]",
265                                                 "Font_Names=",
266                                                 "Font_Underline=True",
267                                                 "BackColor=Color [Red]",
268                                                 "Font_Strikeout=True" };
269                         StyleTestClass  s;
270                         StyleTestClass  copy;
271
272                         s = new StyleTestClass();
273                         SetAllValues(s);
274                         keyvalues = s.KeyValuePairs();
275                         
276                         Assert.AreEqual (15, keyvalues.Length, "State1");
277                         IsEqual(keyvalues, expect1, "State2");
278
279                         s.Font.Name = string.Empty;
280                         keyvalues = s.KeyValuePairs();
281                         Assert.AreEqual (expect2.Length, keyvalues.Length, "State3");
282                         IsEqual(keyvalues, expect2, "State4");
283
284                         s.Font.Names = null;
285                         keyvalues = s.KeyValuePairs();
286                         Assert.AreEqual (expect2.Length, keyvalues.Length, "State5");
287                         IsEqual(keyvalues, expect2, "State6");
288
289                         copy = new StyleTestClass();
290                         copy.CopyFrom(s);
291                         keyvalues = copy.KeyValuePairs();
292                         Assert.AreEqual (expect3.Length, keyvalues.Length, "State7");
293                         IsEqual(keyvalues, expect3, "State8");
294
295                         Assert.AreEqual (false, copy.IsTracking, "State9");
296
297                 }
298
299                 [Test]
300                 public void Style_Merge ()
301                 {
302                         Style s = new Style ();
303                         Style copy = new Style ();
304
305                         SetSomeValues(s);
306                         copy.ForeColor = Color.Blue;
307
308                         copy.MergeWith(s);
309                         Assert.AreEqual (Color.Red, copy.BackColor, "Merge1");
310                         Assert.AreEqual (Color.Blue, copy.ForeColor, "Merge2");
311
312                         // Don't fail here
313                         copy.MergeWith(null);
314                 }
315
316                 [Test]
317                 public void Style_Copy ()
318                 {
319                         Style s = new Style ();
320                         Style copy = new Style ();
321
322                         SetSomeValues(s);
323
324                         copy.CopyFrom (s);
325                         Assert.AreEqual (Color.Red, s.BackColor, "Copy1");
326                 }
327
328 #if NET_2_0
329                 [Test]
330                 public void Style_CssClass ()
331                 {
332                         StyleTestClass s = new StyleTestClass ();
333
334                         Assert.AreEqual (String.Empty, s.RegisteredCssClass, "Css1");
335
336                         s.SetCssClass ("blah");
337                         Assert.AreEqual ("blah", s.RegisteredCssClass, "Css2");
338
339                         s.BackColor = Color.AliceBlue;
340                         Assert.AreEqual ("blah", s.RegisteredCssClass, "Css3");
341                 }
342
343                 [Test]
344                 [Category ("NunitWeb")]
345                 public void Style_AddRegisteredCssClassAttribute () {
346                         new WebTest (PageInvoker.CreateOnLoad (Style_AddRegisteredCssClassAttribute_Load)).Run ();
347                 }
348                 
349                 public static void Style_AddRegisteredCssClassAttribute_Load (Page p) {
350                         StringWriter sw = new StringWriter ();
351                         HtmlTextWriter tw = new HtmlTextWriter (sw);
352                         Style s = new Style ();
353                         s.CssClass = "MyClass";
354                         s.BackColor = Color.AliceBlue;
355                         s.AddAttributesToRender (tw);
356                         tw.RenderBeginTag ("span");
357                         tw.RenderEndTag ();
358                         Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass\""), "AddRegisteredCssClassAttribute#1");
359                         Assert.AreEqual (true, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#2");
360                         
361                         sw = new StringWriter ();
362                         tw = new HtmlTextWriter (sw);
363                         s = new Style ();
364                         s.BackColor = Color.AliceBlue;
365                         p.Header.StyleSheet.RegisterStyle (s, p);
366                         s.AddAttributesToRender (tw);
367                         tw.RenderBeginTag ("span");
368                         tw.RenderEndTag ();
369                         Assert.AreEqual (true, sw.ToString ().Contains ("class"), "AddRegisteredCssClassAttribute#3");
370                         Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#4");
371                         
372                         sw = new StringWriter ();
373                         tw = new HtmlTextWriter (sw);
374                         s = new Style ();
375                         s.BackColor = Color.AliceBlue;
376                         s.CssClass = "MyClass";
377                         p.Header.StyleSheet.RegisterStyle (s, p);
378                         s.AddAttributesToRender (tw);
379                         tw.RenderBeginTag ("span");
380                         tw.RenderEndTag ();
381                         Assert.AreEqual (sw.ToString ().LastIndexOf ("class"), sw.ToString ().IndexOf ("class"), "AddRegisteredCssClassAttribute#5");
382                         Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#6");
383                         Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass "), "AddRegisteredCssClassAttribute#7");
384
385                         s = new Style ();
386                         p.Header.StyleSheet.RegisterStyle (s, p);
387                         Assert.AreEqual (false, s.IsEmpty, "AddRegisteredCssClassAttribute#8");
388                 }
389
390                 [Test]
391                 public void Style_AddAttributesToRender_use_FillStyleAttributes () {
392                         StringWriter sw = new StringWriter ();
393                         HtmlTextWriter tw = new HtmlTextWriter (sw);
394                         StyleTestClass s = new StyleTestClass ();
395                         s.AddAttributesToRender (tw);
396                         tw.RenderBeginTag ("span");
397                         tw.RenderEndTag ();
398                         HtmlDiff.AssertAreEqual ("<span style=\"FillStyleAttributes:FillStyleAttributes;\" />", sw.ToString (), "AddAttributesToRender_use_FillStyleAttributes#2");
399                 }
400
401                 [Test]
402                 public void Style_GetStyleAttributes () {
403                         Style s;
404                         CssStyleCollection css;
405
406                         s = new Style ();
407                         css = s.GetStyleAttributes (null);
408                         Assert.AreEqual (0, css.Count, "GetStyleAttributes#1");
409
410                         s.Font.Bold = true;
411                         s.Font.Italic = true;
412                         s.Font.Size = 10;
413                         s.Font.Names = new string [] { "Arial", "Veranda" };
414                         s.Font.Overline = true;
415                         s.Font.Strikeout = true;
416                         s.Font.Underline = true;
417                         css = s.GetStyleAttributes (null);
418                         Assert.AreEqual ("bold", css ["font-weight"], "GetStyleAttributes#2");
419                         Assert.AreEqual ("italic", css ["font-style"], "GetStyleAttributes#3");
420                         Assert.AreEqual ("10pt", css ["font-size"], "GetStyleAttributes#4");
421                         Assert.AreEqual ("Arial,Veranda", css ["font-family"], "GetStyleAttributes#5");
422                         Assert.AreEqual (true, css ["text-decoration"].Contains ("overline"), "GetStyleAttributes#6");
423                         Assert.AreEqual (true, css ["text-decoration"].Contains ("line-through"), "GetStyleAttributes#7");
424                         Assert.AreEqual (true, css ["text-decoration"].Contains ("underline"), "GetStyleAttributes#8");
425
426                         s.Font.Names = null;
427                         css = s.GetStyleAttributes (null);
428                         Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#9");
429
430                         s.Font.Name = "Arial, Veranda";
431                         css = s.GetStyleAttributes (null);
432                         Assert.AreEqual ("Arial, Veranda", css ["font-family"], "GetStyleAttributes#10");
433
434                         s.Font.Name = "";
435                         css = s.GetStyleAttributes (null);
436                         Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#11");
437
438                         s.Font.Bold = false;
439                         s.Font.Italic = false;
440                         s.Font.Size = FontUnit.Empty;
441                         s.Font.Overline = false;
442                         s.Font.Strikeout = false;
443                         s.Font.Underline = false;
444                         css = s.GetStyleAttributes (null);
445                         Assert.AreEqual ("normal", css ["font-weight"], "GetStyleAttributes#12");
446                         Assert.AreEqual ("normal", css ["font-style"], "GetStyleAttributes#13");
447                         Assert.AreEqual (null, css ["font-size"], "GetStyleAttributes#14");
448                         Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#15");
449
450                         s.Reset ();
451                         css = s.GetStyleAttributes (null);
452                         Assert.AreEqual (0, css.Count, "GetStyleAttributes#16");
453
454                         s.Reset ();
455                         s.Font.Underline = false;
456                         css = s.GetStyleAttributes (null);
457                         Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#17");
458
459                         s.Reset ();
460                         s.BorderWidth = 1;
461                         s.BorderStyle = BorderStyle.Dashed;
462                         css = s.GetStyleAttributes (null);
463                         Assert.AreEqual ("Dashed", css ["border-style"], "GetStyleAttributes#18");
464                         Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#19");
465
466                         s.BorderStyle = BorderStyle.NotSet;
467                         css = s.GetStyleAttributes (null);
468                         Assert.AreEqual ("solid", css ["border-style"], "GetStyleAttributes#20");
469                         Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#21");
470
471                         s.BorderWidth = 0;
472                         css = s.GetStyleAttributes (null);
473                         Assert.AreEqual (null, css ["border-style"], "GetStyleAttributes#22");
474                         Assert.AreEqual ("0px", css ["border-width"], "GetStyleAttributes#23");
475                 }
476 #endif
477
478                 [Test]
479                 public void StyleFonts () {
480                         Style s = new Style ();
481
482                         Assert.AreEqual(new string[0], s.Font.Names, "F1");
483
484                         s.Font.Name = string.Empty;
485                         Assert.AreEqual(new string[0], s.Font.Names, "F2");
486
487                         s.Font.Names = null;
488                         Assert.AreEqual(new string[0], s.Font.Names, "F3");
489                 }
490
491                 [Test]
492                 [ExpectedException(typeof(ArgumentNullException))]
493                 public void NullException1 ()
494                 {
495                         Style s = new Style ();
496
497                         s.Font.Name = null;
498                 }
499
500                 private Style GetStyle ()
501                 {
502                         Style s = new Style ();
503                         s.BackColor = Color.Aqua;
504                         s.BorderWidth = Unit.Pixel (1);
505                         return s;
506                 }
507
508                 private void CheckStyle (Style s)
509                 {
510                         Assert.AreEqual (Color.Aqua, s.BackColor, "BackColor");
511                         Assert.AreEqual (Unit.Pixel (1), s.BorderWidth, "BorderWidth");
512                 }
513
514
515                 [Test]
516                 public void CopyFrom_Null ()
517                 {
518                         Style s = GetStyle ();
519                         s.CopyFrom (null);
520                         CheckStyle (s);
521                 }
522
523                 [Test]
524                 public void CopyFrom_Self ()
525                 {
526                         Style s = GetStyle ();
527                         s.CopyFrom (s);
528                         CheckStyle (s);
529                 }
530
531                 [Test]
532                 public void CopyFrom_Empty ()
533                 {
534                         StyleTestClass s = new StyleTestClass ();
535                         s.CopyFrom (new Style ());
536                         Assert.IsTrue (s.Empty, "Empty");
537                 }
538
539                 [Test]
540                 public void CopyFrom ()
541                 {
542                         Style c = GetStyle ();
543                         Style s = GetStyle ();
544
545                         c.BorderColor = Color.Azure;
546                         c.BorderWidth = Unit.Empty;
547
548                         c.CopyFrom (s);
549                         CheckStyle (c);
550
551                         Assert.AreEqual (Color.Azure, c.BorderColor, "BorderColor");
552                         // CopyFrom doesn't do a Reset
553                 }
554
555                 [Test]
556                 public void CopyFrom_IsEmpty ()
557                 {
558                         StyleTestClass c = new StyleTestClass ();
559                         Style s = GetStyle ();
560
561                         s.BorderColor = Color.Azure;
562                         s.BorderWidth = Unit.Empty;
563
564                         c.CopyFrom (s);
565
566                         Assert.IsFalse (c.Empty, "IsEmpty");
567                 }
568
569                 [Test]
570                 public void Constructor_StateBag_Null ()
571                 {
572                         StyleTestClass s = new StyleTestClass (null);
573                         Assert.IsNotNull (s.StateBag, "StateBag");
574                         s.CssClass = "mono";
575                         Assert.AreEqual ("mono", s.CssClass, "CssClass");
576                 }
577
578                 [Test]
579                 public void Empty ()
580                 {
581                         StyleTestClass s = new StyleTestClass ();
582                         Assert.IsTrue (s.Empty, "Empty");
583                         Assert.AreEqual (0, s.StateBag.Count, "Count");
584                         s.StateBag["Mono"] = "go!";
585                         Assert.IsTrue (s.Empty, "Still Empty");
586                         Assert.AreEqual (1, s.StateBag.Count, "Count");
587                 }
588
589                 [Test]
590                 public void FontInfo_Empty ()
591                 {
592                         FontInfo f;
593                         StyleTestClass s = new StyleTestClass ();
594                         f = s.Font;
595                         Assert.IsTrue (s.Empty, "Empty after getter");
596                         s.Font.Name = "Arial";
597                         Assert.IsFalse (s.Empty, "No longer empty");
598                 }
599                 
600                 [Test]
601                 public void SetBitCalledWhenSetProperty () {
602                         StyleTestClass s = new StyleTestClass ();
603
604                         s.SetBitCalledFlag = false;
605                         s.BackColor = Color.Aqua;
606                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BackColor");
607                         Assert.AreEqual (0x08, s.SetBitCalledValue, "SetBit() was called with wrong argument : BackColor");
608
609                         s.SetBitCalledFlag = false;
610                         s.BorderColor = Color.Blue;
611                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderColor");
612                         Assert.AreEqual (0x10, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderColor");
613
614                         s.SetBitCalledFlag = false;
615                         s.BorderStyle = BorderStyle.Dashed;
616                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderStyle");
617                         Assert.AreEqual (0x40, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderStyle");
618
619                         s.SetBitCalledFlag = false;
620                         s.BorderWidth = 1;
621                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderWidth");
622                         Assert.AreEqual (0x20, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderWidth");
623
624                         s.SetBitCalledFlag = false;
625                         s.CssClass = "class";
626                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : CssClass");
627                         Assert.AreEqual (0x02, s.SetBitCalledValue, "SetBit() was called with wrong argument : CssClass");
628
629                         s.SetBitCalledFlag = false;
630                         s.ForeColor = Color.Red;
631                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : ForeColor");
632                         Assert.AreEqual (0x04, s.SetBitCalledValue, "SetBit() was called with wrong argument : ForeColor");
633
634                         s.SetBitCalledFlag = false;
635                         s.Height = 1;
636                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Height");
637                         Assert.AreEqual (0x80, s.SetBitCalledValue, "SetBit() was called with wrong argument : Height");
638
639                         s.SetBitCalledFlag = false;
640                         s.Width = 1;
641                         Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Width");
642                         Assert.AreEqual (0x100, s.SetBitCalledValue, "SetBit() was called with wrong argument : Width");
643                 }
644
645                 public void Render ()
646                 {
647                         HtmlTextWriter  writer;
648                         StyleTestClass  s;
649
650                         writer = StyleTest.GetWriter();
651                         s  = new StyleTestClass ();
652
653                         s.BorderColor = Color.BlueViolet;
654                         s.AddAttributesToRender(writer);
655                         // Figure out an order-independent way to verify rendered results
656                 }
657         }
658 }