Ejemplo n.º 1
0
 public void BeginBatch_NullAsLogger_ThrowsArgumentNull()
 {
     Assert.Throws <ArgumentNullException>("logger", () =>
     {
         ProjectLoggerExtensions.BeginBatch((IProjectLogger)null);
     });
 }
Ejemplo n.º 2
0
        public void BeginBatch_SetIndentLevelToLessThanZero_ThrowsArgumentOutOfRange(int indentLevel)
        {
            var logger = new ProjectLogger();
            var batch  = ProjectLoggerExtensions.BeginBatch(logger);

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

            var batch = ProjectLoggerExtensions.BeginBatch(logger);

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

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

            Assert.Equal(expected, logger.Text);
        }
Ejemplo n.º 5
0
        public void BeginBatch_WhenUnderlyingLoggerIsEnabled_Logs()
        {
            var logger = new ProjectLogger()
            {
                IsEnabled = true
            };

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

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

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

            Assert.Null(logger.Text);
        }
Ejemplo n.º 7
0
        public void BeginBatch_CanLogMultipleWriteLines()
        {
            var logger = new ProjectLogger()
            {
                IsEnabled = true
            };

            using (var batch = ProjectLoggerExtensions.BeginBatch(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);
        }