}
}
}
+
+ public override void AddAttributesToRender (HtmlTextWriter writer, WebControl owner) {
+ base.AddAttributesToRender (writer, owner);
+ }
+
+ protected override void FillStyleAttributes (CssStyleCollection attributes, IUrlResolutionService urlResolver) {
+ base.FillStyleAttributes (attributes, urlResolver);
+ attributes.Add ("FillStyleAttributes", "FillStyleAttributes");
+ }
#endif
public string[] KeyValuePairs() {
return result;
}
+
+ public bool SetBitCalledFlag = false;
+ public int SetBitCalledValue = 0;
+ protected override void SetBit (int bit) {
+ SetBitCalledFlag = true;
+ SetBitCalledValue = bit;
+ base.SetBit (bit);
+ }
}
[TestFixture]
Assert.AreEqual (sw.ToString ().LastIndexOf ("class"), sw.ToString ().IndexOf ("class"), "AddRegisteredCssClassAttribute#5");
Assert.AreEqual (false, sw.ToString ().Contains ("style"), "AddRegisteredCssClassAttribute#6");
Assert.AreEqual (true, sw.ToString ().Contains ("class=\"MyClass "), "AddRegisteredCssClassAttribute#7");
+
+ s = new Style ();
+ p.Header.StyleSheet.RegisterStyle (s, p);
+ Assert.AreEqual (false, s.IsEmpty, "AddRegisteredCssClassAttribute#8");
+ }
+
+ [Test]
+ public void Style_AddAttributesToRender_use_FillStyleAttributes () {
+ StringWriter sw = new StringWriter ();
+ HtmlTextWriter tw = new HtmlTextWriter (sw);
+ StyleTestClass s = new StyleTestClass ();
+ s.AddAttributesToRender (tw);
+ tw.RenderBeginTag ("span");
+ tw.RenderEndTag ();
+ HtmlDiff.AssertAreEqual ("<span style=\"FillStyleAttributes:FillStyleAttributes;\" />", sw.ToString (), "AddAttributesToRender_use_FillStyleAttributes#2");
+ }
+
+ [Test]
+ public void Style_GetStyleAttributes () {
+ Style s;
+ CssStyleCollection css;
+
+ s = new Style ();
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual (0, css.Count, "GetStyleAttributes#1");
+
+ s.Font.Bold = true;
+ s.Font.Italic = true;
+ s.Font.Size = 10;
+ s.Font.Names = new string [] { "Arial", "Veranda" };
+ s.Font.Overline = true;
+ s.Font.Strikeout = true;
+ s.Font.Underline = true;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("bold", css ["font-weight"], "GetStyleAttributes#2");
+ Assert.AreEqual ("italic", css ["font-style"], "GetStyleAttributes#3");
+ Assert.AreEqual ("10pt", css ["font-size"], "GetStyleAttributes#4");
+ Assert.AreEqual ("Arial,Veranda", css ["font-family"], "GetStyleAttributes#5");
+ Assert.AreEqual (true, css ["text-decoration"].Contains ("overline"), "GetStyleAttributes#6");
+ Assert.AreEqual (true, css ["text-decoration"].Contains ("line-through"), "GetStyleAttributes#7");
+ Assert.AreEqual (true, css ["text-decoration"].Contains ("underline"), "GetStyleAttributes#8");
+
+ s.Font.Names = null;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#9");
+
+ s.Font.Name = "Arial, Veranda";
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("Arial, Veranda", css ["font-family"], "GetStyleAttributes#10");
+
+ s.Font.Name = "";
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual (null, css ["font-family"], "GetStyleAttributes#11");
+
+ s.Font.Bold = false;
+ s.Font.Italic = false;
+ s.Font.Size = FontUnit.Empty;
+ s.Font.Overline = false;
+ s.Font.Strikeout = false;
+ s.Font.Underline = false;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("normal", css ["font-weight"], "GetStyleAttributes#12");
+ Assert.AreEqual ("normal", css ["font-style"], "GetStyleAttributes#13");
+ Assert.AreEqual (null, css ["font-size"], "GetStyleAttributes#14");
+ Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#15");
+
+ s.Reset ();
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual (0, css.Count, "GetStyleAttributes#16");
+
+ s.Reset ();
+ s.Font.Underline = false;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("none", css ["text-decoration"], "GetStyleAttributes#17");
+
+ s.Reset ();
+ s.BorderWidth = 1;
+ s.BorderStyle = BorderStyle.Dashed;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("Dashed", css ["border-style"], "GetStyleAttributes#18");
+ Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#19");
+
+ s.BorderStyle = BorderStyle.NotSet;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual ("solid", css ["border-style"], "GetStyleAttributes#20");
+ Assert.AreEqual ("1px", css ["border-width"], "GetStyleAttributes#21");
+
+ s.BorderWidth = 0;
+ css = s.GetStyleAttributes (null);
+ Assert.AreEqual (null, css ["border-style"], "GetStyleAttributes#22");
+ Assert.AreEqual ("0px", css ["border-width"], "GetStyleAttributes#23");
}
#endif
s.Font.Name = "Arial";
Assert.IsFalse (s.Empty, "No longer empty");
}
+
+ [Test]
+ public void SetBitCalledWhenSetProperty () {
+ StyleTestClass s = new StyleTestClass ();
+
+ s.SetBitCalledFlag = false;
+ s.BackColor = Color.Aqua;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BackColor");
+ Assert.AreEqual (0x08, s.SetBitCalledValue, "SetBit() was called with wrong argument : BackColor");
+
+ s.SetBitCalledFlag = false;
+ s.BorderColor = Color.Blue;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderColor");
+ Assert.AreEqual (0x10, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderColor");
+
+ s.SetBitCalledFlag = false;
+ s.BorderStyle = BorderStyle.Dashed;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderStyle");
+ Assert.AreEqual (0x40, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderStyle");
+
+ s.SetBitCalledFlag = false;
+ s.BorderWidth = 1;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : BorderWidth");
+ Assert.AreEqual (0x20, s.SetBitCalledValue, "SetBit() was called with wrong argument : BorderWidth");
+
+ s.SetBitCalledFlag = false;
+ s.CssClass = "class";
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : CssClass");
+ Assert.AreEqual (0x02, s.SetBitCalledValue, "SetBit() was called with wrong argument : CssClass");
+
+ s.SetBitCalledFlag = false;
+ s.ForeColor = Color.Red;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : ForeColor");
+ Assert.AreEqual (0x04, s.SetBitCalledValue, "SetBit() was called with wrong argument : ForeColor");
+
+ s.SetBitCalledFlag = false;
+ s.Height = 1;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Height");
+ Assert.AreEqual (0x80, s.SetBitCalledValue, "SetBit() was called with wrong argument : Height");
+
+ s.SetBitCalledFlag = false;
+ s.Width = 1;
+ Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Width");
+ Assert.AreEqual (0x100, s.SetBitCalledValue, "SetBit() was called with wrong argument : Width");
+ }
public void Render ()
{