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"); }
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"); }
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]"); }
public ShortcodeParser(IRenderShortcode renderShortcode) { _renderShortcode = renderShortcode; }