Exemple #1
0
        public void NothingToDoKeepsTextUnchanged()
        {
            var text   = "!,-@{}=?";
            var result = Src2Html.GetHtml(text);

            Assert.AreEqual(text, result);
        }
Exemple #2
0
        public void SafeHtml()
        {
            var text   = "<>&";
            var result = Src2Html.GetHtml(text);

            Assert.AreEqual("&lt;&gt;&amp;", result);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public void NullThrowsException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         Src2Html.GetHtml(null);
     });
 }
Exemple #5
0
        public void KeywordHandledCorrectly()
        {
            Src2Html.Settings.Keywords = new[] { _TestText };
            var result = Src2Html.GetHtml(_TestText);

            Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.Keyword}\">{_TestText}</span>", result);
        }
Exemple #6
0
        public void Bug003()
        {
            var sourceText     = @"Hello ""World"" 123 & Test <tag>";
            var expectedResult = @"Hello &quot;World&quot; 123 &amp; Test &lt;tag&gt;";

            Src2Html.Settings = CreateSettings.ForPlainText;
            var result = Src2Html.GetHtml(sourceText);

            Assert.AreEqual(expectedResult, result);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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"">&quot;Hello&quot;</span>;
<span class=""srcKeyword"">var</span> example2=<span class=""srcTextLiteral"">&quot;World&quot;</span>;", result);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        public void BlockComment()
        {
            var result = Src2Html.GetHtml("/* Hello World */");

            Assert.AreEqual("<span class=\"srcComment\">/* Hello World */</span>", result);
        }
Exemple #14
0
        public void SingleQuotes()
        {
            var result = Src2Html.GetHtml("'Hello \"quoted\" world'");

            Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">&#39;Hello &quot;quoted&quot; world&#39;</span>", result);
        }
Exemple #15
0
        public void PrefixAndSuffixHandledCorrectly()
        {
            var result = Src2Html.GetHtml("$$$'Hello \"quoted\" world'$$$");

            Assert.AreEqual($"$$$<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">&#39;Hello &quot;quoted&quot; world&#39;</span>$$$", result);
        }
Exemple #16
0
        public void DoubleQuotes()
        {
            var result = Src2Html.GetHtml("\"Hello 'quoted' world\"");

            Assert.AreEqual($"<span class=\"{Src2Html.Settings.CssClasses.TextLiteral}\">&quot;Hello &#39;quoted&#39; world&quot;</span>", result);
        }
Exemple #17
0
        public void PrefixAndSufficHandledCorrectlyForEndOfLineComment()
        {
            var result = Src2Html.GetHtml("@@@// Hello World" + Environment.NewLine + "@@@");

            Assert.AreEqual("@@@<span class=\"srcComment\">// Hello World</span>" + Environment.NewLine + "@@@", result);
        }
Exemple #18
0
        public void PrefixHandledCorrectlyForBlockComment()
        {
            var result = Src2Html.GetHtml("@@@/* Hello" + Environment.NewLine + "World */@@@");

            Assert.AreEqual("@@@<span class=\"srcComment\">/* Hello" + Environment.NewLine + "World */</span>@@@", result);
        }
Exemple #19
0
        public void OnlyDigits()
        {
            var result = Src2Html.GetHtml("Lorem 12345 Ipsum");

            Assert.AreEqual($"Lorem <span class=\"{Src2Html.Settings.CssClasses.Number}\">12345</span> Ipsum", result);
        }
Exemple #20
0
        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);
        }
Exemple #21
0
        public void EmptyStaysEmpty()
        {
            var result = Src2Html.GetHtml(String.Empty);

            Assert.AreEqual(String.Empty, result);
        }
Exemple #22
0
        public void Unchanged()
        {
            var result = Src2Html.GetHtml("Lorem Test123 Ipsum");

            Assert.AreEqual($"Lorem Test123 Ipsum", result);
        }
Exemple #23
0
        public void EndOfLineComment()
        {
            var result = Src2Html.GetHtml("// Hello World");

            Assert.AreEqual("<span class=\"srcComment\">// Hello World</span>", result);
        }