public void ParseTextWithEquals() { const string html = "="; List <Token> tokens = new TokenParser().Parse(html).ToList(); Token first = tokens.First(); Assert.Equal(first.Type, TokenType.Text); Assert.Equal("=", first.Value); }
public void DoesNotParseAsCommentLtWithSingleMinus() { const string html = "<!- head x=y z-->"; IEnumerable<Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Text, token.Type); Assert.Equal("<!- head x=y z-->", token.Value); }
public void DoesNotParseAsCommentLtWithSingleMinus() { const string html = "<!- head x=y z-->"; IEnumerable <Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Text, token.Type); Assert.Equal("<!- head x=y z-->", token.Value); }
public void ParseCommentWithTripleCloseMinus() { const string html = "<!--head x=y z--->"; IEnumerable <Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("head x=y z-", token.Value); }
public void ParseCommentWithDoubleMinusInside() { const string html = "<!--head x--y-- z-->"; IEnumerable <Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("head x--y-- z", token.Value); }
public void ParseEmptyComment2() { const string html = "<!---->"; IEnumerable <Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("", token.Value); }
public void ParseAttributeNameWithoutWhitespaces() { const string html = "<head x >"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token last = tokens.Last(); Assert.Equal(TokenType.AttributeName, last.Type); Assert.Equal("x", last.Value); }
public void ParseAttributeDoubleQuotedValueWithLtInside() { const string html = "<head x=\"y<z\">"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y<z", attrValue.Value); }
public void ParseAttributeSingleQuotedValueWithSlashInside() { const string html = "<head x='y/z'>"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y/z", attrValue.Value); }
public void ParseAttributeDoubleQuotedValueWithWhitespaces() { const string html = "<head x=\"y z\">"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y z", attrValue.Value); }
public void ParseAttributeValueWithGt() { const string html = "<head x=>>x"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.Text, attrValue.Type); Assert.Equal(">x", attrValue.Value); }
public void ParseTextInsideTag() { const string html = "<head>text</head>"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Token first = tokens.First(); Assert.Equal(TokenType.OpenTag, first.Type); Assert.Equal("head", first.Value); Token text = tokens[1]; Assert.Equal(TokenType.Text, text.Type); Assert.Equal("text", text.Value); Token closeTag = tokens[2]; Assert.Equal(TokenType.CloseTag, closeTag.Type); Assert.Equal("head", closeTag.Value); }
public void ParseAttributeNameAfterAttributeValue() { const string html = "<head x=y z>"; List <Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y", attrValue.Value); Token secondAttrName = tokens[3]; Assert.Equal(TokenType.AttributeName, secondAttrName.Type); Assert.Equal("z", secondAttrName.Value); }
public void ParseAttributeNameWithoutWhitespaces() { const string html = "<head x >"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token last = tokens.Last(); Assert.Equal(TokenType.AttributeName, last.Type); Assert.Equal("x", last.Value); }
public void ParseCommentWithMinusInside() { const string html = "<!--head x-y- z-->"; IEnumerable<Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("head x-y- z", token.Value); }
public void ParseCommentWithTripleCloseMinus() { const string html = "<!--head x=y z--->"; IEnumerable<Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("head x=y z-", token.Value); }
public void ParseEmptyComment2() { const string html = "<!---->"; IEnumerable<Token> tokens = new TokenParser().Parse(html); Token token = tokens.First(); Assert.Equal(TokenType.Comment, token.Type); Assert.Equal("", token.Value); }
public void ParseTextInsideTag() { const string html = "<head>text</head>"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Token first = tokens.First(); Assert.Equal(TokenType.OpenTag, first.Type); Assert.Equal("head", first.Value); Token text = tokens[1]; Assert.Equal(TokenType.Text, text.Type); Assert.Equal("text", text.Value); Token closeTag = tokens[2]; Assert.Equal(TokenType.CloseTag, closeTag.Type); Assert.Equal("head", closeTag.Value); }
public void ParseTextWithSlash() { const string html = "/"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Token first = tokens.First(); Assert.Equal(first.Type, TokenType.Text); Assert.Equal("/", first.Value); }
public void ParseAttributeNameAfterAttributeValue() { const string html = "<head x=y z>"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y", attrValue.Value); Token secondAttrName = tokens[3]; Assert.Equal(TokenType.AttributeName, secondAttrName.Type); Assert.Equal("z", secondAttrName.Value); }
public void ParseAttributeValueWithWhitespaces() { const string html = "<head x= y >"; List<Token> tokens = new TokenParser().Parse(html).ToList(); Assert.Equal("head", tokens.First().Value); Token attrName = tokens[1]; Assert.Equal(TokenType.AttributeName, attrName.Type); Assert.Equal("x", attrName.Value); Token attrValue = tokens[2]; Assert.Equal(TokenType.AttributeValue, attrValue.Type); Assert.Equal("y", attrValue.Value); }