Exemplo n.º 1
0
        public void BeginBatch_SetIndentLevelToLessThanZero_ThrowsArgumentOutOfRange(int indentLevel)
        {
            var logger = new MockOutputService();
            var batch  = new BatchLogger(logger);

            Assert.Throws <ArgumentOutOfRangeException>("value", () =>
            {
                batch.IndentLevel = indentLevel;
            });
        }
Exemplo n.º 2
0
        public void BeginBatch_IsEnabled_ReturnsLoggerIsEnabled(bool isEnabled)
        {
            var logger = new MockOutputService()
            {
                IsEnabled = isEnabled
            };

            var batch = new BatchLogger(logger);

            Assert.Equal(batch.IsEnabled, logger.IsEnabled);
        }
Exemplo n.º 3
0
        public void BeginBatch_IndentLevel_AppendsIndentToWriteLine(int indentLevel, string expected)
        {
            var logger = new MockOutputService();

            using (var batch = new BatchLogger(logger))
            {
                batch.IndentLevel = indentLevel;
                batch.WriteLine(string.Empty);
            }

            Assert.Equal(expected, logger.Text);
        }
Exemplo n.º 4
0
        public void BeginBatch_WhenUnderlyingLoggerIsEnabled_Logs()
        {
            var logger = new MockOutputService()
            {
                IsEnabled = true
            };

            using (var batch = new BatchLogger(logger))
            {
                batch.WriteLine("Hello World!");
            }

            Assert.Equal("Hello World!", logger.Text);
        }
Exemplo n.º 5
0
        public void BeginBatch_WhenUnderlyingLoggerIsNotEnabled_DoesNotLog()
        {
            var logger = new MockOutputService()
            {
                IsEnabled = false
            };

            using (var batch = new BatchLogger(logger))
            {
                batch.WriteLine("Hello World!");
            }

            Assert.Null(logger.Text);
        }
Exemplo n.º 6
0
        public void BeginBatch_CanLogMultipleWriteLines()
        {
            var logger = new MockOutputService()
            {
                IsEnabled = true
            };

            using (var batch = new BatchLogger(logger))
            {
                batch.WriteLine("Line1");
                batch.IndentLevel = 1;
                batch.WriteLine("Line2");
                batch.IndentLevel = 0;
                batch.WriteLine("Line3");
            }

            // NOTE: No trailing new line, as the logger itself should be adding it
            Assert.Equal("Line1\r\n    Line2\r\nLine3", logger.Text, ignoreLineEndingDifferences: true);
        }