Пример #1
0
        public void Parse_MatchedContentIsReplaced(
            [Frozen] IRenderShortcode renderShortcode,
            ShortcodeParser sut,
            IHtmlHelper helper
            )
        {
            A.CallTo(() => renderShortcode.CanRender("test")).Returns(true);
            A.CallTo(() => renderShortcode.Render(helper, "test", A <Dictionary <string, string> > .Ignored))
            .Returns("Updated text");
            const string content = "[test]";

            var result = sut.Parse(helper, content);

            result.ToString().Should().Be("Updated text");
        }
Пример #2
0
        public void Parse_GetsAttributesFromShortcode(
            [Frozen] IRenderShortcode renderShortcode,
            ShortcodeParser sut,
            IHtmlHelper helper
            )
        {
            A.CallTo(() => renderShortcode.CanRender("test")).Returns(true);
            A.CallTo(() =>
                     renderShortcode.Render(helper, "test",
                                            A <Dictionary <string, string> > .That.Matches(
                                                dictionary => dictionary.ContainsKey("id") && dictionary["id"] == "123")))
            .Returns("Updated text");
            const string content = "[test id=\"123\"]";

            var result = sut.Parse(helper, content);

            result.ToString().Should().Be("Updated text");
        }
Пример #3
0
        public void Parse_WithQuotes(
            [Frozen] IRenderShortcode renderShortcode,
            ShortcodeParser sut,
            IHtmlHelper helper
            )
        {
            var content = "[test id=\"123\"] sdfs adfsdf sdaf sadf asdfsdaf sdf sdf  more=(*&)(&knkjdhnf data]";


            A.CallTo(() => renderShortcode.CanRender("test")).Returns(true);
            A.CallTo(() =>
                     renderShortcode.Render(helper, "test ",
                                            A <Dictionary <string, string> > .That.Matches(
                                                dictionary =>
                                                dictionary.ContainsKey("id") && dictionary["id"] == "123"
                                                &&
                                                !dictionary.ContainsKey("more")
                                                )));

            var result = sut.Parse(helper, content);

            result.ToString().Should().Be(" sdfs adfsdf sdaf sadf asdfsdaf sdf sdf  more=(*&)(&knkjdhnf data]");
        }
Пример #4
0
 public ShortcodeParser(IRenderShortcode renderShortcode)
 {
     _renderShortcode = renderShortcode;
 }