using BigRegister.Stamdata; namespace BigRegister.Tests.Domain; /// /// The profession↔program map's validity window (TE-009). `ByProgram` used to be a /// `static readonly` field filtered on `DateTime.Today` at type-load, so both branches of /// `StamdataFile.ActiveOn` were unreachable from here and nothing asserted the window at all. /// Now that the peildatum is a parameter, these are the two branches. /// public class ProfessionsTests { [Fact] public void A_mapping_is_absent_before_its_geldigVan() { // Every seeded row starts 2000-01-01; nothing is valid the day before. Assert.Empty(Professions.ByProgramOn(new DateOnly(1999, 12, 31))); } [Fact] public void A_mapping_is_present_on_and_after_its_geldigVan() { Assert.Equal("Arts", Professions.ByProgramOn(new DateOnly(2000, 1, 1))["geneeskunde"]); Assert.Equal("Arts", Professions.ByProgramOn(new DateOnly(2026, 8, 26))["geneeskunde"]); } [Fact] public void A_closed_mapping_is_absent_from_its_geldigTot_onwards() { // geldigTot is exclusive (`on < tot`), so the row drops out on the boundary date itself. foreach (var m in Professions.Mappings.Where(m => m.GeldigTot is DateOnly)) { var tot = m.GeldigTot!.Value; Assert.True(Professions.ByProgramOn(tot.AddDays(-1)).ContainsKey(m.Program)); Assert.False(Professions.ByProgramOn(tot).ContainsKey(m.Program)); } } [Fact] public void ByProgram_is_evaluated_per_call_not_captured_at_type_load() { // The regression this guards: a long-running process must not keep serving the answer // it computed at startup. Same date in, same answer; different date in, different answer. Assert.Equal(Professions.ByProgram.Count, Professions.ByProgramOn(DateOnly.FromDateTime(DateTime.Today)).Count); Assert.NotEqual(Professions.ByProgram.Count, Professions.ByProgramOn(new DateOnly(1999, 12, 31)).Count); } }