public void NoScriptInAttributeValue(ErrorMode errorMode) { PexAssume.EnumIsDefined(errorMode); var encoded = BBEncodeForTest("[url=<script>][/url]", errorMode); Assert.IsFalse(encoded.Contains("<script")); }
public void Roundtrip(ErrorMode errorMode, out string bbcode, out string output) { PexAssume.EnumIsDefined(errorMode); var parser = BBCodeTestUtil.GetParserForTest(errorMode, false, BBTagClosingStyle.AutoCloseElement, false); var tree = BBCodeTestUtil.CreateRootNode(parser.Tags.ToArray()); bbcode = tree.ToBBCode(); var tree2 = parser.ParseSyntaxTree(bbcode); output = tree2.ToHtml(); Assert.IsTrue(tree == tree2); }
public void NoScript_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input) { PexAssume.EnumIsDefined(errorMode); try { var output = BBEncodeForTest(input, errorMode); PexAssert.IsTrue(!output.Contains("<script")); } catch (BBCodeParsingException) { PexAssume.Fail(); } }
public void NoHtmlChars_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input) { PexAssume.EnumIsDefined(errorMode); try { var output = BBCodeTestUtil.SimpleBBEncodeForTest(input, errorMode); PexObserve.ValueForViewing("output", output); PexAssert.IsTrue(output.IndexOf('<') == -1); PexAssert.IsTrue(output.IndexOf('>') == -1); } catch (BBCodeParsingException) { PexAssume.Fail(); } }
public void NoCrash(ErrorMode errorMode, [PexAssumeNotNull] string input, BBTagClosingStyle listItemBbTagClosingStyle, out string output) { PexAssume.EnumIsDefined(errorMode); PexAssume.EnumIsDefined(listItemBbTagClosingStyle); try { output = BBEncodeForTest(input, errorMode, listItemBbTagClosingStyle, false); Assert.IsNotNull(output); } catch (BBCodeParsingException) { Assert.AreNotEqual(ErrorMode.ErrorFree, errorMode); output = null; } }
public void TextNodesCannotBeSplit(ErrorMode errorMode, [PexAssumeNotNull] string input) { PexAssume.EnumIsDefined(errorMode); var parser = BBCodeTestUtil.GetParserForTest(errorMode, true, BBTagClosingStyle.AutoCloseElement, false); SequenceNode tree; try { tree = parser.ParseSyntaxTree(input); } #pragma warning disable 168 catch (BBCodeParsingException e) #pragma warning restore 168 { PexAssume.Fail(); return; } AssertTextNodesNotSplit(tree); }
public void Roundtrip2(ErrorMode errorMode, [PexAssumeNotNull] string input, out string bbcode, out string output) { PexAssume.EnumIsDefined(errorMode); var parser = BBCodeTestUtil.GetParserForTest(errorMode, false, BBTagClosingStyle.AutoCloseElement, false); SequenceNode tree; try { tree = parser.ParseSyntaxTree(input); } #pragma warning disable 168 catch (BBCodeParsingException e) #pragma warning restore 168 { PexAssume.Fail(); tree = null; } bbcode = tree.ToBBCode(); var tree2 = parser.ParseSyntaxTree(bbcode); output = tree2.ToHtml(); Assert.IsTrue(tree == tree2); }
public void NoScript_FixedInput(ErrorMode errorMode) { PexAssume.EnumIsDefined(errorMode); Assert.IsFalse(BBEncodeForTest("<script>", errorMode).Contains("<script")); }