Пример #1
0
        public void SHCsharpAreTokensWellConverted_TokensAreCorrect_ReturnsTrue(string inputData, TokenType[] expectedTokens)
        {
            //arange
            ISHTokenizer tokenizer   = new CSharpSHTokenizer();
            ISHFilter    tokenFilter = new CSharpTokenFilter(tokenizer.GetTokenRecognizer());

            //act
            tokenizer.SetInput(new StringReader(inputData));
            tokenFilter.SetSource(tokenizer);
            var tokenTypes = tokenFilter.GetTokenTypesFromCurrentTokens();

            //assert
            CollectionAssert.AreEqual(expectedTokens, tokenTypes);
        }
Пример #2
0
        static void Main(string[] args)
        {
            //https://www.freeformatter.com/java-dotnet-escape.html#ad-output
            string       testData  = "            formater.Run(); \r\n            \r\n        }\r\n    }\r\n}\r\n";
            ISHTokenizer tokenizer = new CSharpSHTokenizer();

            tokenizer.SetInput(new StringReader(testData));

            ISHFilter tokenFilter = new CSharpTokenFilter(tokenizer.GetTokenRecognizer());

            tokenFilter.SetSource(tokenizer);
            var revisedTokens = tokenFilter.ReviseTokens();

            ISHFormater formater = new HtmlSHFormatter(); // vytvoříme formátor

            formater.SetSource(revisedTokens);
            //formater.SetOutput(Console.Out);
            formater.SetOutput(new StreamWriter("formated.txt"));
            formater.Run();
        }