Main页面
This commit is contained in:
1 parent
a003d90b0e
commit
f03e2b08f4
33 files changed
+54543
-34
No files matched your search
@@ -28,7 +28,13 @@ handler.Json = """{"code":200,"data":{"total":1,"items":[{"id":3,"userName":"ali
|
||||
var page = await api.Users.SearchAsync(new UserSearchRequest { Page = 2, PageSize = 10 });
|
||||
Check(page.Total == 1 && page.Items[0].UserName == "alice", "分页解析失败");
|
||||
Check(handler.Authorization == "Bearer session-one" && handler.Body!.Contains("\"page\":2"), "Token 或分页请求体错误");
|
||||
handler.Json = """{"code":200,"data":null}""";
|
||||
await api.Users.DeleteAsync(3);
|
||||
Check(handler.Path.EndsWith("/user/DelUser") && handler.Query == "?id=3" && handler.Method == HttpMethod.Post,
|
||||
"删除用户必须 POST 并通过 query 指定 ID");
|
||||
var count = handler.Count;
|
||||
try { await api.Users.DeleteAsync(0); throw new Exception("未校验用户 ID"); }
|
||||
catch (ArgumentOutOfRangeException) { Check(handler.Count == count, "无效 ID 不应发送"); }
|
||||
try { await api.Users.SearchAsync(new UserSearchRequest { Page = 0 }); throw new Exception("未校验分页"); }
|
||||
catch (ValidationException) { Check(handler.Count == count, "无效参数不应发送"); }
|
||||
handler.Json = """{"code":2001,"msg":"业务失败","traceId":"trace-1","data":null}""";
|
||||
@@ -153,6 +159,8 @@ sealed class StubHandler : HttpMessageHandler
|
||||
public HttpStatusCode Status { get; set; } = HttpStatusCode.OK;
|
||||
public int Count { get; private set; }
|
||||
public string Path { get; private set; } = "";
|
||||
public string? Query { get; private set; }
|
||||
public HttpMethod? Method { get; private set; }
|
||||
public string? Authorization { get; private set; }
|
||||
public string? Body { get; private set; }
|
||||
public Func<CancellationToken, Task>? BeforeResponse { get; set; }
|
||||
@@ -160,6 +168,8 @@ sealed class StubHandler : HttpMessageHandler
|
||||
{
|
||||
Count++;
|
||||
Path = request.RequestUri!.AbsolutePath;
|
||||
Query = request.RequestUri.Query;
|
||||
Method = request.Method;
|
||||
Authorization = request.Headers.Authorization?.ToString();
|
||||
Body = request.Content is null ? null : await request.Content.ReadAsStringAsync(cancellationToken);
|
||||
HttpStatusCode status = Status;
|
||||
|
||||
Reference in new issue
Block a user