IncreaseIndentation() public method

public IncreaseIndentation ( ) : void
return void
コード例 #1
0
        public void IncreasingIndentation_ByMustBeGreaterThanZero()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");

            Assert.Throws <ArgumentOutOfRangeException>(() => iw.IncreaseIndentation(0));
            Assert.Throws <ArgumentOutOfRangeException>(() => iw.IncreaseIndentation(-42));
        }
コード例 #2
0
        public void IncreasingIndentation_NeverOverflows()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");

            iw.IncreaseIndentation(Int32.MaxValue);
            iw.IncreaseIndentation(42);

            Assert.AreEqual(Int32.MaxValue, iw.Indentation);
        }
コード例 #3
0
        public void Write_WithIndentationTokenContainingNewLine_DoesNotRecurse()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "\r\n  ");
            iw.IncreaseIndentation(1);

            iw.Write("Hello\r\nWorld");

            String result = sw.GetStringBuilder().ToString();

            Assert.AreEqual("\r\n  Hello\r\n\r\n  World", result);
        }
コード例 #4
0
        public void Write_WithTwoLevelsOfIndentation()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");
            iw.IncreaseIndentation(2);

            iw.Write("Hello\r\nWorld");

            String result = sw.GetStringBuilder().ToString();

            Assert.AreEqual("    Hello\r\n    World", result);
        }
コード例 #5
0
        public void Write_WithIndentationTokenContainingNewLine_DoesNotRecurse()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "\r\n  ");

            iw.IncreaseIndentation(1);

            iw.Write("Hello\r\nWorld");

            String result = sw.GetStringBuilder().ToString();

            Assert.AreEqual("\r\n  Hello\r\n\r\n  World", result);
        }
コード例 #6
0
        public void Write_WithTwoLevelsOfIndentation()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");

            iw.IncreaseIndentation(2);

            iw.Write("Hello\r\nWorld");

            String result = sw.GetStringBuilder().ToString();

            Assert.AreEqual("    Hello\r\n    World", result);
        }
コード例 #7
0
        public void IncreasingIndentation_NeverOverflows()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");

            iw.IncreaseIndentation(Int32.MaxValue);
            iw.IncreaseIndentation(42);

            Assert.AreEqual(Int32.MaxValue, iw.Indentation);
        }
コード例 #8
0
        public void IncreasingIndentation_ByMustBeGreaterThanZero()
        {
            var sw = new StringWriter();
            var iw = new IndentingTextWriter(sw, "  ");

            Assert.Throws<ArgumentOutOfRangeException>(() => iw.IncreaseIndentation(0));
            Assert.Throws<ArgumentOutOfRangeException>(() => iw.IncreaseIndentation(-42));
        }