public void ParseWidth_HeightAttributeTest() { //Parse tokens MarkupParser markupParser = new MarkupParser(Init("80%20")); Width_HeightAttribute parsedWidth_HeightAttribute = markupParser.ParseWidth_HeightAttribute(); //Check Id Attribute Assert.AreEqual(80, parsedWidth_HeightAttribute.GetWidth()); Assert.AreEqual(20, parsedWidth_HeightAttribute.GetHeight()); }
/// <summary> /// Parser for Width_HeightAttribute /// </summary> /// <returns>Parsed Width_HeightAttribute</returns> public Width_HeightAttribute ParseWidth_HeightAttribute() { Width_HeightAttribute widthHeightAttribute = new Width_HeightAttribute(); //Get width CurrentToken = TokenStream.NextToken(); widthHeightAttribute.SetWidth(ObjectToInt(CurrentToken.GetValue())); //Skip % token NextToken("%", "@width %height", '%'); //Get height CurrentToken = TokenStream.NextToken(); widthHeightAttribute.SetHeight(ObjectToInt(CurrentToken.GetValue())); return(widthHeightAttribute); }
public void ParseDesignatorWithAttributeTest() { //Parse tokens MarkupParser markupParser = new MarkupParser(Init("img@100%50")); Designator parsedDesignator = markupParser.ParseDesignator(); //Check designator Assert.AreEqual("img", parsedDesignator.GetIdentifier()); Assert.AreEqual(1, parsedDesignator.GetAttributes().Count); //Check attribute Attribute parsedAttribute = (Attribute)parsedDesignator.GetAttributes().Get(0); Assert.AreEqual(typeof(Width_HeightAttribute), parsedAttribute.GetType()); //Check Width_HeightAttribute contents Width_HeightAttribute attribute = (Width_HeightAttribute)parsedAttribute; Assert.AreEqual(100, attribute.GetWidth()); Assert.AreEqual(50, attribute.GetHeight()); }
/// <summary> /// Interpret Width_HeightAttribute /// </summary> /// <param name="attribute">Width_HeightAttribute to interpret</param> public override void Visit(Width_HeightAttribute attribute) { //Add width and height attribute Current.AddAttribute("width", attribute.GetWidth().ToString()); Current.AddAttribute("height", attribute.GetHeight().ToString()); }
public virtual void Visit(Width_HeightAttribute attribute) { VisitSubNodes(attribute); }