コード例 #1
0
        public void RenderableColumnValuesAreNotConvertedToText()
        {
            var sizer = new ColumnSizer(typeof(string));
            sizer.ColumnValue("XXXX XXXX");

            //add a renderable value
            var renderable = new RecordingConsoleAdapter();
            renderable.FormatTable(Enumerable.Range(0, 3).Select(i => new {String = "blah blah blah blah", Number = i}));
            sizer.ColumnValue(renderable);

            Assert.That(sizer.GetSizeValue(1).RenderableValue, Is.Not.Null);
        }
コード例 #2
0
        public void MaxLineBreaksIsCalculated()
        {
            var columnFormat = new ColumnFormat("", typeof(string));
            var sizer = new ColumnSizer(typeof(string), columnFormat);
            sizer.ColumnValue("XXXX XXXX XXXX XX XXX");
            sizer.ColumnValue("YYYYYY YYYYY YY YYY YY YYYY YY Y");

            var sb = new StringBuilder();
            sb.AppendLine("Test values:");
            sb.AppendLine(sizer.GetSizeValue(0).TextValue);
            sb.AppendLine(sizer.GetSizeValue(1).TextValue);

            sb.AppendLine("Max Linebreaks:");
            for (var width = 15; width > 0; --width)
            {
                Console.WriteLine(width);
                sb.AppendLine();
                sb.AppendFormat("Width = {0}, line breaks = {1}", width, sizer.GetMaxLineBreaks(width));
                sb.AppendLine();
                sb.AppendLine(RulerFormatter.MakeRuler(width));
                foreach (var line in ColumnWrapper.WrapValue(sizer.GetSizeValue(1), columnFormat, width))
                {
                    sb.AppendLine(line);
                }
            }

            Console.WriteLine(sb.ToString());
            Approvals.Verify(sb.ToString());
        }