public void Test_ExceptionInfo_Addition() { // 测试普通情况 using (WebContext context = CreateWebContext()) { context.SetUserName("Fish Li"); context.AddSession("session-1", "aaaaaaaaaaaa"); context.AddSession("session-2", DateTime.Now); context.AddSession("session-3", null); context.Request.SetInputStream("a=1&b=2"); Exception ex = LogHelperTest.CreateException("Test: HttpInfo.Create"); ExceptionInfo info = ExceptionInfo.Create(ex, context.HttpContext, null); info.Addition = Guid.NewGuid().ToString(); LogHelper.SyncWrite(info); LogHelperTest.AssertWriteOK(info.Addition); } }
public void Test_LogHelper_Write_DbCommand() { using (WebContext context = HttpInfoTest.CreateWebContext()) { context.SetUserName("Fish Li"); context.AddSession("session-1", "aaaaaaaaaaaa"); context.AddSession("session-2", DateTime.Now); context.AddSession("session-3", null); context.Request.SetInputStream("a=1&b=2"); DbCommand command = SqlInfoTest.CreateDbCommand(); Exception ex = CreateException("Test: HttpInfo.Create"); ExceptionInfo info = ExceptionInfo.Create(ex, context.HttpContext, command); info.Addition = Guid.NewGuid().ToString(); LogHelper.SyncWrite(info); LogHelperTest.AssertWriteOK(info.Addition); AssertWriteOK(ex.Message); } }