public void DecimalDataDoesNotAllowLineBreaks()
        {
            var sizer = new ColumnSizer(typeof(decimal));
            sizer.ColumnValue("N");
            for (decimal n = 0; n <= 100; ++n)
                sizer.ColumnValue(n.ToString());

            Assert.That(sizer.MinWidth(10), Is.EqualTo(3));
        }
        public void FixedColumnMinWidthIsAlwaysFixed()
        {
            var sizer = new ColumnSizer(typeof(string), new ColumnFormat(type: typeof(string))  { FixedWidth = 4});
            sizer.ColumnValue("XXXX XXXX");
            sizer.ColumnValue("YYYYYY XXXXX");

            var width = sizer.MinWidth(0);
            Assert.That(width, Is.EqualTo(4));
        }
        public void DateTimeDataDoesNotAllowLineBreaks()
        {
            var sizer = new ColumnSizer(typeof(double));
            sizer.ColumnValue("Date");
            for (var n = 0; n <= 100; ++n)
                sizer.ColumnValue((DateTime.Parse("2014-04-28") + new TimeSpan(n, 0, 0, 0)).ToString("yyyy-MM-dd"));

            Assert.That(sizer.MinWidth(10), Is.EqualTo(10));
        }
        public void FittingToLineBreaksStopsIfTheMaximumPossibleNumberOfLineBreaksIsReached()
        {
            var sizer = new ColumnSizer(typeof(string));
            sizer.ColumnValue("X");
            //                        ----+----|----+----|----+----|---\----+----|----+----|----+----|---\----+----|----+----|----+----|
            const string testValue = "A few words.";
            sizer.ColumnValue(testValue);

            var minWidth = sizer.MinWidth(200);
            Assert.That(minWidth, Is.EqualTo(1));
        }
        public void ZeroLineBreaksReturnsWidestLength()
        {
            var sizer = new ColumnSizer(typeof(int));
            sizer.ColumnValue("N");
            for (var n = 0; n <= 100; ++n)
                sizer.ColumnValue(n.ToString());

            Assert.That(sizer.MinWidth(0), Is.EqualTo(3));
        }
        public void StringValuesAllowLineBreaks()
        {
            var sizer = new ColumnSizer(typeof(string));
            sizer.ColumnValue("X");
            //                        ----+----|----+----|----+----|---\----+----|----+----|----+----|---\----+----|----+----|----+----|
            const string testValue = "Several words so that line breaks can be added to fit a small column to a number of lines.";
            sizer.ColumnValue(testValue);

            var minWidth = sizer.MinWidth(2);

            var formatted = ColumnWrapper.WrapValue(testValue, new ColumnFormat("X", typeof (string)), minWidth);
            Console.WriteLine(RulerFormatter.MakeRuler(minWidth));
            Console.WriteLine(string.Join(Environment.NewLine, formatted));

            Assert.That(minWidth, Is.EqualTo(33));
        }
        public void MinWidthColumnMinWidthIsAlwaysMinimum()
        {
            var sizer = new ColumnSizer(typeof(string), new ColumnFormat(type: typeof(string)) { MinWidth = 6 });
            sizer.ColumnValue("XXXX XXXX");
            sizer.ColumnValue("YYYYYY XXXXX");

            var width = sizer.MinWidth(0);
            Assert.That(width, Is.EqualTo(6));
        }