This commit is contained in:
wanghu
2026-09-02 09:38:45 +08:00
commit 8774b6cc44
128 changed files with 9382 additions and 0 deletions
@@ -0,0 +1,109 @@
namespace Yh.SchClass.OpenApi.Tests;
/// <summary>
/// OAStu(学生)端点的请求契约对拍。注意本控制器参数名<b>几乎全小写</b>
/// (<c>schserid</c> / <c>schgroupid</c> / <c>stuids</c> / <c>schserids</c>),
/// 与 VSchClass 的 <c>SchSerID</c> 形成对照,不可混用。
/// </summary>
public class SchClassStuInfoClientTests
{
private const string Root = "/oapi/OAStu/";
[Fact]
public async Task OAStu_全部19个端点_路径与参数名对齐()
{
var handler = SchClassTestHost.Ok();
var api = SchClassTestHost.Api(handler);
await api.StuInfo.GetAllStuListAsync();
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetAllStulist");
await api.StuInfo.GetEleAllStuListAsync();
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleAllStulist");
await api.StuInfo.GetSchStuListAsync("S1", "10");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetSchStulist", "?schserid=S1&schgroupid=10");
await api.StuInfo.GetEleSchStuListAsync("S1", "10");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleSchStulist", "?schserid=S1&schgroupid=10");
await api.StuInfo.GetClaStuListAsync("1001", "20");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetClaStulist", "?ClassID=1001&clagroupid=20");
await api.StuInfo.GetEleClaStuListAsync("1001", "20");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleClaStulist", "?ClassID=1001&clagroupid=20");
await api.StuInfo.GetClaArrStuListAsync("1001,1002", "20,21");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetClaArrStulist", "?ClassIDs=1001,1002&clagroupids=20,21");
await api.StuInfo.GetEleClaArrStuListAsync("1001,1002", "20,21");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleClaArrStulist", "?ClassIDs=1001,1002&clagroupids=20,21");
await api.StuInfo.GetStuIdsListAsync("1,2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetStuIdslist", "?stuids=1,2");
await api.StuInfo.GetEleStuIdsListAsync("1,2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleStuIdslist", "?stuids=1,2");
await api.StuInfo.GetStuUserFamIdListAsync("1,2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetStuUserFamIDList", "?stuids=1,2");
await api.StuInfo.GetFamStuListAsync("IC1,IC2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetFamStulist", "?invitecodes=IC1,IC2");
await api.StuInfo.GetStuFamMemAsync("S1");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetStuFamMem", "?SchSerID=S1");
await api.StuInfo.GetSchBySchIdsAsync("S1,S2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetSchBySchIds", "?schserids=S1,S2");
await api.StuInfo.GetEleSchIdsStuListAsync("S1,S2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleSchIdsStulist", "?schserids=S1,S2");
await api.StuInfo.GetEleSchBySchIdsAsync("S1,S2");
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetEleSchBySchIds", "?schserids=S1,S2");
await api.StuInfo.GetStudentsByElectiveIdAsync(5);
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "GetStudentsByElectiveId", "?electiveIds=5");
await api.StuInfo.GetHistoryStudentsBySchoolIdAsync(1, 2026);
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "getHistoryStudentsBySchoolId", "?schoolId=1&year=2026");
await api.StuInfo.GetHistoryClassAsync(1, 2026);
SchClassTestHost.Verify(handler, HttpMethod.Get, Root + "getHistoryClass", "?schoolId=1&year=2026");
}
[Fact]
public async Task 学生行字段_按键名原样读取()
{
var handler = FakeHandler.Json(HttpStatusCode.OK, """
[{"Account":"2026001","UserStuSerID":11,"StuName":"小明","StuIDCard":"110101","StuSex":"男",
"StuStatus":1,"ClassID":1001,"ClassStuID":2001,"GroupID":30,"StuPhoto":null,"CardID":"C1",
"StuCurrentTel":"138","invitecode":"IC1","SchSerID":"S1","Graduated":0,"isjiedu":0}]
""");
var rows = await SchClassTestHost.Api(handler).StuInfo.GetAllStuListAsync();
var row = Assert.Single(rows);
Assert.Equal("小明", row["StuName"].GetString());
Assert.Equal(1001, row["ClassID"].GetInt32());
Assert.Equal("S1", row["SchSerID"].GetString());
Assert.Equal(JsonValueKind.Null, row["StuPhoto"].ValueKind);
}
[Fact]
public async Task 历史学生行_使用小写字段名()
{
var handler = FakeHandler.Json(HttpStatusCode.OK, """
[{"stuId":11,"stuName":"小明","classId":1001,"className":"高一(1)班",
"grade":1,"name":"第一中学","school_system_id":3,"system_grade":10}]
""");
var rows = await SchClassTestHost.Api(handler).StuInfo.GetHistoryStudentsBySchoolIdAsync(1, 2026);
var row = Assert.Single(rows);
Assert.Equal("小明", row["stuName"].GetString());
Assert.Equal("高一(1)班", row["className"].GetString());
Assert.Equal(3, row["school_system_id"].GetInt32());
}
}