bag
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Yh.SchClass.OpenApi.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// 联调调试用例:默认请求联调环境 <c>http://base.yunhaixingtong.com/bschclass</c>,
|
||||
/// 并把每个端点的返回条数/异常打印到测试输出,便于在 IDE 调试窗口里逐个端点排查。
|
||||
/// <para>
|
||||
/// 用 <c>YH_SCHCLASS_DEBUG_HOST</c> / <c>YH_SCHCLASS_DEBUG_PATH</c> 覆盖目标地址,
|
||||
/// 置 <c>YH_SCHCLASS_DEBUG_OFF=1</c> 可关闭联调(CI 用它空跑通过)。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public class SchClassLiveDebugTests(ITestOutputHelper output)
|
||||
{
|
||||
private bool Live()
|
||||
{
|
||||
if (SchClassLiveDebug.Enabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
output.WriteLine("跳过联调:已设置 " + SchClassLiveDebug.OffVar + "=1(清除该变量即可恢复联调)");
|
||||
return false;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task 联调_学校列表()
|
||||
{
|
||||
if (!Live()) return;
|
||||
|
||||
var api = SchClassLiveDebug.Create();
|
||||
var list = await api.SchInfo.AllListAsync();
|
||||
|
||||
foreach (var s in list)
|
||||
{
|
||||
output.WriteLine($"SchInfo: {s.SchSerId} / {s.UserSchSerId} / {s.SchName}");
|
||||
}
|
||||
output.WriteLine($"共 {list.Count} 所学校 —— {SchClassLiveDebug.Target()}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task 联调_班级与学生()
|
||||
{
|
||||
if (!Live()) return;
|
||||
|
||||
var api = SchClassLiveDebug.Create();
|
||||
var sch = SchClassLiveDebug.Sch
|
||||
?? (await api.SchInfo.AllListAsync()).FirstOrDefault()?.SchSerId;
|
||||
if (string.IsNullOrEmpty(sch))
|
||||
{
|
||||
output.WriteLine("未取到学校序列号(设置 YH_SCHCLASS_DEBUG_SCH 或确认学校列表非空)");
|
||||
return;
|
||||
}
|
||||
|
||||
var classes = await api.VClass.GetVClassListAsync(sch);
|
||||
output.WriteLine($"VSchClass[{sch}] 共 {classes.Count} 个班级");
|
||||
|
||||
var students = await api.StuInfo.GetSchStuListAsync(sch, null);
|
||||
output.WriteLine($"OAStu[{sch}] 共 {students.Count} 名学生");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task 联调_教师与任课()
|
||||
{
|
||||
if (!Live()) return;
|
||||
|
||||
var api = SchClassLiveDebug.Create();
|
||||
var sch = SchClassLiveDebug.Sch
|
||||
?? (await api.SchInfo.AllListAsync()).FirstOrDefault()?.SchSerId;
|
||||
|
||||
var teachers = await api.TeaInfo.GetSchTeaInfoAsync(sch, null);
|
||||
output.WriteLine($"OATea[{sch}] 共 {teachers.Count} 名教师");
|
||||
|
||||
if (SchClassLiveDebug.TeaSerId is { } teaId)
|
||||
{
|
||||
var teach = await api.TeachInfo.GetSchTeachListAsync(sch, teaId);
|
||||
output.WriteLine($"TeachInfo[{teaId}] 共 {teach.Count} 条任课");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task 联调_一键跑通全部端点()
|
||||
{
|
||||
if (!Live()) return;
|
||||
|
||||
var failures = await SchClassLiveDebug.RunAllAsync(output.WriteLine);
|
||||
Assert.Empty(failures);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user