Esempio n. 1
0
        public void CopyFrom_Empty()
        {
            StyleTestClass s = new StyleTestClass();

            s.CopyFrom(new Style());
            Assert.IsTrue(s.Empty, "Empty");
        }
Esempio n. 2
0
        public void Constructor_StateBag_Null()
        {
            StyleTestClass s = new StyleTestClass(null);

            Assert.IsNotNull(s.StateBag, "StateBag");
            s.CssClass = "mono";
            Assert.AreEqual("mono", s.CssClass, "CssClass");
        }
Esempio n. 3
0
        public void Empty()
        {
            StyleTestClass s = new StyleTestClass();

            Assert.IsTrue(s.Empty, "Empty");
            Assert.AreEqual(0, s.StateBag.Count, "Count");
            s.StateBag["Mono"] = "go!";
            Assert.IsTrue(s.Empty, "Still Empty");
            Assert.AreEqual(1, s.StateBag.Count, "Count");
        }
Esempio n. 4
0
        public void FontInfo_Empty()
        {
            FontInfo       f;
            StyleTestClass s = new StyleTestClass();

            f = s.Font;
            Assert.IsTrue(s.Empty, "Empty after getter");
            s.Font.Name = "Arial";
            Assert.IsFalse(s.Empty, "No longer empty");
        }
Esempio n. 5
0
        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");
        }
Esempio n. 6
0
        public void Render()
        {
            HtmlTextWriter writer;
            StyleTestClass s;

            writer = StyleTest.GetWriter();
            s      = new StyleTestClass();

            s.BorderColor = Color.BlueViolet;
            s.AddAttributesToRender(writer);
            // Figure out an order-independent way to verify rendered results
        }
Esempio n. 7
0
        public void Style_RegisteredCssClass()
        {
            StyleTestClass s = new StyleTestClass();

            Assert.AreEqual(String.Empty, s.RegisteredCssClass, "Css1");

            s.SetCssClass("blah");
            Assert.AreEqual("blah", s.RegisteredCssClass, "Css2");

            s.BackColor = Color.AliceBlue;
            Assert.AreEqual("blah", s.RegisteredCssClass, "Css3");
        }
Esempio n. 8
0
        public void CopyFrom_IsEmpty()
        {
            StyleTestClass c = new StyleTestClass();
            Style          s = GetStyle();

            s.BorderColor = Color.Azure;
            s.BorderWidth = Unit.Empty;

            c.CopyFrom(s);

            Assert.IsFalse(c.Empty, "IsEmpty");
        }
Esempio n. 9
0
        public void Style_CssClass()
        {
            StyleTestClass s = new StyleTestClass();

            Assert.AreEqual(String.Empty, s.CssClass, "#A1");

            s.CssClass = "css1";
            Assert.AreEqual("css1", s.CssClass, "#A2");

            s.CssClass = String.Empty;
            Assert.AreEqual(String.Empty, s.CssClass, "#A3");

            s.CssClass = null;
            Assert.AreEqual(String.Empty, s.CssClass, "#A4");
        }
Esempio n. 10
0
		public void Style_BorderStyle_InvalidValue2 ()
		{
			StyleTestClass s = new StyleTestClass ();
			s.BorderStyle = (BorderStyle)(BorderStyle.Outset + 1);
		}
Esempio n. 11
0
		public void Style_RegisteredCssClass ()
		{
			StyleTestClass s = new StyleTestClass ();

			Assert.AreEqual (String.Empty, s.RegisteredCssClass, "Css1");

			s.SetCssClass ("blah");
			Assert.AreEqual ("blah", s.RegisteredCssClass, "Css2");

			s.BackColor = Color.AliceBlue;
			Assert.AreEqual ("blah", s.RegisteredCssClass, "Css3");
		}
Esempio n. 12
0
        public void Style_BorderStyle_InvalidValue2()
        {
            StyleTestClass s = new StyleTestClass();

            s.BorderStyle = (BorderStyle)(BorderStyle.Outset + 1);
        }
Esempio n. 13
0
		public void CopyFrom_Empty ()
		{
			StyleTestClass s = new StyleTestClass ();
			s.CopyFrom (new Style ());
			Assert.IsTrue (s.Empty, "Empty");
		}
