Пример #1
0
        public void SetStyleTest()
        {
            var element = new JumonyParser().Parse( "<div></div>" ).Elements().First();

              element.Style( "display", "none" );
              Assert.AreEqual( element.Attribute( "style" ).Value(), "display:none", ".Style( name, value ) 测试不通过" );

              element.Style().SetValue( "color", "red" );
              Assert.AreEqual( element.Attribute( "style" ).Value(), "display:none;color:red", ".Style().SetValue( name, value ) 测试不通过" );

              element.Style().SetValue( "display", "block" );
              Assert.AreEqual( element.Attribute( "style" ).Value(), "display:block;color:red", ".Style().SetValue( name, value ) 测试不通过" );

              element.Style().SetValue( "display", null );
              Assert.AreEqual( element.Attribute( "style" ).Value(), "color:red", ".Style().SetValue( name, null ) 测试不通过" );

              element.Style().Clear();
              Assert.AreEqual( element.Attribute( "style" ).Value(), "", ".Style().Clear() 测试不通过" );

              element.Style().SetValue( "padding", "10px" );
              Assert.AreEqual( element.Style().GetValue( "padding-left" ), "10px", "shorthand 展开测试不通过" );

              element.Style().SetValue( "padding-left", "0px" );
              Assert.AreEqual( element.Style().GetValue( "padding-left" ), "0px", "shorthand 展开测试不通过" );
              Assert.AreEqual( element.Style().GetValue( "padding-top" ), "10px", "shorthand 展开测试不通过" );

              element.Style().SetValue( "margin", "5px" );
              Assert.AreEqual( element.Style().GetValue( "margin-left" ), "5px", "margin shorthand 展开测试不通过" );
        }