public void NothingToDoKeepsTextUnchanged() { var text = "!,-@{}=?"; var result = Src2Html.GetHtml(text); Assert.AreEqual(text, result); }
public void SafeHtml() { var text = "<>&"; var result = Src2Html.GetHtml(text); Assert.AreEqual("<>&", result); }
public void BacktickQuotes() { Src2Html.Settings.QuoteChars = new[] { '\'', '"', '`' }; var result = Src2Html.GetHtml("`Hello world`"); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">`Hello world`</span>", result); }
public void NullThrowsException() { Assert.Throws <ArgumentNullException>(() => { Src2Html.GetHtml(null); }); }
public void KeywordHandledCorrectly() { Src2Html.Settings.Keywords = new[] { _TestText }; var result = Src2Html.GetHtml(_TestText); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.Keyword}\">{_TestText}</span>", result); }
public void Bug003() { var sourceText = @"Hello ""World"" 123 & Test <tag>"; var expectedResult = @"Hello "World" 123 & Test <tag>"; Src2Html.Settings = CreateSettings.ForPlainText; var result = Src2Html.GetHtml(sourceText); Assert.AreEqual(expectedResult, result); }
public void Separators() { var testText = "Lorem 123|456|789 Ipsum"; var result = Src2Html.GetHtml(testText); Assert.AreEqual($"Lorem <span class=\"{Src2Html.Settings.CssClasses.Number}\">123</span>|<span class=\"{Src2Html.Settings.CssClasses.Number}\">456</span>|<span class=\"{Src2Html.Settings.CssClasses.Number}\">789</span> Ipsum", result); Src2Html.Settings.NumberSeparators = new[] { '|' }; result = Src2Html.GetHtml(testText); Assert.AreEqual($"Lorem <span class=\"{Src2Html.Settings.CssClasses.Number}\">123|456|789</span> Ipsum", result); }
public void Bug001() { var sourceText = @"var example1=""Hello""; var example2=""World"";"; Src2Html.Settings = CreateSettings.ForJavaScript; var result = Src2Html.GetHtml(sourceText); Assert.AreEqual(@"<span class=""srcKeyword"">var</span> example1=<span class=""srcTextLiteral"">"Hello"</span>; <span class=""srcKeyword"">var</span> example2=<span class=""srcTextLiteral"">"World"</span>;", result); }
public void IdentifierHandledCorrectly() { Src2Html.Settings.Keywords = new string[0]; Src2Html.Settings.CssClasses.Identifier = "withCssClass"; var result = Src2Html.GetHtml(_TestText); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.Identifier}\">{_TestText}</span>", result); Src2Html.Settings.CssClasses.Identifier = String.Empty; // without CSS class result = Src2Html.GetHtml(_TestText); Assert.AreEqual(_TestText, result); }
public void PrefixAndSuffixHandledCorrectly() { Src2Html.Settings.CssClasses.Identifier = "withCssClass"; Src2Html.Settings.Keywords = new string[0]; var result = Src2Html.GetHtml($"@@@{_TestText}@@@"); Assert.AreEqual($"@@@<span class=\"{Src2Html.Settings.CssClasses.Identifier}\">{_TestText}</span>@@@", result); Src2Html.Settings.CssClasses.Identifier = String.Empty; // without CSS class Src2Html.Settings.Keywords = new string[0]; result = Src2Html.GetHtml($"@@@{_TestText}@@@"); Assert.AreEqual($"@@@{_TestText}@@@", result); }
public void Bug002() { var sourceText1 = @"{ ""fooA"" : { ""bar"" : [ ""valueA1"", ""valueA2"" ] }, ""fooB"" : { ""bar"" : ""valueB"" } }"; var sourceText2 = @"{ ""fooA"" : { ""bar"" : [ ""valueA1"", ""valueA2"" ] }, ""fooB"" : { ""bar"" : ""valueB"" } }"; Src2Html.Settings = CreateSettings.ForJson; var result1 = StripWhitespace(Src2Html.GetHtml(sourceText1)); var result2 = StripWhitespace(Src2Html.GetHtml(sourceText2)); Assert.AreEqual(result1, result2); }
public void CustomIdentifierCharacters() { Src2Html.Settings.CssClasses.Identifier = "withCssClass"; Src2Html.Settings.IdentifierSpecialChars = new[] { '_' }; var result = Src2Html.GetHtml("$_Hello$_World"); Assert.AreEqual($"$<span class=\"{Src2Html.Settings.CssClasses.Identifier}\">_Hello</span>$<span class=\"{Src2Html.Settings.CssClasses.Identifier}\">_World</span>", result); Src2Html.Settings.IdentifierSpecialChars = new[] { '_', '$' }; result = Src2Html.GetHtml("$_Hello$_World"); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.Identifier}\">$_Hello$_World</span>", result); Src2Html.Settings.CssClasses.Identifier = String.Empty; // without CSS class Src2Html.Settings.IdentifierSpecialChars = new[] { '_' }; result = Src2Html.GetHtml("$_Hello$_World"); Assert.AreEqual("$_Hello$_World", result); Src2Html.Settings.IdentifierSpecialChars = new[] { '_', '$' }; result = Src2Html.GetHtml("$_Hello$_World"); Assert.AreEqual("$_Hello$_World", result); }
public void BlockComment() { var result = Src2Html.GetHtml("/* Hello World */"); Assert.AreEqual("<span class=\"srcComment\">/* Hello World */</span>", result); }
public void SingleQuotes() { var result = Src2Html.GetHtml("'Hello \"quoted\" world'"); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">'Hello "quoted" world'</span>", result); }
public void PrefixAndSuffixHandledCorrectly() { var result = Src2Html.GetHtml("$$$'Hello \"quoted\" world'$$$"); Assert.AreEqual($"$$$<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">'Hello "quoted" world'</span>$$$", result); }
public void DoubleQuotes() { var result = Src2Html.GetHtml("\"Hello 'quoted' world\""); Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">"Hello 'quoted' world"</span>", result); }
public void PrefixAndSufficHandledCorrectlyForEndOfLineComment() { var result = Src2Html.GetHtml("@@@// Hello World" + Environment.NewLine + "@@@"); Assert.AreEqual("@@@<span class=\"srcComment\">// Hello World</span>" + Environment.NewLine + "@@@", result); }
public void PrefixHandledCorrectlyForBlockComment() { var result = Src2Html.GetHtml("@@@/* Hello" + Environment.NewLine + "World */@@@"); Assert.AreEqual("@@@<span class=\"srcComment\">/* Hello" + Environment.NewLine + "World */</span>@@@", result); }
public void OnlyDigits() { var result = Src2Html.GetHtml("Lorem 12345 Ipsum"); Assert.AreEqual($"Lorem <span class=\"{Src2Html.Settings.CssClasses.Number}\">12345</span> Ipsum", result); }
public void Mixed() { var result = Src2Html.GetHtml("Lorem 0x123.45) Ipsum"); Assert.AreEqual($"Lorem <span class=\"{Src2Html.Settings.CssClasses.Number}\">0x123.45</span>) Ipsum", result); }
public void EmptyStaysEmpty() { var result = Src2Html.GetHtml(String.Empty); Assert.AreEqual(String.Empty, result); }
public void Unchanged() { var result = Src2Html.GetHtml("Lorem Test123 Ipsum"); Assert.AreEqual($"Lorem Test123 Ipsum", result); }
public void EndOfLineComment() { var result = Src2Html.GetHtml("// Hello World"); Assert.AreEqual("<span class=\"srcComment\">// Hello World</span>", result); }