StyleTest.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. //
  2. // Tests for System.Web.UI.WebControls.Style.cs
  3. //
  4. // Author:
  5. // Peter Dennis Bartok ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2005 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. using NUnit.Framework;
  30. using System;
  31. using System.Collections;
  32. using System.Drawing;
  33. using System.IO;
  34. using System.Globalization;
  35. using refl = System.Reflection;
  36. using System.Web;
  37. using System.Web.UI;
  38. using System.Web.UI.WebControls;
  39. using MonoTests.SystemWeb.Framework;
  40. using MonoTests.stand_alone.WebHarness;
  41. namespace MonoTests.System.Web.UI.WebControls
  42. {
  43. public class StyleTestClass : Style {
  44. public StyleTestClass ()
  45. : base ()
  46. {
  47. }
  48. public StyleTestClass (StateBag bag)
  49. : base (bag)
  50. {
  51. }
  52. public StateBag StateBag {
  53. get { return base.ViewState; }
  54. }
  55. public bool Empty {
  56. get { return base.IsEmpty; }
  57. }
  58. public bool IsTracking {
  59. get { return base.IsTrackingViewState; }
  60. }
  61. #if NET_2_0
  62. public void SetCssClass(string name) {
  63. Type style = typeof (Style);
  64. if (style != null) {
  65. refl.MethodInfo methodInfo = style.GetMethod("SetRegisteredCssClass",refl.BindingFlags.NonPublic | refl.BindingFlags.Instance);
  66. if (methodInfo != null) {
  67. object[] parameters = new object[] {name};
  68. methodInfo.Invoke(this, parameters);
  69. }
  70. }
  71. }
  72. public override void AddAttributesToRender (HtmlTextWriter writer, WebControl owner) {
  73. base.AddAttributesToRender (writer, owner);
  74. }
  75. protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver) {
  76. base.FillStyleAttributes (attributes, urlResolver);
  77. attributes.Add ("FillStyleAttributes", "FillStyleAttributes");
  78. }
  79. #endif
  80. public string[] KeyValuePairs() {
  81. IEnumerator e;
  82. string[] result;
  83. int item;
  84. e = ViewState.GetEnumerator();
  85. result = new string[ViewState.Keys.Count];
  86. item = 0;
  87. while (e.MoveNext()) {
  88. DictionaryEntry d;
  89. StateItem si;
  90. d = (DictionaryEntry)e.Current;
  91. si = (StateItem)d.Value;
  92. if (si.Value is String[]) {
  93. string[] values;
  94. values = (string[]) si.Value;
  95. result[item] = d.Key.ToString() + "=";
  96. if (values.Length > 0) {
  97. result[item] += values[0];
  98. for (int i = 1; i < values.Length; i++) {
  99. result[item] += ", " + values[i];
  100. }
  101. }
  102. } else {
  103. result[item] = d.Key.ToString() + "=" + si.Value;
  104. }
  105. item++;
  106. }
  107. return result;
  108. }
  109. public bool SetBitCalledFlag = false;
  110. public int SetBitCalledValue = 0;
  111. protected override void SetBit (int bit) {
  112. SetBitCalledFlag = true;
  113. SetBitCalledValue = bit;
  114. base.SetBit (bit);
  115. }
  116. }
  117. [TestFixture]
  118. public class StyleTest {
  119. private static HtmlTextWriter GetWriter () {
  120. StringWriter sw = new StringWriter ();
  121. sw.NewLine = "\n";
  122. return new HtmlTextWriter (sw);
  123. }
  124. private void SetSomeValues(Style s) {
  125. s.BackColor = Color.Red;
  126. s.ForeColor = Color.Green;
  127. s.Width = new Unit(10);
  128. s.Font.Bold = true;
  129. }
  130. private void SetAllValues(Style s) {
  131. s.BackColor = Color.Red;
  132. s.BorderColor = Color.Green;
  133. s.BorderStyle = BorderStyle.None;
  134. s.BorderWidth = new Unit(1);
  135. s.CssClass = "Boing";
  136. s.Font.Bold = true;
  137. s.Font.Italic = true;
  138. s.Font.Names = new string[2] {"namelist1", "namelist2"};
  139. //s.Font.Name = string.Empty;
  140. //s.Font.Names = new string[0];
  141. //Console.WriteLine("Font name after setting name: {0}", s.Font.ToString());
  142. s.Font.Overline = true;
  143. s.Font.Size = new FontUnit(1);
  144. //Console.WriteLine("Font name after setting size: {0}", s.Font.ToString());
  145. s.Font.Strikeout = true;
  146. s.Font.Underline = true;
  147. s.ForeColor = Color.Blue;
  148. s.Height = new Unit(2);
  149. s.Width = new Unit(3);
  150. }
  151. private bool IsEqual(object[] a1, object[] a2, string assertion) {
  152. int matches;
  153. bool[] notfound;
  154. if (a1.Length != a2.Length) {
  155. if (assertion != null) {
  156. Assert.Fail(assertion + "( different length )");
  157. }
  158. return false;
  159. }
  160. matches = 0;
  161. notfound = new bool[a1.Length];
  162. for (int i = 0; i < a1.Length; i++) {
  163. for (int j = 0; j < a2.Length; j++) {
  164. if (a1[i].Equals(a2[j])) {
  165. matches++;
  166. break;
  167. }
  168. }
  169. if ((assertion != null) && (matches != i+1)) {
  170. Assert.Fail(assertion + "( missing " + a1[i].ToString() + " )");
  171. }
  172. }
  173. return matches == a1.Length;
  174. }
  175. [Test]
  176. public void Style_Defaults ()
  177. {
  178. Style s = new Style ();
  179. Assert.AreEqual (s.BackColor, Color.Empty, "Default1");
  180. Assert.AreEqual (s.BorderColor, Color.Empty, "Default22");
  181. Assert.AreEqual (s.BorderStyle, BorderStyle.NotSet, "Default3");
  182. Assert.AreEqual (s.BorderWidth, Unit.Empty, "Default4");
  183. Assert.AreEqual (s.CssClass, string.Empty, "Default5");
  184. Assert.AreEqual (s.ForeColor, Color.Empty, "Default6");
  185. Assert.AreEqual (s.Height, Unit.Empty, "Default7");
  186. Assert.AreEqual (s.Width, Unit.Empty, "Default8");
  187. }
  188. [Test]
  189. public void Style_State () {
  190. string[] keyvalues;
  191. string[] expect1 = {
  192. "BorderStyle=None",
  193. "Font_Bold=True",
  194. "Font_Italic=True",
  195. "Height=2px",
  196. "CssClass=Boing",
  197. "BorderWidth=1px",
  198. "ForeColor=Color [Blue]",
  199. "Font_Size=1pt",
  200. "Font_Overline=True",
  201. "Width=3px",
  202. "BorderColor=Color [Green]",
  203. "Font_Names=namelist1, namelist2",
  204. "Font_Underline=True",
  205. "BackColor=Color [Red]",
  206. "Font_Strikeout=True" };
  207. string[] expect2 = {
  208. "BorderStyle=None",
  209. "Font_Bold=True",
  210. "Font_Italic=True",
  211. "Height=2px",
  212. "CssClass=Boing",
  213. "BorderWidth=1px",
  214. "ForeColor=Color [Blue]",
  215. "Font_Size=1pt",
  216. "Font_Overline=True",
  217. "Width=3px",
  218. "BorderColor=Color [Green]",
  219. "Font_Underline=True",
  220. "BackColor=Color [Red]",
  221. "Font_Strikeout=True" };
  222. string[] expect3 = {
  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=",
  235. "Font_Underline=True",
  236. "BackColor=Color [Red]",
  237. "Font_Strikeout=True" };
  238. StyleTestClass s;
  239. StyleTestClass copy;
  240. s = new StyleTestClass();
  241. SetAllValues(s);
  242. keyvalues = s.KeyValuePairs();
  243. Assert.AreEqual (15, keyvalues.Length, "State1");
  244. IsEqual(keyvalues, expect1, "State2");
  245. s.Font.Name = string.Empty;
  246. keyvalues = s.KeyValuePairs();
  247. Assert.AreEqual (expect2.Length, keyvalues.Length, "State3");
  248. IsEqual(keyvalues, expect2, "State4");
  249. s.Font.Names = null;
  250. keyvalues = s.KeyValuePairs();
  251. Assert.AreEqual (expect2.Length, keyvalues.Length, "State5");
  252. IsEqual(keyvalues, expect2, "State6");
  253. copy = new StyleTestClass();
  254. copy.CopyFrom(s);
  255. keyvalues = copy.KeyValuePairs();
  256. Assert.AreEqual (expect3.Length, keyvalues.Length, "State7");
  257. IsEqual(keyvalues, expect3, "State8");
  258. Assert.AreEqual (false, copy.IsTracking, "State9");
  259. }
  260. [Test]
  261. public void Style_Merge ()
  262. {
  263. Style s = new Style ();
  264. Style copy = new Style ();
  265. SetSomeValues(s);
  266. copy.ForeColor = Color.Blue;
  267. copy.MergeWith(s);
  268. Assert.AreEqual (Color.Red, copy.BackColor, "Merge1");
  269. Assert.AreEqual (Color.Blue, copy.ForeColor, "Merge2");
  270. // Don't fail here
  271. copy.MergeWith(null);
  272. }
  273. [Test]
  274. public void Style_Copy ()
  275. {
  276. Style s = new Style ();
  277. Style copy = new Style ();
  278. SetSomeValues(s);
  279. copy.CopyFrom (s);
  280. Assert.AreEqual (Color.Red, s.BackColor, "Copy1");
  281. }
  282. #if NET_2_0
  283. [Test]
  284. public void Style_CssClass ()
  285. {
  286. StyleTestClass s = new StyleTestClass ();
  287. Assert.AreEqual (String.Empty, s.RegisteredCssClass, "Css1");
  288. s.SetCssClass ("blah");
  289. Assert.AreEqual ("blah", s.RegisteredCssClass, "Css2");
  290. s.BackColor = Color.AliceBlue;
  291. Assert.AreEqual ("blah", s.RegisteredCssClass, "Css3");
  292. }
  293. [Test]
  294. [Category ("NunitWeb")]
  295. public void Style_AddRegisteredCssClassAttribute () {
  296. new WebTest (PageInvoker.CreateOnLoad (Style_AddRegisteredCssClassAttribute_Load)).Run ();
  297. }
  298. public static void Style_AddRegisteredCssClassAttribute_Load (Page p) {
  299. StringWriter sw = new StringWriter ();
  300. HtmlTextWriter tw = new HtmlTextWriter (sw);
  301. Style s = new Style ();
  302. s.CssClass = "MyClass";
  303. s.BackColor = Color.AliceBlue;
  304. s.AddAttributesToRender (tw);
  305. tw.RenderBeginTag ("span");
  306. tw.RenderEndTag ();
  307. Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass\""), "AddRegisteredCssClassAttribute#1");
  308. Assert.AreEqual (true, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#2");
  309. sw = new StringWriter ();
  310. tw = new HtmlTextWriter (sw);
  311. s = new Style ();
  312. s.BackColor = Color.AliceBlue;
  313. p.Header.StyleSheet.RegisterStyle (s, p);
  314. s.AddAttributesToRender (tw);
  315. tw.RenderBeginTag ("span");
  316. tw.RenderEndTag ();
  317. Assert.AreEqual (true, sw.ToString ().Contains ("class"), "AddRegisteredCssClassAttribute#3");
  318. Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#4");
  319. sw = new StringWriter ();
  320. tw = new HtmlTextWriter (sw);
  321. s = new Style ();
  322. s.BackColor = Color.AliceBlue;
  323. s.CssClass = "MyClass";
  324. p.Header.StyleSheet.RegisterStyle (s, p);
  325. s.AddAttributesToRender (tw);
  326. tw.RenderBeginTag ("span");
  327. tw.RenderEndTag ();
  328. Assert.AreEqual (sw.ToString ().LastIndexOf ("class"), sw.ToString ().IndexOf ("class"), "AddRegisteredCssClassAttribute#5");
  329. Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#6");
  330. Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass "), "AddRegisteredCssClassAttribute#7");
  331. s = new Style ();
  332. p.Header.StyleSheet.RegisterStyle (s, p);
  333. Assert.AreEqual (false, s.IsEmpty, "AddRegisteredCssClassAttribute#8");
  334. }
  335. [Test]
  336. public void Style_AddAttributesToRender_use_FillStyleAttributes () {
  337. StringWriter sw = new StringWriter ();
  338. HtmlTextWriter tw = new HtmlTextWriter (sw);
  339. StyleTestClass s = new StyleTestClass ();
  340. s.AddAttributesToRender (tw);
  341. tw.RenderBeginTag ("span");
  342. tw.RenderEndTag ();
  343. HtmlDiff.AssertAreEqual ("<span style=\"FillStyleAttributes:FillStyleAttributes;\" />", sw.ToString (), "AddAttributesToRender_use_FillStyleAttributes#2");
  344. }
  345. [Test]
  346. public void Style_GetStyleAttributes () {
  347. Style s;
  348. CssStyleCollection css;
  349. s = new Style ();
  350. css = s.GetStyleAttributes (null);
  351. Assert.AreEqual (0, css.Count, "GetStyleAttributes#1");
  352. s.Font.Bold = true;
  353. s.Font.Italic = true;
  354. s.Font.Size = 10;
  355. s.Font.Names = new string [] { "Arial", "Veranda" };
  356. s.Font.Overline = true;
  357. s.Font.Strikeout = true;
  358. s.Font.Underline = true;
  359. css = s.GetStyleAttributes (null);
  360. Assert.AreEqual ("bold", css ["font-weight"], "GetStyleAttributes#2");
  361. Assert.AreEqual ("italic", css ["font-style"], "GetStyleAttributes#3");
  362. Assert.AreEqual ("10pt", css ["font-size"], "GetStyleAttributes#4");
  363. Assert.AreEqual ("Arial,Veranda", css ["font-family"], "GetStyleAttributes#5");
  364. Assert.AreEqual (true, css ["text-decoration"].Contains ("overline"), "GetStyleAttributes#6");
  365. Assert.AreEqual (true, css ["text-decoration"].Contains ("line-through"), "GetStyleAttributes#7");
  366. Assert.AreEqual (true, css ["text-decoration"].Contains ("underline"), "GetStyleAttributes#8");
  367. s.Font.Names = null;
  368. css = s.GetStyleAttributes (null);
  369. Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#9");
  370. s.Font.Name = "Arial, Veranda";
  371. css = s.GetStyleAttributes (null);
  372. Assert.AreEqual ("Arial, Veranda", css ["font-family"], "GetStyleAttributes#10");
  373. s.Font.Name = "";
  374. css = s.GetStyleAttributes (null);
  375. Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#11");
  376. s.Font.Bold = false;
  377. s.Font.Italic = false;
  378. s.Font.Size = FontUnit.Empty;
  379. s.Font.Overline = false;
  380. s.Font.Strikeout = false;
  381. s.Font.Underline = false;
  382. css = s.GetStyleAttributes (null);
  383. Assert.AreEqual ("normal", css ["font-weight"], "GetStyleAttributes#12");
  384. Assert.AreEqual ("normal", css ["font-style"], "GetStyleAttributes#13");
  385. Assert.AreEqual (null, css ["font-size"], "GetStyleAttributes#14");
  386. Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#15");
  387. s.Reset ();
  388. css = s.GetStyleAttributes (null);
  389. Assert.AreEqual (0, css.Count, "GetStyleAttributes#16");
  390. s.Reset ();
  391. s.Font.Underline = false;
  392. css = s.GetStyleAttributes (null);
  393. Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#17");
  394. s.Reset ();
  395. s.BorderWidth = 1;
  396. s.BorderStyle = BorderStyle.Dashed;
  397. css = s.GetStyleAttributes (null);
  398. Assert.AreEqual ("Dashed", css ["border-style"], "GetStyleAttributes#18");
  399. Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#19");
  400. s.BorderStyle = BorderStyle.NotSet;
  401. css = s.GetStyleAttributes (null);
  402. Assert.AreEqual ("solid", css ["border-style"], "GetStyleAttributes#20");
  403. Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#21");
  404. s.BorderWidth = 0;
  405. css = s.GetStyleAttributes (null);
  406. Assert.AreEqual (null, css ["border-style"], "GetStyleAttributes#22");
  407. Assert.AreEqual ("0px", css ["border-width"], "GetStyleAttributes#23");
  408. }
  409. #endif
  410. [Test]
  411. public void StyleFonts () {
  412. Style s = new Style ();
  413. Assert.AreEqual(new string[0], s.Font.Names, "F1");
  414. s.Font.Name = string.Empty;
  415. Assert.AreEqual(new string[0], s.Font.Names, "F2");
  416. s.Font.Names = null;
  417. Assert.AreEqual(new string[0], s.Font.Names, "F3");
  418. }
  419. [Test]
  420. [ExpectedException(typeof(ArgumentNullException))]
  421. public void NullException1 ()
  422. {
  423. Style s = new Style ();
  424. s.Font.Name = null;
  425. }
  426. private Style GetStyle ()
  427. {
  428. Style s = new Style ();
  429. s.BackColor = Color.Aqua;
  430. s.BorderWidth = Unit.Pixel (1);
  431. return s;
  432. }
  433. private void CheckStyle (Style s)
  434. {
  435. Assert.AreEqual (Color.Aqua, s.BackColor, "BackColor");
  436. Assert.AreEqual (Unit.Pixel (1), s.BorderWidth, "BorderWidth");
  437. }
  438. [Test]
  439. public void CopyFrom_Null ()
  440. {
  441. Style s = GetStyle ();
  442. s.CopyFrom (null);
  443. CheckStyle (s);
  444. }
  445. [Test]
  446. public void CopyFrom_Self ()
  447. {
  448. Style s = GetStyle ();
  449. s.CopyFrom (s);
  450. CheckStyle (s);
  451. }
  452. [Test]
  453. public void CopyFrom_Empty ()
  454. {
  455. StyleTestClass s = new StyleTestClass ();
  456. s.CopyFrom (new Style ());
  457. Assert.IsTrue (s.Empty, "Empty");
  458. }
  459. [Test]
  460. public void CopyFrom ()
  461. {
  462. Style c = GetStyle ();
  463. Style s = GetStyle ();
  464. c.BorderColor = Color.Azure;
  465. c.BorderWidth = Unit.Empty;
  466. c.CopyFrom (s);
  467. CheckStyle (c);
  468. Assert.AreEqual (Color.Azure, c.BorderColor, "BorderColor");
  469. // CopyFrom doesn't do a Reset
  470. }
  471. [Test]
  472. public void CopyFrom_IsEmpty ()
  473. {
  474. StyleTestClass c = new StyleTestClass ();
  475. Style s = GetStyle ();
  476. s.BorderColor = Color.Azure;
  477. s.BorderWidth = Unit.Empty;
  478. c.CopyFrom (s);
  479. Assert.IsFalse (c.Empty, "IsEmpty");
  480. }
  481. [Test]
  482. public void Constructor_StateBag_Null ()
  483. {
  484. StyleTestClass s = new StyleTestClass (null);
  485. Assert.IsNotNull (s.StateBag, "StateBag");
  486. s.CssClass = "mono";
  487. Assert.AreEqual ("mono", s.CssClass, "CssClass");
  488. }
  489. [Test]
  490. public void Empty ()
  491. {
  492. StyleTestClass s = new StyleTestClass ();
  493. Assert.IsTrue (s.Empty, "Empty");
  494. Assert.AreEqual (0, s.StateBag.Count, "Count");
  495. s.StateBag["Mono"] = "go!";
  496. Assert.IsTrue (s.Empty, "Still Empty");
  497. Assert.AreEqual (1, s.StateBag.Count, "Count");
  498. }
  499. [Test]
  500. public void FontInfo_Empty ()
  501. {
  502. FontInfo f;
  503. StyleTestClass s = new StyleTestClass ();
  504. f = s.Font;
  505. Assert.IsTrue (s.Empty, "Empty after getter");
  506. s.Font.Name = "Arial";
  507. Assert.IsFalse (s.Empty, "No longer empty");
  508. }
  509. [Test]
  510. public void SetBitCalledWhenSetProperty () {
  511. StyleTestClass s = new StyleTestClass ();
  512. s.SetBitCalledFlag = false;
  513. s.BackColor = Color.Aqua;
  514. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BackColor");
  515. Assert.AreEqual (0x08, s.SetBitCalledValue, "SetBit() was called with wrong argument : BackColor");
  516. s.SetBitCalledFlag = false;
  517. s.BorderColor = Color.Blue;
  518. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderColor");
  519. Assert.AreEqual (0x10, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderColor");
  520. s.SetBitCalledFlag = false;
  521. s.BorderStyle = BorderStyle.Dashed;
  522. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderStyle");
  523. Assert.AreEqual (0x40, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderStyle");
  524. s.SetBitCalledFlag = false;
  525. s.BorderWidth = 1;
  526. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderWidth");
  527. Assert.AreEqual (0x20, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderWidth");
  528. s.SetBitCalledFlag = false;
  529. s.CssClass = "class";
  530. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : CssClass");
  531. Assert.AreEqual (0x02, s.SetBitCalledValue, "SetBit() was called with wrong argument : CssClass");
  532. s.SetBitCalledFlag = false;
  533. s.ForeColor = Color.Red;
  534. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : ForeColor");
  535. Assert.AreEqual (0x04, s.SetBitCalledValue, "SetBit() was called with wrong argument : ForeColor");
  536. s.SetBitCalledFlag = false;
  537. s.Height = 1;
  538. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Height");
  539. Assert.AreEqual (0x80, s.SetBitCalledValue, "SetBit() was called with wrong argument : Height");
  540. s.SetBitCalledFlag = false;
  541. s.Width = 1;
  542. Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Width");
  543. Assert.AreEqual (0x100, s.SetBitCalledValue, "SetBit() was called with wrong argument : Width");
  544. }
  545. public void Render ()
  546. {
  547. HtmlTextWriter writer;
  548. StyleTestClass s;
  549. writer = StyleTest.GetWriter();
  550. s = new StyleTestClass ();
  551. s.BorderColor = Color.BlueViolet;
  552. s.AddAttributesToRender(writer);
  553. // Figure out an order-independent way to verify rendered results
  554. }
  555. }
  556. }