Esempio n. 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));
        }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 5
0
 public void Constructor_CalculatesRuleTypeCorrectly(string testString, HamlRuleEnum expectedRule)
 {
     var rule = HamlRuleFactory.ParseHamlRule(ref testString);
     Assert.AreEqual(expectedRule, rule);
 }
Esempio n. 6
0
 private static bool IsBlankLine(string content, HamlRuleEnum hamlRule)
 {
     return(hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content));
 }
Esempio n. 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);
        }
Esempio n. 8
0
 public void GetHamlNode_TagSubTypes_ThrowsHamlUnknownRuleException(HamlRuleEnum rule, Type nodeType)
 {
     var line = new HamlLine("Blah", rule, indent: "");
     Assert.Throws<HamlParserUnknownRuleException>(() => HamlNodeFactory.GetHamlNode(line));
 }
Esempio n. 9
0
 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));
 }
Esempio n. 10
0
 private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule)
 {
     return hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass;
 }
Esempio n. 11
0
 private static bool IsBlankLine(string content, HamlRuleEnum hamlRule)
 {
     return (hamlRule == HamlRuleEnum.PlainText && string.IsNullOrEmpty(content));
 }
Esempio n. 12
0
 private static bool IsRuleThatAllowsInlineContent(HamlRuleEnum hamlRule)
 {
     return(hamlRule == HamlRuleEnum.Tag || hamlRule == HamlRuleEnum.DivId || hamlRule == HamlRuleEnum.DivClass);
 }
Esempio n. 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();
        }
Esempio n. 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);
 }
Esempio n. 15
0
        public void Constructor_CalculatesRuleTypeCorrectly(string testString, HamlRuleEnum expectedRule)
        {
            var rule = HamlRuleFactory.ParseHamlRule(ref testString);

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

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