public void InformationWithExceptionMustLogInformationWhenCalled() { MockLogger logger = new MockLogger(); Exception exception = new Exception("Test"); logger.Information <LoggingExtensionsTests>(exception, "42"); Assert.True(logger.Storage.Count == 1); Assert.Contains("System.Exception: Test", logger.Storage[0]); }
public void InformationMustLogInformationWhenCalled() { MockLogger logger = new MockLogger(); logger.Information <LoggingExtensionsTests>("42"); Assert.True(logger.Storage.Count == 1); Assert.Contains(logger.Storage, x => x.StartsWith($"Information: 42 ({{\"activityId\":\"\",\"applicationName\":\"{new RuntimeContext().ApplicationName}\",\"environmentName\":\"\",\"loggerName\":\"{typeof(LoggingExtensionsTests).FullName}\",\"logLevel\":2,\"memberName\":\"{nameof(InformationMustLogInformationWhenCalled)}\",\"message\":\"42\",\"organizationId\":\"\"")); Assert.Contains("threadName", logger.Storage[0]); Assert.Contains("timestamp", logger.Storage[0]); Assert.Contains("userId", logger.Storage[0]); }