コード例 #1
0
        public void SetUp()
        {
            _renderer = new DefaultCodeRenderer();

            ICodeFormatter formatter = new PlainTextCodeFormatter();

            _empty = formatter.Format("");

            _text3x7 = formatter.Format(
                    "111\r\n" +
                    "222\r\n" +
                    "333\r\n" +
                    "444\r\n" +
                    "555\r\n" +
                    "666\r\n" +
                    "777\r\n");

            _loremIpsum = formatter.Format(
                "Lorem ipsum dolor sit\r\n" +
                "amet, consectetur adipiscing elit.\r\n" +
                "Maecenas a nisi. In imperdiet, orci in\r\n" +
                "porta facilisis,\r\n" +
                "odio purus iaculis est, non varius urna turpis in mi.\r\n" + // longest line
                "Nullam dictum. Ut iaculis dignissim nulla.\r\n" +
                "Nullam condimentum porttitor leo.\r\n" +
                "Integer a odio et\r\n" +
                "velit suscipit pulvinar.");

            Image img = new Bitmap(100, 100);
            _args = new CodeRenderingContext();
            _args.Graphics = Graphics.FromImage(img);
            _args.Font = new Font("Courier New", 12);

            return;
        }
コード例 #2
0
        FormattedCode Format(string text, string language)
        {
            ICodeFormatter formatter;

            if (language == "C#")
                formatter = new CSharpCodeFormatter();
            else
                formatter = new PlainTextCodeFormatter();

            return (formatter.Format(text));
        }
コード例 #3
0
        public void SetUp()
        {
            _formatter = new PlainTextCodeFormatter();

            return;
        }
コード例 #4
0
        public void Format_Pick_Best_Formatter()
        {
            ErrorItem itemHelloTxt;
            ErrorItem itemBasicCs;
            ICodeFormatter txtFormatter;
            ICodeFormatter csFormatter;
            FormattedCode exp;

            using (new TestResource("HelloWorld.txt"))
            {
                itemHelloTxt = new ErrorItem("HelloWorld.txt", 1);
                txtFormatter = new PlainTextCodeFormatter();
                exp = txtFormatter.Format(itemHelloTxt.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemHelloTxt.ReadFile(), itemHelloTxt.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            using (new TestResource("Basic.cs"))
            {
                itemBasicCs = new ErrorItem("Basic.cs", 1);
                csFormatter = new CSharpCodeFormatter();
                exp = csFormatter.Format(itemBasicCs.ReadFile());
                Assert.That(
                    _formatter.FormatFromExtension(itemBasicCs.ReadFile(), itemBasicCs.FileExtension),
                    Is.EqualTo(exp));
                FormattedCode.CheckData(exp);
            }

            return;
        }