Exemplo n.º 1
0
 public DelimitedValuesFormatter(Char indentChar, String dateTimeFormatText, String logContext, String delimiter)
 {
     _default = new DefaultFormatter(indentChar, dateTimeFormatText);
     _delayedService = new DelayedFormatterService(dateTimeFormatText);
     this.LogContext = logContext;
     this.Delimiter = delimiter;
 }
Exemplo n.º 2
0
 public DelimitedValuesFormatter(Char indentChar, String dateTimeFormatText, String logContext, String delimiter)
 {
     _default        = new DefaultFormatter(indentChar, dateTimeFormatText);
     _delayedService = new DelayedFormatterService(dateTimeFormatText);
     this.LogContext = logContext;
     this.Delimiter  = delimiter;
 }
Exemplo n.º 3
0
        public void FormatMethodEntry_HideTimeStampInMethodIsSet_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = LogFiltersBuilder.Create().WithTimeStampInMethodHidden().Build();
            var formatter = new DefaultFormatter();
            var entry = new MethodEntry(1, "Yalf.TestMethod", new[] { "param1", "param2" }, DateTime.Parse("2022-10-22 22:22:31.678"));
            var expectedText = "[Enter] Yalf.TestMethod(param1, param2)";

            // Act
            var outputText = formatter.FormatMethodEntry(22, 1, 33, entry, filters, true);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 4
0
        public void FormatLogEvent_ValidLog_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = this.GetDefaultFilters();
            var formatter = new DefaultFormatter();
            var entry = new LogEvent(LogLevel.Info, DateTime.Parse("2022-10-22 22:22:31.678"), "This is a log entry");

            var expectedText = "[Log] [Info] This is a log entry";

            // Act
            var outputText = formatter.FormatLogEvent(22, 1, 33, entry, filters, true);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 5
0
        public void FormatException_ValidLog_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = this.GetDefaultFilters();
            var formatter = new DefaultFormatter();
            var ex = this.GenerateExceptionWithStackTrace();
            var entry = new ExceptionTrace(ex, DateTime.Parse("2022-10-22 22:22:31.678"));

            var expectedText = "[Exception] 22:22:31.678 Attempted to divide by zero.";

            // Act
            var outputText = formatter.FormatException(22, 1, 33, entry, filters);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 6
0
        public void FormatThread_ValidLogWithThreadName_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = this.GetDefaultFilters();
            var formatter = new DefaultFormatter();

            var entry1 = new MethodEntry(1, "Yalf.TestMethod", new[] { "param1", "param2" }, DateTime.Parse("2022-10-22 22:22:31.678"));
            var entry2 = new MethodExit(1, "Yalf.TestMethod", 345, true, "returnVal");
            var entry = new ThreadData(22, "YalfThread", new BaseEntry[] { entry1, entry2 });

            var expectedText = "[Thread 22 'YalfThread']";

            // Act
            var outputText = formatter.FormatThread(entry, filters);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 7
0
        public void FormatMethodExit_ValidLog_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = this.GetDefaultFilters();
            var formatter = new DefaultFormatter();
            var entry = new MethodExit(1, "Yalf.TestMethod", 345, true, "returnVal");
            var expectedText = "[Exit] Yalf.TestMethod(returnVal) duration 345ms";

            // Act
            var outputText = formatter.FormatMethodExit(22, 1, 33, entry, filters, true);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 8
0
        public void FormatMethodExit_HideMethodReturnValueIsSet_ExpectedTextIsReturned()
        {
            // Arrange
            var filters = LogFiltersBuilder.Create().WithMethodReturnValueHidden().Build();
            var formatter = new DefaultFormatter();
            var entry = new MethodExit(1, "Yalf.TestMethod", 345, true, "returnVal");
            var expectedText = "[Exit] Yalf.TestMethod() duration 345ms";

            // Act
            var outputText = formatter.FormatMethodExit(22, 1, 33, entry, filters, true);

            // Assert
            Assert.That(outputText, Is.Not.Empty, "Expected a string to be returned");
            Assert.That(outputText, Is.EqualTo(expectedText), "Not the expected output text, you may need to adjust the test if the formatter has been changed.");
        }
Exemplo n.º 9
0
 public SingleLineFormatter(Char indentChar, String dateTimeFormatText)
 {
     _default = new DefaultFormatter(indentChar, dateTimeFormatText);
     _delayedService = new DelayedFormatterService(dateTimeFormatText);
 }
Exemplo n.º 10
0
 public SingleLineFormatter(Char indentChar, String dateTimeFormatText)
 {
     _default        = new DefaultFormatter(indentChar, dateTimeFormatText);
     _delayedService = new DelayedFormatterService(dateTimeFormatText);
 }