Merge branch 'codex/shiyan' into master
# Conflicts: # web/package-lock.json
This commit is contained in:
@@ -171,7 +171,8 @@ public sealed class AutomaticScheduleGeneratorTests
|
||||
Name = "实验室 101",
|
||||
Building = building,
|
||||
Capacity = 40,
|
||||
RoomType = "实验室"
|
||||
RoomType = "实验室",
|
||||
TeachingVenueNature = TeachingVenueNature.Laboratory
|
||||
};
|
||||
var course = new Course
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public sealed class ExperimentsControllerTests
|
||||
|
||||
var result = await controller.CreateProjects(
|
||||
fixture.BatchProjectRequest(
|
||||
ExperimentArrangementMode.Centralized),
|
||||
ExperimentArrangementMode.SelfScheduled),
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.IsType<CreatedResult>(result);
|
||||
@@ -119,7 +119,7 @@ public sealed class ExperimentsControllerTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CentralizedProject_PublishesAndUsesTeachingTaskRoster()
|
||||
public async Task CentralizedProject_PublishesWhenBoundToPublishedExperimentSchedule()
|
||||
{
|
||||
await using var fixture = await ExperimentFixture.CreateAsync();
|
||||
var controller = fixture.Controller(fixture.ManagerScope);
|
||||
@@ -133,10 +133,7 @@ public sealed class ExperimentsControllerTests
|
||||
project.Id,
|
||||
fixture.SessionRequest(1, 2, 10),
|
||||
CancellationToken.None);
|
||||
Assert.IsType<CreatedResult>(sessionResult);
|
||||
Assert.Equal(
|
||||
1,
|
||||
(await fixture.Db.ExperimentSessions.SingleAsync()).Capacity);
|
||||
Assert.IsType<ConflictObjectResult>(sessionResult);
|
||||
|
||||
var published = await controller.PublishProject(
|
||||
project.Id,
|
||||
@@ -146,13 +143,7 @@ public sealed class ExperimentsControllerTests
|
||||
ExperimentProjectStatus.Published,
|
||||
(await fixture.Db.ExperimentProjects.SingleAsync()).Status);
|
||||
|
||||
var session = await fixture.Db.ExperimentSessions.SingleAsync();
|
||||
var participants = await controller.GetParticipants(
|
||||
session.Id,
|
||||
CancellationToken.None);
|
||||
var ok = Assert.IsType<OkObjectResult>(participants);
|
||||
var rows = Assert.IsAssignableFrom<IEnumerable<object>>(ok.Value);
|
||||
Assert.Single(rows);
|
||||
Assert.Empty(await fixture.Db.ExperimentSessions.ToListAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -333,11 +324,10 @@ public sealed class ExperimentsControllerTests
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.NotNull(timetable);
|
||||
Assert.Equal(2, timetable.ExperimentEntries.Count);
|
||||
Assert.Contains(
|
||||
timetable.ExperimentEntries,
|
||||
x => x.ExperimentArrangementMode ==
|
||||
ExperimentArrangementMode.Centralized);
|
||||
Assert.Single(timetable.ExperimentEntries);
|
||||
Assert.Equal(
|
||||
ExperimentArrangementMode.SelfScheduled,
|
||||
timetable.ExperimentEntries[0].ExperimentArrangementMode);
|
||||
Assert.Contains(
|
||||
timetable.ExperimentEntries,
|
||||
x => x.Id == selfSession.Id &&
|
||||
@@ -380,10 +370,7 @@ public sealed class ExperimentsControllerTests
|
||||
CancellationToken.None);
|
||||
|
||||
Assert.NotNull(timetable);
|
||||
Assert.Single(timetable.ExperimentEntries);
|
||||
Assert.Equal(
|
||||
ExperimentArrangementMode.Centralized,
|
||||
timetable.ExperimentEntries[0].ExperimentArrangementMode);
|
||||
Assert.Empty(timetable.ExperimentEntries);
|
||||
}
|
||||
|
||||
private sealed class ExperimentFixture : IAsyncDisposable
|
||||
@@ -395,6 +382,7 @@ public sealed class ExperimentsControllerTests
|
||||
TeachingTask task,
|
||||
Classroom classroom,
|
||||
Classroom secondClassroom,
|
||||
ScheduleEntry scheduleEntry,
|
||||
ICurrentUserDataScope managerScope,
|
||||
ICurrentUserDataScope studentScope)
|
||||
{
|
||||
@@ -404,6 +392,7 @@ public sealed class ExperimentsControllerTests
|
||||
Task = task;
|
||||
Classroom = classroom;
|
||||
SecondClassroom = secondClassroom;
|
||||
ScheduleEntry = scheduleEntry;
|
||||
ManagerScope = managerScope;
|
||||
StudentScope = studentScope;
|
||||
}
|
||||
@@ -414,6 +403,7 @@ public sealed class ExperimentsControllerTests
|
||||
public TeachingTask Task { get; }
|
||||
public Classroom Classroom { get; }
|
||||
public Classroom SecondClassroom { get; }
|
||||
public ScheduleEntry ScheduleEntry { get; }
|
||||
public ICurrentUserDataScope ManagerScope { get; }
|
||||
public ICurrentUserDataScope StudentScope { get; }
|
||||
|
||||
@@ -441,14 +431,16 @@ public sealed class ExperimentsControllerTests
|
||||
Code = "LAB101",
|
||||
Name = "实验室 101",
|
||||
BuildingId = building.Id,
|
||||
Capacity = 40
|
||||
Capacity = 40,
|
||||
TeachingVenueNature = TeachingVenueNature.Laboratory
|
||||
};
|
||||
var secondClassroom = new Classroom
|
||||
{
|
||||
Code = "LAB102",
|
||||
Name = "实验室 102",
|
||||
BuildingId = building.Id,
|
||||
Capacity = 40
|
||||
Capacity = 40,
|
||||
TeachingVenueNature = TeachingVenueNature.Laboratory
|
||||
};
|
||||
var college = new College { Code = "CS", Name = "计算机学院" };
|
||||
manager.CollegeId = college.Id;
|
||||
@@ -564,6 +556,27 @@ public sealed class ExperimentsControllerTests
|
||||
});
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
var scheduleEntry = new ScheduleEntry
|
||||
{
|
||||
SchedulePlan = new SchedulePlan
|
||||
{
|
||||
AcademicTermId = term.Id,
|
||||
Name = "已发布实验课表",
|
||||
Version = "LAB-1",
|
||||
Status = SchedulePlanStatus.Published
|
||||
},
|
||||
TeachingTaskId = task.Id,
|
||||
Kind = ScheduleEntryKind.Experiment,
|
||||
ClassroomId = classroom.Id,
|
||||
DayOfWeek = 1,
|
||||
StartPeriod = 10,
|
||||
PeriodCount = 2,
|
||||
StartWeek = 1,
|
||||
EndWeek = 8,
|
||||
WeekPattern = WeekPattern.All
|
||||
};
|
||||
db.ScheduleEntries.Add(scheduleEntry);
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return new ExperimentFixture(
|
||||
connection,
|
||||
@@ -572,6 +585,7 @@ public sealed class ExperimentsControllerTests
|
||||
task,
|
||||
classroom,
|
||||
secondClassroom,
|
||||
scheduleEntry,
|
||||
Scope(
|
||||
manager,
|
||||
SystemRoles.CollegeAdmin,
|
||||
@@ -600,7 +614,8 @@ public sealed class ExperimentsControllerTests
|
||||
"完成规定实验项目。",
|
||||
"携带校园卡。",
|
||||
Term.StartDate,
|
||||
Term.StartDate.AddDays(14));
|
||||
Term.StartDate.AddDays(14),
|
||||
mode == ExperimentArrangementMode.Centralized ? ScheduleEntry.Id : null);
|
||||
|
||||
public ExperimentProjectBatchRequest BatchProjectRequest(
|
||||
ExperimentArrangementMode mode) =>
|
||||
|
||||
@@ -46,7 +46,8 @@ public sealed class SchedulesControllerTests
|
||||
Name = "实验室 201",
|
||||
Building = building,
|
||||
Capacity = 40,
|
||||
RoomType = "实验室"
|
||||
RoomType = "实验室",
|
||||
TeachingVenueNature = TeachingVenueNature.Laboratory
|
||||
};
|
||||
var course = new Course
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user