Add batch proxy booking for self-scheduled experiments
This commit is contained in:
1 parent
1e43d910c0
commit
e6d25791b3
3 files changed
+152
-11
No files matched your search
@@ -427,6 +427,41 @@ public sealed class ExperimentsControllerTests
|
||||
x.Status == ExperimentBookingStatus.Booked));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ManagerCanProxyBookMultipleStudentsForASelfScheduledSession()
|
||||
{
|
||||
await using var fixture = await ExperimentFixture.CreateAsync();
|
||||
var manager = fixture.Controller(fixture.ManagerScope);
|
||||
await manager.CreateProject(
|
||||
fixture.ProjectRequest(ExperimentArrangementMode.SelfScheduled),
|
||||
CancellationToken.None);
|
||||
var project = await fixture.Db.ExperimentProjects.SingleAsync();
|
||||
await manager.CreateSession(
|
||||
project.Id, fixture.SessionRequest(3, 2, 3), CancellationToken.None);
|
||||
await manager.PublishProject(project.Id, CancellationToken.None);
|
||||
var session = await fixture.Db.ExperimentSessions.SingleAsync();
|
||||
var originalStudent = await fixture.Db.Students.SingleAsync();
|
||||
fixture.Db.Students.Add(new Student
|
||||
{
|
||||
StudentNumber = "20990002",
|
||||
Name = "第二名实验学生",
|
||||
AdministrativeClassId = originalStudent.AdministrativeClassId,
|
||||
EnrollmentYear = originalStudent.EnrollmentYear,
|
||||
EnrollmentDate = originalStudent.EnrollmentDate
|
||||
});
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var studentIds = await fixture.Db.Students.Select(x => x.Id).ToListAsync();
|
||||
|
||||
var result = await manager.CreateProxyBookings(
|
||||
session.Id, new ProxyExperimentBookingBatchRequest(studentIds), CancellationToken.None);
|
||||
|
||||
var response = Assert.IsType<OkObjectResult>(result);
|
||||
Assert.Equal(studentIds.Count, response.Value!.GetType().GetProperty("BookedCount")!.GetValue(response.Value));
|
||||
Assert.Equal(studentIds.Count, await fixture.Db.ExperimentBookings.CountAsync(x =>
|
||||
x.ExperimentSessionId == session.Id &&
|
||||
x.Status == ExperimentBookingStatus.Booked));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StudentBooking_RejectsPublishedTimetableConflict()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user