批量排课约束新增校区、教学楼、多教室统一指定,也支持清除原有限定。 课表新增“总视图”,同一时段、不同周次课程会并列显示。 周视图按教学周过滤,支持上一周、下一周、周次下拉和回到本周。 日视图按周次过滤;连续两节课程会跨两行完整占格。
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using Jiaowu.Api.Controllers;
|
|
using Jiaowu.Api.Domain.Academic;
|
|
using Jiaowu.Api.Infrastructure.Persistence;
|
|
using Jiaowu.Api.Infrastructure.Scheduling;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Jiaowu.Api.Tests;
|
|
|
|
public sealed class SchedulesControllerTests
|
|
{
|
|
[Fact]
|
|
public async Task Latest_auto_schedule_job_remains_available_after_completion()
|
|
{
|
|
await using var connection = new SqliteConnection("Data Source=:memory:");
|
|
await connection.OpenAsync();
|
|
var options = new DbContextOptionsBuilder<AppDbContext>()
|
|
.UseSqlite(connection)
|
|
.Options;
|
|
await using var db = new AppDbContext(options);
|
|
await db.Database.EnsureCreatedAsync();
|
|
|
|
var term = new AcademicTerm
|
|
{
|
|
Code = "2026-F",
|
|
Name = "2026 秋季",
|
|
AcademicYear = "2026-2027",
|
|
Season = TermSeason.Autumn,
|
|
StartDate = new DateOnly(2026, 9, 7),
|
|
EndDate = new DateOnly(2027, 1, 17)
|
|
};
|
|
var plan = new SchedulePlan
|
|
{
|
|
AcademicTerm = term,
|
|
Name = "排课草稿",
|
|
Version = "V1"
|
|
};
|
|
var completed = new AutomaticScheduleJob
|
|
{
|
|
SchedulePlan = plan,
|
|
Status = AutomaticScheduleJobStatus.Succeeded,
|
|
CreatedEntries = 12,
|
|
CompletedTasks = 5,
|
|
TotalTasks = 6,
|
|
ProcessedTasks = 6,
|
|
MessagesJson = "[\"TASK-06 仍有 2 学时无法安排\"]",
|
|
CompletedAt = DateTime.UtcNow
|
|
};
|
|
db.AddRange(term, plan, completed);
|
|
await db.SaveChangesAsync();
|
|
|
|
var controller = new SchedulesController(
|
|
db,
|
|
new AutomaticScheduleJobQueue());
|
|
var result = await controller.GetLatestAutomaticScheduleJob(
|
|
plan.Id,
|
|
CancellationToken.None);
|
|
|
|
var ok = Assert.IsType<OkObjectResult>(result.Result);
|
|
var response = Assert.IsType<AutomaticScheduleJobResponse>(ok.Value);
|
|
Assert.Equal(completed.Id, response.Id);
|
|
Assert.Equal(AutomaticScheduleJobStatus.Succeeded, response.Status);
|
|
Assert.Equal(
|
|
"TASK-06 仍有 2 学时无法安排",
|
|
Assert.Single(response.Messages));
|
|
}
|
|
}
|