XFEExtension.NetCore.ServerInteractive
[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.ServerInteractive.Test/Program.cs
+28
-27
Modified
XFEExtension.NetCore.ServerInteractive/Interfaces/CoreService/IXFEStandardServerCoreServiceBase.cs
+7
-1
XFEstudio/XFEExtension.NetCore.ServerInteractive
Apply PR review feedback: fix doc, add Request shim, fix HttpClient disposal, add test assertions, re-enable SMTest
Agent-Logs-Url: https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive/sessions/fd08659e-2e2a-46f6-9afa-fd84bd52275f Co-authored-by: XFEstudio <132526994+XFEstudio@users.noreply.github.com>
0330137
代码差异
2 个文件
+35
-28
@@ -66,7 +66,7 @@ internal class Program
66
66
[SMTest]
67
67
public static async Task TestGET()
68
68
{
69
var client = new HttpClient
69
using var client = new HttpClient
70
70
{
71
71
BaseAddress = new Uri("http://localhost:3305/api/")
72
72
};
@@ -78,14 +78,15 @@ internal class Program
78
78
}
79
79
else
80
80
{
81
Console.WriteLine($"请求失败:{response.StatusCode}");
81
var errorContent = await response.Content.ReadAsStringAsync();
82
throw new HttpRequestException($"请求失败:{response.StatusCode},响应内容:{errorContent}");
82
83
}
83
84
}
84
85
85
86
/// <summary>
86
87
/// 测试基本的test端点请求
87
88
/// </summary>
88
//[SMTest]
89
[SMTest]
89
90
public static async Task Test()
90
91
{
91
92
var result = await s_xFEClientRequester.Request<string>("test");
@@ -103,7 +104,7 @@ internal class Program
103
104
/// <summary>
104
105
/// 测试连接检查端点
105
106
/// </summary>
106
//[SMTest]
107
[SMTest]
107
108
public static async Task Check()
108
109
{
109
110
try
@@ -132,7 +133,7 @@ internal class Program
132
133
/// <summary>
133
134
/// 测试用户登录功能
134
135
/// </summary>
135
//[SMTest("Admin", "123456")]
136
[SMTest("Admin", "123456")]
136
137
public static async Task Login(string account, string password)
137
138
{
138
139
var result = await s_xFEClientRequester.Request<UserLoginResult<UserFaceInfo>>("login", account, password);
@@ -157,7 +158,7 @@ internal class Program
157
158
/// <summary>
158
159
/// 测试无效用户登录(错误密码)
159
160
/// </summary>
160
//[SMTest("Admin", "wrong_password")]
161
[SMTest("Admin", "wrong_password")]
161
162
public static async Task LoginWithWrongPassword(string account, string password)
162
163
{
163
164
var result = await s_xFEClientRequester.Request<UserLoginResult<UserFaceInfo>>("login", account, password);
@@ -168,7 +169,7 @@ internal class Program
168
169
/// <summary>
169
170
/// 测试无效用户登录(不存在的用户)
170
171
/// </summary>
171
//[SMTest("NonExistentUser", "123456")]
172
[SMTest("NonExistentUser", "123456")]
172
173
public static async Task LoginWithNonExistentUser(string account, string password)
173
174
{
174
175
var result = await s_xFEClientRequester.Request<UserLoginResult<UserFaceInfo>>("login", account, password);
@@ -179,7 +180,7 @@ internal class Program
179
180
/// <summary>
180
181
/// 测试重新登录功能
181
182
/// </summary>
182
//[SMTest]
183
[SMTest]
183
184
public static async Task ReLogin()
184
185
{
185
186
var result = await s_xFEClientRequester.Request<UserFaceInfo>("relogin");
@@ -203,7 +204,7 @@ internal class Program
203
204
/// <summary>
204
205
/// 测试Echo服务:发送消息并验证原样返回
205
206
/// </summary>
206
//[SMTest]
207
[SMTest]
207
208
public static async Task EchoTest()
208
209
{
209
210
var result = await s_xFEClientRequester.Request<string>("echo", "Hello, XFE!");
@@ -220,7 +221,7 @@ internal class Program
220
221
/// <summary>
221
222
/// 测试Echo服务:发送空消息
222
223
/// </summary>
223
//[SMTest]
224
[SMTest]
224
225
public static async Task EchoEmptyTest()
225
226
{
226
227
var result = await s_xFEClientRequester.Request<string>("echo", string.Empty);
@@ -237,7 +238,7 @@ internal class Program
237
238
/// <summary>
238
239
/// 测试Echo服务:发送中文消息
239
240
/// </summary>
240
//[SMTest]
241
[SMTest]
241
242
public static async Task EchoChineseTest()
242
243
{
243
244
var result = await s_xFEClientRequester.Request<string>("echo", "你好,世界!");
@@ -258,7 +259,7 @@ internal class Program
258
259
/// <summary>
259
260
/// 测试加法运算
260
261
/// </summary>
261
//[SMTest]
262
[SMTest]
262
263
public static async Task MathAddTest()
263
264
{
264
265
var result = await s_xFEClientRequester.Request<string>("math/add", 3.0, 5.0);
@@ -275,7 +276,7 @@ internal class Program
275
276
/// <summary>
276
277
/// 测试乘法运算
277
278
/// </summary>
278
//[SMTest]
279
[SMTest]
279
280
public static async Task MathMultiplyTest()
280
281
{
281
282
var result = await s_xFEClientRequester.Request<string>("math/multiply", 4.0, 7.0);
@@ -292,7 +293,7 @@ internal class Program
292
293
/// <summary>
293
294
/// 测试加法运算:负数
294
295
/// </summary>
295
//[SMTest]
296
[SMTest]
296
297
public static async Task MathAddNegativeTest()
297
298
{
298
299
var result = await s_xFEClientRequester.Request<string>("math/add", -10.0, 3.0);
@@ -309,7 +310,7 @@ internal class Program
309
310
/// <summary>
310
311
/// 测试乘法运算:零
311
312
/// </summary>
312
//[SMTest]
313
[SMTest]
313
314
public static async Task MathMultiplyZeroTest()
314
315
{
315
316
var result = await s_xFEClientRequester.Request<string>("math/multiply", 42.0, 0.0);
@@ -326,7 +327,7 @@ internal class Program
326
327
/// <summary>
327
328
/// 测试加法运算:小数
328
329
/// </summary>
329
//[SMTest]
330
[SMTest]
330
331
public static async Task MathAddDecimalTest()
331
332
{
332
333
var result = await s_xFEClientRequester.Request<string>("math/add", 1.5, 2.3);
@@ -347,7 +348,7 @@ internal class Program
347
348
/// <summary>
348
349
/// 测试服务器状态端点
349
350
/// </summary>
350
//[SMTest]
351
[SMTest]
351
352
public static async Task StatusTest()
352
353
{
353
354
var result = await s_xFEClientRequester.Request<string>("status");
@@ -368,7 +369,7 @@ internal class Program
368
369
/// <summary>
369
370
/// 测试问候服务:正常名称
370
371
/// </summary>
371
//[SMTest]
372
[SMTest]
372
373
public static async Task GreetTest()
373
374
{
374
375
var result = await s_xFEClientRequester.Request<string>("greet", "XFEstudio");
@@ -385,7 +386,7 @@ internal class Program
385
386
/// <summary>
386
387
/// 测试问候服务:空名称(应返回错误)
387
388
/// </summary>
388
//[SMTest]
389
[SMTest]
389
390
public static async Task GreetEmptyNameTest()
390
391
{
391
392
var result = await s_xFEClientRequester.Request<string>("greet");
@@ -400,7 +401,7 @@ internal class Program
400
401
/// <summary>
401
402
/// 测试服务器时间端点
402
403
/// </summary>
403
//[SMTest]
404
[SMTest]
404
405
public static async Task TimeTest()
405
406
{
406
407
var result = await s_xFEClientRequester.Request<string>("time");
@@ -421,7 +422,7 @@ internal class Program
421
422
/// <summary>
422
423
/// 压力测试:并行发送10000个请求
423
424
/// </summary>
424
//[SMTest]
425
[SMTest]
425
426
public static async Task TestBench()
426
427
{
427
428
await Parallel.ForEachAsync(Enumerable.Range(0, 10000), async (_, _) =>
@@ -446,7 +447,7 @@ internal class Program
446
447
/// <summary>
447
448
/// 测试获取服务器日志
448
449
/// </summary>
449
//[SMTest]
450
[SMTest]
450
451
public static async Task GetLog()
451
452
{
452
453
var result = await s_xFEClientRequester.Request<string>("get_log", DateTime.MinValue, DateTime.MaxValue);
@@ -468,7 +469,7 @@ internal class Program
468
469
/// <summary>
469
470
/// 测试Order模型序列化
470
471
/// </summary>
471
//[SMTest]
472
[SMTest]
472
473
public static string ConvertOrder()
473
474
{
474
475
var order = new Order
@@ -482,7 +483,7 @@ internal class Program
482
483
/// <summary>
483
484
/// 测试添加订单
484
485
/// </summary>
485
//[SMTest]
486
[SMTest]
486
487
public static async Task<bool> AddOrder() => await TableRequester.Add<Order>(new()
487
488
{
488
489
Description = "测试订单的描述",
@@ -492,7 +493,7 @@ internal class Program
492
493
/// <summary>
493
494
/// 测试获取订单列表
494
495
/// </summary>
495
//[SMTest]
496
[SMTest]
496
497
public static async Task GetOrder()
497
498
{
498
499
var result = await TableRequester.Get<Order>();
@@ -505,7 +506,7 @@ internal class Program
505
506
/// <summary>
506
507
/// 测试修改订单
507
508
/// </summary>
508
//[SMTest]
509
[SMTest]
509
510
public static async Task ChangeOrder()
510
511
{
511
512
var result = await TableRequester.Get<Order>();
@@ -519,7 +520,7 @@ internal class Program
519
520
/// <summary>
520
521
/// 测试获取修改后的订单列表
521
522
/// </summary>
522
//[SMTest]
523
[SMTest]
523
524
public static async Task GetOrder2()
524
525
{
525
526
var result = await TableRequester.Get<Order>();
@@ -41,10 +41,16 @@ public interface IXFEStandardServerCoreServiceBase : IXFEServerCoreServiceBase
41
41
ServerCoreReturnArgs ReturnArgs { get; set; }
42
42
43
43
/// <summary>
44
/// 本次异常服务器参数
44
/// 当前请求的事件参数
45
45
/// </summary>
46
46
CyberCommRequestEventArgs Args { get; set; }
47
47
48
/// <summary>
49
/// 当前请求对象。
50
/// </summary>
51
[Obsolete("Use Args.Request instead. This compatibility shim will be removed in a future release.")]
52
HttpListenerRequest? Request => Args?.Request;
53
48
54
/// <summary>
49
55
/// Sends a reply message asynchronously using the current context.
50
56
/// </summary>