Esempio n. 14
0
        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");

            s.SetBitCalledFlag = false;
            s.Font.Bold        = true;
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Bold");
            Assert.AreEqual(0x800, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Bold");

            s.SetBitCalledFlag = false;
            s.Font.Italic      = true;
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Italic");
            Assert.AreEqual(0x1000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Italic");

            s.SetBitCalledFlag = false;
            s.Font.Overline    = true;
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Overline");
            Assert.AreEqual(0x4000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Overline");

            s.SetBitCalledFlag = false;
            s.Font.Underline   = true;
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Underline");
            Assert.AreEqual(0x2000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Underline");

            s.SetBitCalledFlag = false;
            s.Font.Strikeout   = true;
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Strikeout");
            Assert.AreEqual(0x8000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Strikeout");

            s.SetBitCalledFlag = false;
            s.Font.Names       = new string [] { "Arial" };
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Names");
            Assert.AreEqual(0x200, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Strikeout");

            s.SetBitCalledFlag = false;
            s.Font.Size        = new FontUnit(10);
            Assert.IsTrue(s.SetBitCalledFlag, "SetBit() was not called : Font.Size");
            Assert.AreEqual(0x400, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Size");
        }
Esempio n. 15
0
        public void Style_State()
        {
            string[] keyvalues;
            string[] expect1 =
            {
                "BorderStyle=None",
                "Font_Bold=True",
                "Font_Italic=True",
                "Height=2px",
                "CssClass=Boing",
                "BorderWidth=1px",
                "ForeColor=Color [Blue]",
                "Font_Size=1pt",
                "Font_Overline=True",
                "Width=3px",
                "BorderColor=Color [Green]",
                "Font_Names=namelist1, namelist2",
                "Font_Underline=True",
                "BackColor=Color [Red]",
                "Font_Strikeout=True"
            };
            string[] expect2 =
            {
                "BorderStyle=None",
                "Font_Bold=True",
                "Font_Italic=True",
                "Height=2px",
                "CssClass=Boing",
                "BorderWidth=1px",
                "ForeColor=Color [Blue]",
                "Font_Size=1pt",
                "Font_Overline=True",
                "Width=3px",
                "BorderColor=Color [Green]",
                "Font_Underline=True",
                "BackColor=Color [Red]",
                "Font_Strikeout=True"
            };
            string[] expect3 =
            {
                "BorderStyle=None",
                "Font_Bold=True",
                "Font_Italic=True",
                "Height=2px",
                "CssClass=Boing",
                "BorderWidth=1px",
                "ForeColor=Color [Blue]",
                "Font_Size=1pt",
                "Font_Overline=True",
                "Width=3px",
                "BorderColor=Color [Green]",
                "Font_Names=",
                "Font_Underline=True",
                "BackColor=Color [Red]",
                "Font_Strikeout=True"
            };
            StyleTestClass s;
            StyleTestClass copy;

            s = new StyleTestClass();
            SetAllValues(s);
            keyvalues = s.KeyValuePairs();

            Assert.AreEqual(15, keyvalues.Length, "State1");
            IsEqual(keyvalues, expect1, "State2");

            s.Font.Name = string.Empty;
            keyvalues   = s.KeyValuePairs();
            Assert.AreEqual(expect2.Length, keyvalues.Length, "State3");
            IsEqual(keyvalues, expect2, "State4");

            s.Font.Names = null;
            keyvalues    = s.KeyValuePairs();
            Assert.AreEqual(expect2.Length, keyvalues.Length, "State5");
            IsEqual(keyvalues, expect2, "State6");

            copy = new StyleTestClass();
            copy.CopyFrom(s);
            keyvalues = copy.KeyValuePairs();
            Assert.AreEqual(expect3.Length, keyvalues.Length, "State7");
            IsEqual(keyvalues, expect3, "State8");

            Assert.AreEqual(false, copy.IsTracking, "State9");
        }
Esempio n. 16
0
		public void Style_State () {
			string[]	keyvalues;
			string[]	expect1 = {
						"BorderStyle=None",
						"Font_Bold=True",
						"Font_Italic=True",
						"Height=2px",
						"CssClass=Boing",
						"BorderWidth=1px",
						"ForeColor=Color [Blue]",
						"Font_Size=1pt",
						"Font_Overline=True",
						"Width=3px",
						"BorderColor=Color [Green]",
						"Font_Names=namelist1, namelist2",
						"Font_Underline=True",
						"BackColor=Color [Red]",
						"Font_Strikeout=True" };
			string[]	expect2 = {
						"BorderStyle=None",
						"Font_Bold=True",
						"Font_Italic=True",
						"Height=2px",
						"CssClass=Boing",
						"BorderWidth=1px",
						"ForeColor=Color [Blue]",
						"Font_Size=1pt",
						"Font_Overline=True",
						"Width=3px",
						"BorderColor=Color [Green]",
						"Font_Underline=True",
						"BackColor=Color [Red]",
						"Font_Strikeout=True" };
			string[]	expect3 = {
						"BorderStyle=None",
						"Font_Bold=True",
						"Font_Italic=True",
						"Height=2px",
						"CssClass=Boing",
						"BorderWidth=1px",
						"ForeColor=Color [Blue]",
						"Font_Size=1pt",
						"Font_Overline=True",
						"Width=3px",
						"BorderColor=Color [Green]",
						"Font_Names=",
						"Font_Underline=True",
						"BackColor=Color [Red]",
						"Font_Strikeout=True" };
			StyleTestClass	s;
			StyleTestClass	copy;

			s = new StyleTestClass();
			SetAllValues(s);
			keyvalues = s.KeyValuePairs();
			
			Assert.AreEqual (15, keyvalues.Length, "State1");
			IsEqual(keyvalues, expect1, "State2");

			s.Font.Name = string.Empty;
			keyvalues = s.KeyValuePairs();
			Assert.AreEqual (expect2.Length, keyvalues.Length, "State3");
			IsEqual(keyvalues, expect2, "State4");

			s.Font.Names = null;
			keyvalues = s.KeyValuePairs();
			Assert.AreEqual (expect2.Length, keyvalues.Length, "State5");
			IsEqual(keyvalues, expect2, "State6");

			copy = new StyleTestClass();
			copy.CopyFrom(s);
			keyvalues = copy.KeyValuePairs();
			Assert.AreEqual (expect3.Length, keyvalues.Length, "State7");
			IsEqual(keyvalues, expect3, "State8");

			Assert.AreEqual (false, copy.IsTracking, "State9");

		}
Esempio n. 17
0
		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");
			
			s.SetBitCalledFlag = false;
			s.Font.Bold = true;
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Bold");
			Assert.AreEqual (0x800, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Bold");

			s.SetBitCalledFlag = false;
			s.Font.Italic = true;
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Italic");
			Assert.AreEqual (0x1000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Italic");

			s.SetBitCalledFlag = false;
			s.Font.Overline = true;
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Overline");
			Assert.AreEqual (0x4000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Overline");

			s.SetBitCalledFlag = false;
			s.Font.Underline = true;
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Underline");
			Assert.AreEqual (0x2000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Underline");

			s.SetBitCalledFlag = false;
			s.Font.Strikeout = true;
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Strikeout");
			Assert.AreEqual (0x8000, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Strikeout");

			s.SetBitCalledFlag = false;
			s.Font.Names = new string [] { "Arial" };
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Names");
			Assert.AreEqual (0x200, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Strikeout");

			s.SetBitCalledFlag = false;
			s.Font.Size = new FontUnit (10);
			Assert.IsTrue (s.SetBitCalledFlag, "SetBit() was not called : Font.Size");
			Assert.AreEqual (0x400, s.SetBitCalledValue, "SetBit() was called with wrong argument : Font.Size");
		}
Esempio n. 18
0
		public void FontInfo_Empty ()
		{
			FontInfo f;
			StyleTestClass s = new StyleTestClass ();
			f = s.Font;
			Assert.IsTrue (s.Empty, "Empty after getter");
			s.Font.Name = "Arial";
			Assert.IsFalse (s.Empty, "No longer empty");
		}
Esempio n. 19
0
		public void Empty ()
		{
			StyleTestClass s = new StyleTestClass ();
			Assert.IsTrue (s.Empty, "Empty");
			Assert.AreEqual (0, s.StateBag.Count, "Count");
			s.StateBag["Mono"] = "go!";
			Assert.IsTrue (s.Empty, "Still Empty");
			Assert.AreEqual (1, s.StateBag.Count, "Count");
		}
Esempio n. 20
0
		public void Constructor_StateBag_Null ()
		{
			StyleTestClass s = new StyleTestClass (null);
			Assert.IsNotNull (s.StateBag, "StateBag");
			s.CssClass = "mono";
			Assert.AreEqual ("mono", s.CssClass, "CssClass");
		}
Esempio n. 21
0
		public void CopyFrom_IsEmpty ()
		{
			StyleTestClass c = new StyleTestClass ();
			Style s = GetStyle ();

			s.BorderColor = Color.Azure;
			s.BorderWidth = Unit.Empty;

			c.CopyFrom (s);

			Assert.IsFalse (c.Empty, "IsEmpty");
		}
Esempio n. 22
0
		public void Style_BorderStyle_InvalidValue1 ()
		{
			StyleTestClass s = new StyleTestClass ();
			s.BorderStyle = (BorderStyle)(BorderStyle.NotSet - 1);
		}
Esempio n. 23
0
		public void Style_CssClass ()
		{
			StyleTestClass s = new StyleTestClass ();
			Assert.AreEqual (String.Empty, s.CssClass, "#A1");

			s.CssClass = "css1";
			Assert.AreEqual ("css1", s.CssClass, "#A2");

			s.CssClass = String.Empty;
			Assert.AreEqual (String.Empty, s.CssClass, "#A3");

			s.CssClass = null;
			Assert.AreEqual (String.Empty, s.CssClass, "#A4");
		}
Esempio n. 24
0
        public void Style_BorderStyle_InvalidValue1()
        {
            StyleTestClass s = new StyleTestClass();

            s.BorderStyle = (BorderStyle)(BorderStyle.NotSet - 1);
        }
Esempio n. 25
0
		public void Render ()
		{
			HtmlTextWriter	writer;
			StyleTestClass	s;

			writer = StyleTest.GetWriter();
			s  = new StyleTestClass ();

			s.BorderColor = Color.BlueViolet;
			s.AddAttributesToRender(writer);
			// Figure out an order-independent way to verify rendered results
		}
Esempio n. 26
0
		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 ();

			string origHtml = "<span style=\"FillStyleAttributes:FillStyleAttributes;\"></span>";
			string renderedHtml = sw.ToString ();
			HtmlDiff.AssertAreEqual (origHtml, renderedHtml, "AddAttributesToRender_use_FillStyleAttributes#2");
		}