Example #1
0
        public void Walk_InternalWhitespaceRemoval_GeneratesCorrectOutput()
        {
            var tagNode = new HamlNodeTag(new HamlLine("p<", HamlRuleEnum.Tag, "", 0));

            //tagNode.IsMultiLine = true;

            tagNode.AddChild(new HamlNodeTextContainer(new HamlLine("\n", HamlRuleEnum.PlainText, "", 0)));
            tagNode.AddChild(new HamlNodeTextContainer(new HamlLine("  Hello", HamlRuleEnum.PlainText, "", 0)));

            _tagWalker.Walk(tagNode);

            const string expectedOutput = "<p>Hello</p>";

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedOutput));
        }
Example #2
0
        public void Walk_ClassNoteAndClassHtmlAttribute_WritesCorrectIdAttribute()
        {
            // Arrange
            var tagNode = new HamlNodeTag(new HamlLine("p", HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeTagClass(0, "class2"));
            tagNode.AddChild(new HamlNodeHtmlAttributeCollection(0, "(class='class1')"));

            // Act
            _tagWalker.Walk(tagNode);

            // Assert
            const string expectedIdAttr = @"class='class1 class2'";

            Assert.That(_classBuilderMock.Build(""), Is.StringContaining(expectedIdAttr));
        }
Example #3
0
        public void Walk_MultipleIdNodes_WritesCorrectIdAttribute()
        {
            // Arrange
            var tagNode = new HamlNodeTag(new HamlLine("p", HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeTagId(0, "id1"));
            tagNode.AddChild(new HamlNodeTagId(0, "id2"));

            // Act
            _tagWalker.Walk(tagNode);

            // Assert
            const string expectedIdAttr = @"id='id2'";

            Assert.That(_classBuilderMock.Build(""), Is.StringContaining(expectedIdAttr));
        }
Example #4
0
        public void Walk_IdFollowedByClassNodes_OrderedCorrectly()
        {
            // Arrange
            const string tagId    = "id";
            const string tagClass = "class";
            var          tagNode  = new HamlNodeTag(new HamlLine("p", HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeTagId(0, tagId));
            tagNode.AddChild(new HamlNodeTagClass(0, tagClass));

            // Act
            _tagWalker.Walk(tagNode);

            // Assert
            const string expectedTag = @"<p class='class' id='id'></p>";

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedTag));
        }
Example #5
0
        public void Walk_WhitespaceRemoval_GeneratesCorrectOutput(string line1, string line2, string line3, string expectedOutput)
        {
            var tagNode = new HamlNodeTag(new HamlLine(line1, HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeTag(new HamlLine(line2, HamlRuleEnum.Tag, "  ", 0)));

            _tagWalker.Walk(tagNode);

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedOutput));
        }
Example #6
0
        public void Walk_EmptyAttributeCollectionNode_WritesCorrectAttributes(string tag, string attributes, string expectedOutput)
        {
            var tagNode = new HamlNodeTag(new HamlLine(tag, HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeHtmlAttributeCollection(0, attributes));

            _tagWalker.Walk(tagNode);

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedOutput));
        }
Example #7
0
        public void Walk_InlineContent_GeneratesCorrectOutput()
        {
            var tagNode = new HamlNodeTag(new HamlLine("p", HamlRuleEnum.Tag));

            tagNode.AddChild(new HamlNodeTextContainer(new HamlLine("Content", HamlRuleEnum.PlainText, "\t", 0, true)));

            _tagWalker.Walk(tagNode);

            const string expectedOutput = "<p>Content</p>";

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedOutput));
        }
Example #8
0
        public void Walk_NestedTags_AppendsCorrectTags()
        {
            // Arrange
            const string tagName    = "p";
            const string nestedText = "Hello world";
            var          tagNode    = new HamlNodeTag(new HamlLine(tagName, HamlRuleEnum.Tag, "", 0));

            tagNode.AddChild(new HamlNodeTextContainer(new HamlLine(nestedText, HamlRuleEnum.PlainText, "", 1, true)));
            // Act
            _tagWalker.Walk(tagNode);

            // Assert
            string expectedTag = string.Format("<{0}>{1}</{0}>", tagName, nestedText);

            Assert.That(_classBuilderMock.Build(""), Is.EqualTo(expectedTag));
        }