public void BeginBatch_NullAsLogger_ThrowsArgumentNull() { Assert.Throws <ArgumentNullException>("logger", () => { ProjectLoggerExtensions.BeginBatch((IProjectLogger)null); }); }
public void BeginBatch_SetIndentLevelToLessThanZero_ThrowsArgumentOutOfRange(int indentLevel) { var logger = new ProjectLogger(); var batch = ProjectLoggerExtensions.BeginBatch(logger); Assert.Throws <ArgumentOutOfRangeException>("value", () => { batch.IndentLevel = indentLevel; }); }
public void BeginBatch_IsEnabled_ReturnsLoggerIsEnabled(bool isEnabled) { var logger = new ProjectLogger() { IsEnabled = isEnabled }; var batch = ProjectLoggerExtensions.BeginBatch(logger); Assert.Equal(batch.IsEnabled, logger.IsEnabled); }
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); }
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); }
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); }
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); }