Implement applicant pool functionality in school simulation, allowing for the management of job seekers who are not yet part of the school roster. Update the catalog to include staffing definitions and enhance the API to support applicant data retrieval. Revise the school architecture to handle applicant refresh logic and ensure proper integration with existing roster management. Update tests to validate the new applicant functionalities and ensure robustness in handling staffing scenarios.
This commit is contained in:
@@ -9,21 +9,23 @@ public class PeopleInSchoolTests
|
||||
private static readonly DateTime Start = new(2012, 4, 3, 6, 0, 0, DateTimeKind.Utc);
|
||||
|
||||
[Fact]
|
||||
public void InstallPeople_FillsHomeroomsAndJobs()
|
||||
public void InstallPeople_FillsHomeroomsAndLeavesJobsEmpty()
|
||||
{
|
||||
var (catalog, map) = Vanilla();
|
||||
var demand = SchoolDemand.From(catalog, map);
|
||||
var roster = RosterGenerator.Generate(catalog, map, schoolSeed: 1, "Slavic", Start);
|
||||
var pool = ApplicantPool.Create(catalog, roster, schoolSeed: 1, "Slavic", Start);
|
||||
|
||||
using var school = School.Create(1, "Полная", Start, catalog, map);
|
||||
school.InstallPeople(roster, seed: 1);
|
||||
school.InstallPeople(roster, seed: 1, "Slavic", pool);
|
||||
school.Tick(1d / 20d, 5d);
|
||||
|
||||
Assert.Same(roster, school.Roster);
|
||||
Assert.Equal(11, roster.Classes.Count);
|
||||
Assert.Equal(demand.Seats.Count, roster.People.Count(person => person.IsStudent));
|
||||
Assert.Equal(demand.Staff.Count, roster.People.Count(person => person.IsStaff));
|
||||
Assert.Equal(0, roster.People.Count(person => person.IsStaff));
|
||||
Assert.True(RosterFit.Matches(roster, demand));
|
||||
Assert.Equal(catalog.StaffingRules!.PoolSize, school.Applicants!.Applicants.Count);
|
||||
|
||||
var peopleQuery = new QueryDescription().WithAll<PersonIdentity, PersonNeeds, PersonRoles>();
|
||||
var classesQuery = new QueryDescription().WithAll<ClassIdentity>();
|
||||
@@ -31,6 +33,28 @@ public class PeopleInSchoolTests
|
||||
Assert.Equal(11, school.World.CountEntities(in classesQuery));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_AcrossAWeekBoundary_RefreshesTheApplicantPool()
|
||||
{
|
||||
var start = new DateTime(2012, 3, 31, 6, 0, 0, DateTimeKind.Utc);
|
||||
var (catalog, map) = Vanilla();
|
||||
var roster = RosterGenerator.Generate(catalog, map, schoolSeed: 1, "Slavic", start);
|
||||
var pool = ApplicantPool.Create(catalog, roster, schoolSeed: 1, "Slavic", start);
|
||||
|
||||
using var school = School.Create(1, "Неделя", start, catalog, map);
|
||||
school.InstallPeople(roster, seed: 1, "Slavic", pool);
|
||||
|
||||
var monday = new DateTime(2012, 4, 2, 6, 0, 0, DateTimeKind.Utc);
|
||||
var changed = school.Tick((monday - start).TotalMinutes / 5d, 5d);
|
||||
|
||||
Assert.True(changed);
|
||||
Assert.NotNull(school.Applicants);
|
||||
Assert.NotEqual(pool.Week, school.Applicants.Week);
|
||||
Assert.Equal(pool.Applicants.Count, school.Applicants.Applicants.Count);
|
||||
var peopleQuery = new QueryDescription().WithAll<PersonIdentity>();
|
||||
Assert.Equal(roster.People.Count, school.World.CountEntities(in peopleQuery));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CoreNeeds_DoNotMoveOnTick()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user