1- using System ;
1+ using System ;
22using System . IO ;
33using System . Threading ;
44using Microsoft . AspNetCore . Hosting ;
@@ -21,73 +21,73 @@ public class SenparcTraceTests
2121
2222 public SenparcTraceTests ( )
2323 {
24- //注册
24+ //Comment
2525 var mockEnv = new Mock < Microsoft . Extensions . Hosting . IHostEnvironment /*IHostingEnvironment*/ > ( ) ;
2626 mockEnv . Setup ( z => z . ContentRootPath ) . Returns ( ( ) => UnitTestHelper . RootPath ) ;
2727 var register = Senparc . CO2NET . AspNet . RegisterServices . RegisterService . Start ( mockEnv . Object , new SenparcSetting ( ) { IsDebug = true } ) ;
2828
2929 IServiceCollection services = new ServiceCollection ( ) ;
30- services . AddMemoryCache ( ) ; //使用内存缓存
30+ services . AddMemoryCache ( ) ; //Used for caching
3131
32- SenparcDI . GlobalServiceCollection = services ; //本地缓存需要用到
32+ SenparcDI . GlobalServiceCollection = services ; //Required for registration
3333
3434 //var mockRegisterService = new Mock<RegisterService>();
3535 //mockRegisterService.Setup(z => z.ServiceCollection).Returns(() => services);
3636
37- //删除日志文件
37+ //Delete log file
3838 //File.Delete(_logFilePath);
3939 }
4040
4141
4242 [ TestMethod ]
4343 public void LogTest ( )
4444 {
45- //直接调用此方法不会记录到log文件中,而是输出到系统日志中
46- var keyword = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
47- SenparcTrace . Log ( $ "添加Log: { keyword } ") ;
45+ //Directly call this method to record in the log file, instead of the system log
46+ var keyword = Guid . NewGuid ( ) . ToString ( ) ; //Test string
47+ SenparcTrace . Log ( $ "Add Log: { keyword } ") ;
4848
4949 var dt1 = SystemTime . Now ;
5050 while ( SystemTime . DiffTotalMS ( dt1 ) < 600 )
5151 {
52- //等待队列执行
52+ //Wait for execution
5353 }
5454
5555 SenparcMessageQueue . OperateQueue ( ) ;
5656
5757 Console . WriteLine ( SenparcMessageQueue . MessageQueueDictionary . Count ) ;
5858
5959 Console . WriteLine ( ThreadUtility . AsynThreadCollection . Count ) ;
60- //Assert.IsTrue(UnitTestHelper.CheckKeywordsExist(_logFilePath,keyword));
60+ //Assert.IsTrue(UnitTestHelper.CheckKeywordsExist(_logFilePath, keyword));
6161 }
6262
6363
6464 [ TestMethod ]
6565 public void SendCustomLogTest ( )
6666 {
67- var keyword = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
68- SenparcTrace . SendCustomLog ( "标题 " , $ "添加Log: { keyword } ") ;
67+ var keyword = Guid . NewGuid ( ) . ToString ( ) ; //Test string
68+ SenparcTrace . SendCustomLog ( "Title " , $ "Add Log: { keyword } ") ;
6969
7070 var dt1 = SystemTime . Now ;
7171 while ( SystemTime . DiffTotalMS ( dt1 ) < 800 )
7272 {
73- //等待队列执行
73+ //Wait for execution
7474 }
7575
76- Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , "标题 " , keyword ) ) ;
76+ Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , "Title " , keyword ) ) ;
7777 }
7878
7979
8080 [ TestMethod ]
8181 public void SendApiLogTest ( )
8282 {
8383 var url = "http://www.senparc.com" ;
84- var result = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
84+ var result = Guid . NewGuid ( ) . ToString ( ) ; //Test string
8585 SenparcTrace . SendApiLog ( url , result ) ;
8686
8787 var dt1 = SystemTime . Now ;
8888 while ( SystemTime . DiffTotalMS ( dt1 ) < 800 )
8989 {
90- //等待队列执行
90+ //Wait for execution
9191 }
9292
9393 Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , url , result ) ) ;
@@ -98,13 +98,13 @@ public void SendApiLogTest()
9898 public void SendApiPostDataLogTest ( )
9999 {
100100 var url = "http://www.senparc.com" ;
101- var data = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
101+ var data = Guid . NewGuid ( ) . ToString ( ) ; //Test string
102102 SenparcTrace . SendApiLog ( url , data ) ;
103103
104104 var dt1 = SystemTime . Now ;
105105 while ( SystemTime . DiffTotalMS ( dt1 ) < 800 )
106106 {
107- //等待队列执行
107+ //Wait for execution
108108 }
109109
110110 Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , url , data ) ) ;
@@ -115,18 +115,18 @@ public void SendApiPostDataLogTest()
115115 [ TestMethod ]
116116 public void BaseExceptionLogTest ( )
117117 {
118- var keyword = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
119- var ex = new BaseException ( "测试异常: " + keyword ) ;
120- //Log会记录两次,第一次是在BaseException初始化的时候会调用此方法
118+ var keyword = Guid . NewGuid ( ) . ToString ( ) ; //Test string
119+ var ex = new BaseException ( "Test Excepption " + keyword ) ;
120+ //Log recording method, call this method when initializing a BaseException
121121 SenparcTrace . BaseExceptionLog ( ex ) ;
122122
123123 var dt1 = SystemTime . Now ;
124124 while ( SystemTime . DiffTotalMS ( dt1 ) < 800 )
125125 {
126- //等待队列执行
126+ //Wait for execution
127127 }
128128
129- Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , "测试异常 " , keyword ) ) ;
129+ Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , "�����쳣 " , keyword ) ) ;
130130 }
131131
132132 [ TestMethod ]
@@ -135,13 +135,13 @@ public void OnLogFuncTest()
135135 var onlogCount = 0 ;
136136 SenparcTrace . OnLogFunc = ( ) => onlogCount ++ ;
137137
138- var keyword = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
139- SenparcTrace . SendCustomLog ( "测试OnLogFuncTest " , keyword ) ;
138+ var keyword = Guid . NewGuid ( ) . ToString ( ) ; //Test string
139+ SenparcTrace . SendCustomLog ( "Test OnLogFuncTest " , keyword ) ;
140140
141141 var dt1 = SystemTime . Now ;
142142 while ( SystemTime . DiffTotalMS ( dt1 ) < 800 )
143143 {
144- //等待队列执行
144+ //Wait for execution
145145 }
146146
147147 Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , keyword ) ) ;
@@ -155,15 +155,15 @@ public void OnBaseExceptionFuncTest()
155155 var onlogCount = 0 ;
156156 SenparcTrace . OnLogFunc = ( ) => onlogCount ++ ;
157157
158- var keyword = Guid . NewGuid ( ) . ToString ( ) ; //随机字符串
159- var ex = new BaseException ( "测试异常: " + keyword ) ;
160- //Log会记录两次,第一次是在BaseException初始化的时候会调用此方法
158+ var keyword = Guid . NewGuid ( ) . ToString ( ) ; //Test string
159+ var ex = new BaseException ( "Test Exception " + keyword ) ;
160+ //Log recording method, call this method when initializing a BaseException
161161 SenparcTrace . BaseExceptionLog ( ex ) ;
162162
163163 var dt1 = SystemTime . Now ;
164164 while ( SystemTime . DiffTotalMS ( dt1 ) < 1000 )
165165 {
166- //等待队列执行
166+ //Wait for execution
167167 }
168168
169169 Assert . IsTrue ( UnitTestHelper . CheckKeywordsExist ( LogFilePath , keyword ) ) ;
0 commit comments