public void GetHamlNode_DifferentHamlLineTypes_ReturnsCorrectHamlNode(HamlRuleEnum rule, Type nodeType) { var line = new HamlLine("Blah", rule, "", 0); var result = HamlNodeFactory.GetHamlNode(line); Assert.That(result, Is.InstanceOf(nodeType)); }
public HamlLine(string content, HamlRuleEnum hamlRule, HamlSourceFileMetrics metrics = null, string indent = "", bool isInline = false) { Metrics = metrics ?? new HamlSourceFileMetrics(0, -1, content.Length, 0); Content = content; Indent = isInline ? "" : indent; IndentCount = IsBlankLine(content, hamlRule) ? 0 : GetIndentCount(indent); HamlRule = hamlRule; IsInline = isInline; }
public HamlLine(string content, HamlRuleEnum hamlRule, string indent = "", int sourceFileLineNum = -1, bool isInline = false) { SourceFileLineNo = sourceFileLineNum; Content = content; Indent = isInline ? "" : indent; IndentCount = IsBlankLine(content, hamlRule) ? 0 : GetIndentCount(indent); HamlRule = hamlRule; IsInline = isInline; }
public void Constructor_CalculatesRuleTypeCorrectly(string testString, HamlRuleEnum expectedRule) { var rule = HamlRuleFactory.ParseHamlRule(ref testString); Assert.AreEqual(expectedRule, rule); }
private static bool IsBlankLine(string content, HamlRuleEnum hamlRule) { return(hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content)); }
public void Constructor_MaintainsIndentForNonTextNodes(string indent, string content, HamlRuleEnum rule, int expectedIndent) { var line = new HamlLine(content, rule, indent, 0); Assert.AreEqual(expectedIndent, line.IndentCount); }
public void GetHamlNode_TagSubTypes_ThrowsHamlUnknownRuleException(HamlRuleEnum rule, Type nodeType) { var line = new HamlLine("Blah", rule, indent: ""); Assert.Throws<HamlParserUnknownRuleException>(() => HamlNodeFactory.GetHamlNode(line)); }
public void GetHamlNode_DifferentHamlLineTypes_ReturnsCorrectHamlNode(HamlRuleEnum rule, Type nodeType) { var line = new HamlLine("Blah", rule, indent: ""); var result = HamlNodeFactory.GetHamlNode(line); Assert.That(result, Is.InstanceOf(nodeType)); }
private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule) { return hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass; }
private static bool IsBlankLine(string content, HamlRuleEnum hamlRule) { return (hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content)); }
private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule) { return(hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass); }
private void ParseHamlLine(string currentLine) { _indentCount = 0; int whiteSpaceIndex = 0; while (whiteSpaceIndex < currentLine.Length) { if (currentLine[whiteSpaceIndex] == ' ') _indentCount++; else if (currentLine[whiteSpaceIndex] == '\t') _indentCount += 2; else break; whiteSpaceIndex++; } _indent = currentLine.Substring(0, whiteSpaceIndex); _content = (whiteSpaceIndex == currentLine.Length) ? "" : currentLine.Substring(whiteSpaceIndex); if (string.IsNullOrEmpty(_content)) _indentCount = 0; AddImplicitDivTag(); _hamlRule = ParseHamlRule(); }
public void Constructor_MaintainsIndentForNonTextNodes(string indent, string content, HamlRuleEnum rule, int expectedIndent) { var line = new HamlLine(content, rule, indent: indent); Assert.AreEqual(expectedIndent, line.IndentCount); }
public void GetHamlNode_TagSubTypes_ThrowsHamlUnknownRuleException(HamlRuleEnum rule, Type nodeType) { var line = new HamlLine("Blah", rule, "", 0); Assert.Throws <HamlUnknownRuleException>(() => HamlNodeFactory.GetHamlNode(line)); }