public void ExceptionTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            ExceptionTestExtensions.M0(logger, new ArgumentException("Foo"), new ArgumentException("Bar"));
            Assert.Equal("Foo", logger.LastException !.Message);
            Assert.Equal("M0 System.ArgumentException: Bar", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ExceptionTestExtensions.M1(new ArgumentException("Foo"), logger, new ArgumentException("Bar"));
            Assert.Equal("Foo", logger.LastException !.Message);
            Assert.Equal("M1 System.ArgumentException: Bar", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }
        public void EnableTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            logger.Enabled = false;
            NoNamespace.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(0, logger.CallCount);          // ensure the logger doesn't get called when it is disabled
        }
        public void MessageTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            MessageTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #4
0
        public void FindsLoggerFieldInAnotherParialClass()
        {
            var logger = new MockLogger();

            logger.Reset();

            new PartialClassWithLoggerField(logger).Test();
            Assert.Equal("Test.", logger.LastFormattedString);
        }
Exemple #5
0
        public void FindsLoggerFieldInBaseClass()
        {
            var logger = new MockLogger();

            logger.Reset();

            new DerivedClass(logger).Test();
            Assert.Equal("Test.", logger.LastFormattedString);
        }
        public void ExtensionMethodTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            LoggerExtensions.CouldNotOpenSocket(logger, "microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LoggerExtensionsNoNamespace.CouldNotOpenSocketNoNamespace(logger, "microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #7
0
        public void InstanceTests()
        {
            var logger = new MockLogger();
            var o      = new TestInstances(logger);

            logger.Reset();
            o.M0();
            Assert.Null(logger.LastException);
            Assert.Equal("M0", logger.LastFormattedString);
            Assert.Equal(LogLevel.Error, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            o.M1("Foo");
            Assert.Null(logger.LastException);
            Assert.Equal("M1 Foo", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #8
0
        public void TemplateTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            TemplateTestExtensions.M0(logger, 0);
            Assert.Null(logger.LastException);
            Assert.Equal("M0 0", logger.LastFormattedString);
            AssertLastState(logger,
                            new KeyValuePair <string, object?>("A1", 0),
                            new KeyValuePair <string, object?>("{OriginalFormat}", "M0 {A1}"));

            logger.Reset();
            TemplateTestExtensions.M1(logger, 42);
            Assert.Null(logger.LastException);
            Assert.Equal("M1 42 42", logger.LastFormattedString);
            AssertLastState(logger,
                            new KeyValuePair <string, object?>("A1", 42),
                            new KeyValuePair <string, object?>("{OriginalFormat}", "M1 {A1} {A1}"));

            logger.Reset();
            TemplateTestExtensions.M2(logger, 42, 43, 44, 45, 46, 47, 48);
            Assert.Null(logger.LastException);
            Assert.Equal("M2 42 43 44 45 46 47 48", logger.LastFormattedString);
            AssertLastState(logger,
                            new KeyValuePair <string, object?>("A1", 42),
                            new KeyValuePair <string, object?>("a2", 43),
                            new KeyValuePair <string, object?>("A3", 44),
                            new KeyValuePair <string, object?>("a4", 45),
                            new KeyValuePair <string, object?>("A5", 46),
                            new KeyValuePair <string, object?>("a6", 47),
                            new KeyValuePair <string, object?>("A7", 48),
                            new KeyValuePair <string, object?>("{OriginalFormat}", "M2 {A1} {a2} {A3} {a4} {A5} {a6} {A7}"));

            logger.Reset();
            TemplateTestExtensions.M3(logger, 42, 43);
            Assert.Null(logger.LastException);
            Assert.Equal("M3 43 42", logger.LastFormattedString);
            AssertLastState(logger,
                            new KeyValuePair <string, object?>("A1", 42),
                            new KeyValuePair <string, object?>("a2", 43),
                            new KeyValuePair <string, object?>("{OriginalFormat}", "M3 {a2} {A1}"));
        }
Exemple #9
0
        public void MessageTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            MessageTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M5(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(-1, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M6(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal(string.Empty, logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(6, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MessageTestExtensions.M7(logger, LogLevel.Trace, "p", "q");
            Assert.Null(logger.LastException);
            Assert.Equal("\"p\" -> \"q\"", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(7, logger.LastEventId.Id);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #10
0
        public void EventNameTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            EventNameTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M0", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
            Assert.Equal("CustomEventName", logger.LastEventId.Name);

            logger.Reset();
            EventNameTestExtensions.CustomEventName(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("CustomEventName", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
            Assert.Equal("CustomEventName", logger.LastEventId.Name);
        }
Exemple #11
0
        public void NestedClassTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            NestedClassTestsExtensions <ABC> .NestedMiddleParentClass.NestedClass.M8(logger);

            Assert.Null(logger.LastException);
            Assert.Equal("M8", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            NonStaticNestedClassTestsExtensions <ABC> .NonStaticNestedMiddleParentClass.NestedClass.M9(logger);

            Assert.Null(logger.LastException);
            Assert.Equal("M9", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            NestedStruct.Logger.M10(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M10", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            NestedRecord.Logger.M11(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M11", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            MultiLevelNestedClass.NestedStruct.NestedRecord.Logger.M12(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M12", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #12
0
        public void WrapperTypeTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            var d = global::Microsoft.Extensions.Logging.Generators.Tests.LoggerExtensions.Wrap(logger);    // make sure this is using the right namespace

            d.CouldNotOpenSocket("microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            var d2 = global::LoggerExtensionsNoNamespace.Wrap(logger);      // make sure this is outside of any namespace

            d2.CouldNotOpenSocketNoNamespace("microsoft.com");
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Null(logger.LastException);
            Assert.Equal("Could not open socket to `microsoft.com`", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #13
0
        public void SkipEnabledCheckTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            logger.Enabled = false;
            Assert.False(logger.IsEnabled(LogLevel.Information));
            SkipEnabledCheckExtensions.LoggerMethodWithFalseSkipEnabledCheck(logger);
            Assert.Null(logger.LastException);
            Assert.Null(logger.LastFormattedString);
            Assert.Equal((LogLevel)(-1), logger.LastLogLevel);
            Assert.Equal(0, logger.CallCount);
            Assert.Equal(default, logger.LastEventId);
Exemple #14
0
        public void EnableTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            logger.Enabled = false;
            var d = LoggerExtensions.Wrap(logger);

            d.CouldNotOpenSocket("microsoft.com");
            Assert.Equal(0, logger.CallCount);          // ensure the logger doesn't get called when it is disabled

            logger.CouldNotOpenSocket("microsoft.com");
            Assert.Equal(0, logger.CallCount);          // ensure the logger doesn't get called when it is disabled
        }
Exemple #15
0
        public void ReadOnlyListTest()
        {
            var logger = new MockLogger();
            var d      = ArgTestExtensions.Wrap(logger);

            logger.Reset();
            d.Method1();
            var rol = logger.LastState as IReadOnlyList <KeyValuePair <string, object> >;

            Assert.Equal(0, rol !.Count);
            Assert.Empty(rol);
            Assert.Throws <ArgumentOutOfRangeException>(() => _ = rol[0]);

            logger.Reset();
            d.Method2("arg1");
            rol = logger.LastState as IReadOnlyList <KeyValuePair <string, object> >;
            Assert.Equal(1, rol !.Count);
#pragma warning disable CA1829 // Use Length/Count property instead of Count() when available
            Assert.Equal(1, rol.LongCount());
#pragma warning restore CA1829 // Use Length/Count property instead of Count() when available
            Assert.Equal("p1", (string)rol[0].Key);
            Assert.Equal("arg1", (string)rol[0].Value);
            Assert.Throws <ArgumentOutOfRangeException>(() => _ = rol[1]);

            logger.Reset();
            d.Method3("arg1", 2);
            rol = logger.LastState as IReadOnlyList <KeyValuePair <string, object> >;
            Assert.Equal(2, rol !.Count);
#pragma warning disable CA1829 // Use Length/Count property instead of Count() when available
            Assert.Equal(2, rol.LongCount());
#pragma warning restore CA1829 // Use Length/Count property instead of Count() when available
            Assert.Equal("p1", (string)rol[0].Key);
            Assert.Equal("arg1", (string)rol[0].Value);
            Assert.Equal("p2", (string)rol[1].Key);
            Assert.Equal(2, (int)rol[1].Value);
            Assert.Throws <ArgumentOutOfRangeException>(() => _ = rol[2]);
        }
        public void ArgTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            ArgTestExtensions.Method1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method2(logger, "arg1");
            Assert.Null(logger.LastException);
            Assert.Equal("M2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method3(logger, "arg1", 2);
            Assert.Null(logger.LastException);
            Assert.Equal("M3 arg1 2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method4(logger, new InvalidOperationException("A"));
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M4", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method5(logger, new InvalidOperationException("A"), new InvalidOperationException("B"));
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M5", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method6(logger, new InvalidOperationException("A"), 2);
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M6", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method7(logger, 1, new InvalidOperationException("B"));
            Assert.Equal("B", logger.LastException !.Message);
            Assert.Equal("M7", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #17
0
        public void ReadOnlyListTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            ReadOnlyListExtensions.M0(logger);
            TestCollection(0, logger);

            logger.Reset();
            ReadOnlyListExtensions.M1(logger, 0);
            TestCollection(1, logger);

            logger.Reset();
            ReadOnlyListExtensions.M2(logger, 0, 1);
            TestCollection(2, logger);

            logger.Reset();
            ReadOnlyListExtensions.M3(logger, 0, 1, 2);
            TestCollection(3, logger);

            logger.Reset();
            ReadOnlyListExtensions.M4(logger, 0, 1, 2, 3);
            TestCollection(4, logger);

            logger.Reset();
            ReadOnlyListExtensions.M5(logger, 0, 1, 2, 3, 4);
            TestCollection(5, logger);

            logger.Reset();
            ReadOnlyListExtensions.M6(logger, 0, 1, 2, 3, 4, 5);
            TestCollection(6, logger);

            logger.Reset();
            ReadOnlyListExtensions.M7(logger, 0, 1, 2, 3, 4, 5, 6);
            TestCollection(7, logger);
        }
Exemple #18
0
        public void ArgTest()
        {
            var logger = new MockLogger();

            logger.Reset();
            ArgTestExtensions.Method1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method2(logger, "arg1");
            Assert.Null(logger.LastException);
            Assert.Equal("M2 arg1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method3(logger, "arg1", 2);
            Assert.Null(logger.LastException);
            Assert.Equal("M3 arg1 2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method4(logger, new InvalidOperationException("A"));
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M4", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method5(logger, new InvalidOperationException("A"), new InvalidOperationException("B"));
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M5 System.InvalidOperationException: B", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method6(logger, new InvalidOperationException("A"), 2);
            Assert.Equal("A", logger.LastException !.Message);
            Assert.Equal("M6 2", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method7(logger, 1, new InvalidOperationException("B"));
            Assert.Equal("B", logger.LastException !.Message);
            Assert.Equal("M7 1", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method8(logger, 1, 2, 3, 4, 5, 6, 7);
            Assert.Equal("M81234567", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method9(logger, 1, 2, 3, 4, 5, 6, 7);
            Assert.Equal("M9 1 2 3 4 5 6 7", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            ArgTestExtensions.Method10(logger, 1);
            Assert.Equal("M101", logger.LastFormattedString);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #19
0
        public void LevelTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            LevelTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M0", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M1", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M2(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M2", logger.LastFormattedString);
            Assert.Equal(LogLevel.Information, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M3(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M3", logger.LastFormattedString);
            Assert.Equal(LogLevel.Warning, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M4(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M4", logger.LastFormattedString);
            Assert.Equal(LogLevel.Error, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M5(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M5", logger.LastFormattedString);
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M6(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M6", logger.LastFormattedString);
            Assert.Equal(LogLevel.None, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M7(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M7", logger.LastFormattedString);
            Assert.Equal((LogLevel)42, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M8(logger, LogLevel.Critical);
            Assert.Null(logger.LastException);
            Assert.Equal("M8", logger.LastFormattedString);
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M9(LogLevel.Trace, logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M9", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M10vs11(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("event ID 10 vs. 11", logger.LastFormattedString);
            Assert.Equal(LogLevel.Warning, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
            Assert.Equal(11, logger.LastEventId.Id);

            logger.Reset();
            LevelTestExtensions.M12(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal("M12 Trace", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M13(logger, LogLevel.Trace);
            Assert.Null(logger.LastException);
            Assert.Equal("M13 Microsoft.Extensions.Logging.Generators.Tests.MockLogger", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }
Exemple #20
0
        public void LevelTests()
        {
            var logger = new MockLogger();

            logger.Reset();
            LevelTestExtensions.M0(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M0", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M1(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M1", logger.LastFormattedString);
            Assert.Equal(LogLevel.Debug, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M2(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M2", logger.LastFormattedString);
            Assert.Equal(LogLevel.Information, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M3(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M3", logger.LastFormattedString);
            Assert.Equal(LogLevel.Warning, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M4(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M4", logger.LastFormattedString);
            Assert.Equal(LogLevel.Error, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M5(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M5", logger.LastFormattedString);
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M6(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M6", logger.LastFormattedString);
            Assert.Equal(LogLevel.None, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M7(logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M7", logger.LastFormattedString);
            Assert.Equal((LogLevel)42, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M8(logger, LogLevel.Critical);
            Assert.Null(logger.LastException);
            Assert.Equal("M8", logger.LastFormattedString);
            Assert.Equal(LogLevel.Critical, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);

            logger.Reset();
            LevelTestExtensions.M9(LogLevel.Trace, logger);
            Assert.Null(logger.LastException);
            Assert.Equal("M9", logger.LastFormattedString);
            Assert.Equal(LogLevel.Trace, logger.LastLogLevel);
            Assert.Equal(1, logger.CallCount);
        }