Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnSameLoggerForSameContext()
        internal virtual void ShouldReturnSameLoggerForSameContext()
        {
            // Given
            FormattedLogProvider logProvider = FormattedLogProvider.ToOutputStream(new MemoryStream());

            // Then
            FormattedLog log = logProvider.GetLog("test context");

            assertThat(logProvider.GetLog("test context"), sameInstance(log));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnSameLoggerForSameClass()
        internal virtual void ShouldReturnSameLoggerForSameClass()
        {
            // Given
            FormattedLogProvider logProvider = FormattedLogProvider.ToOutputStream(new MemoryStream());

            // Then
            FormattedLog log = logProvider.getLog(this.GetType());

            assertThat(logProvider.GetLog(typeof(FormattedLogProviderTest)), sameInstance(log));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldLogWithAbbreviatedClassNameAsContext()
        internal virtual void ShouldLogWithAbbreviatedClassNameAsContext()
        {
            // Given
            StringWriter         writer      = new StringWriter();
            FormattedLogProvider logProvider = NewFormattedLogProvider(writer);
            FormattedLog         log         = logProvider.GetLog(typeof(StringWriter));

            // When
            log.Info("Terminator 2");

            // Then
            assertThat(writer.ToString(), endsWith(format("INFO [j.i.StringWriter] Terminator 2%n")));
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSetLevelForLogWithMatchingContext()
        internal virtual void ShouldSetLevelForLogWithMatchingContext()
        {
            // Given
            StringWriter         writer      = new StringWriter();
            FormattedLogProvider logProvider = NewFormattedLogProvider(writer, "java.io.StringWriter", Level.Debug);

            // When
            FormattedLog stringWriterLog     = logProvider.GetLog(typeof(StringWriter));
            FormattedLog otherClassLog       = logProvider.GetLog(typeof(PrintWriter));
            FormattedLog matchingNamedLog    = logProvider.GetLog("java.io.StringWriter");
            FormattedLog nonMatchingNamedLog = logProvider.GetLog("java.io.Foo");

            // Then
            assertThat(stringWriterLog.DebugEnabled, @is(true));
            assertThat(otherClassLog.DebugEnabled, @is(false));
            assertThat(matchingNamedLog.DebugEnabled, @is(true));
            assertThat(nonMatchingNamedLog.DebugEnabled, @is(false));
        }