Exemple #1
0
        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));
        }
Exemple #2
0
 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;
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 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);
 }
Exemple #6
0
 private static bool IsBlankLine(string content, HamlRuleEnum hamlRule)
 {
     return(hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content));
 }
Exemple #7
0
        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));
 }
Exemple #10
0
 private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule)
 {
     return hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass;
 }
Exemple #11
0
 private static bool IsBlankLine(string content, HamlRuleEnum hamlRule)
 {
     return (hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content));
 }
Exemple #12
0
 private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule)
 {
     return(hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass);
 }
Exemple #13
0
        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();
        }
Exemple #14
0
 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);
 }
Exemple #15
0
        public void Constructor_CalculatesRuleTypeCorrectly(string testString, HamlRuleEnum expectedRule)
        {
            var rule = HamlRuleFactory.ParseHamlRule(ref testString);

            Assert.AreEqual(expectedRule, rule);
        }
Exemple #16
0
        public void GetHamlNode_TagSubTypes_ThrowsHamlUnknownRuleException(HamlRuleEnum rule, Type nodeType)
        {
            var line = new HamlLine("Blah", rule, "", 0);

            Assert.Throws <HamlUnknownRuleException>(() => HamlNodeFactory.GetHamlNode(line));
        }