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); }
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); }