using Jiaowu.Api.Domain.Academic; using Jiaowu.Api.Infrastructure.Teaching; namespace Jiaowu.Api.Tests; public sealed class TeachingTaskHoursTests { private static readonly Course Course = new() { Code = "TEST-01", Name = "测试课程", CollegeId = Guid.NewGuid(), Credits = 2, TotalHours = 32, LectureHours = 32 }; [Fact] public void Validate_accepts_matching_week_range_and_weekly_hours() { Assert.Null(TeachingTaskHours.Validate(Course, 1, 16, 2)); } [Fact] public void Validate_reports_course_total_and_planned_hours_when_mismatched() { var result = TeachingTaskHours.Validate(Course, 1, 8, 2); Assert.NotNull(result); Assert.Contains("总学时为 32", result); Assert.Contains("共 16 学时", result); } [Fact] public void Standard_schedule_includes_theory_and_experiment_hours() { var course = new Course { Code = "TEST-LAB", Name = "实验混合课程", CollegeId = Guid.NewGuid(), Credits = 4, TotalHours = 64, LectureHours = 48, PracticeHours = 16 }; Assert.Equal(48, TeachingTaskHours.RegularScheduleHours(course)); Assert.True(TeachingTaskHours.TryResolveRegularWeeklyHours( course, 1, 16, out var weeklyHours)); Assert.Equal(3, weeklyHours); Assert.Null(TeachingTaskHours.Validate(course, 1, 16, 4)); var result = TeachingTaskHours.Validate(course, 1, 16, 3); Assert.NotNull(result); Assert.Contains("理论课和实验课均应进入课表", result); Assert.Contains("共 48 学时", result); } [Fact] public void Flexible_schedule_keeps_total_workload_hours() { var course = new Course { Code = "TEST-PRACTICE", Name = "实践课程", CollegeId = Guid.NewGuid(), Credits = 1, TotalHours = 16, PracticeHours = 16 }; Assert.Null(TeachingTaskHours.Validate( course, 1, 16, 1, TeachingTaskSchedulingMode.Flexible)); Assert.Null(TeachingTaskHours.Validate(course, 1, 16, 1)); } }