public void TestMessageLogWithoutParams() { var requestMocker = new HttpRequestTests(); var mockRequest = requestMocker.CreateMockRequest(); var logBeginsWith = $@"{{""level"":{(int) LogLevels.Warn},""time"":"; var logEndsWith = $@",""msg"":""message"",""reqId"":""{ReqId}""}}"; Logger.Warn(mockRequest.Object, "message"); _mockILog.Verify(mock => mock.Warn(It.Is <string>(str => str.StartsWith(logBeginsWith) && str.EndsWith(logEndsWith))), Times.Once); }
public void TestDebugLog() { var requestMocker = new HttpRequestTests(); var mockRequest = requestMocker.CreateMockRequest(); var logBeginsWith = $@"{{""level"":{(int) LogLevels.Debug},""time"":"; var logEndsWith = $@",""msg"":""message"",""reqId"":""{ReqId}"",""customPropA"":""foo"",""customPropB"":""bar""}}"; Logger.Debug(mockRequest.Object, "message", new CustomProps("foo", "bar")); _mockILog.Verify(mock => mock.Debug(It.Is <string>(str => str.StartsWith(logBeginsWith) && str.EndsWith(logEndsWith))), Times.Once); }
public void TestDebugLogWithRequestIdInDictionary() { var requestMocker = new HttpRequestTests(); var dictionary = new Dictionary <object, object> { { RequestResponseLoggingMiddleware.RequestIdDictionaryKey, "42" } }; var mockRequest = requestMocker.CreateMockRequest(dictionary); var logBeginsWith = $@"{{""level"":{(int) LogLevels.Debug},""time"":"; var logEndsWith = $@",""msg"":""message"",""reqId"":""42"",""customPropA"":""foo"",""customPropB"":""bar""}}"; Logger.Debug(mockRequest.Object, "message", new CustomProps("foo", "bar")); _mockILog.Verify(mock => mock.Debug(It.Is <string>(str => str.StartsWith(logBeginsWith) && str.EndsWith(logEndsWith))), Times.Once); }