Skip to content

Commit eee1844

Browse files
committed
Write a test for limits of the 3 trainings in a day (close issues #46 and #47)
1 parent 6aedf6d commit eee1844

File tree

3 files changed

+90
-4
lines changed

3 files changed

+90
-4
lines changed

lib/models/db/event_series/competition/calendar_records/calendar_main_competition_records_to_calendar.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class CalendarMainCompetitionRecordsToCalendarConverter
2020
static const _day = Duration(days: 1);
2121

2222
@override
23-
List<Competition> convert(List<CalendarMainCompetitionRecord> records) {
24-
_highLevelCalendar = records;
23+
List<Competition> convert(List<CalendarMainCompetitionRecord> highLevelCalendar) {
24+
_highLevelCalendar = highLevelCalendar;
2525
_competitionsWhichShouldMoveBackIfHaveTeamCompBehind = {};
2626
_createLowCalendarAndAppropiatelyMarkCompetitions();
2727
_moveAppropriateCompetitionsBehindTeamComps();

lib/models/db/event_series/competition/calendar_records/converter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import 'package:sj_manager/models/db/event_series/competition/competition.dart';
44
abstract interface class LowLevelCalendarCreator<T extends HighLevelCompetitionRecord> {
55
const LowLevelCalendarCreator();
66

7-
List<Competition> convert(List<T> records);
7+
List<Competition> convert(List<T> highLevelCalendar);
88
}

test/career_mode_logic/creating_raw_calendars_test.dart

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,92 @@ void main() {
349349
]);
350350
});
351351

352-
test('The limit of 3 trainings in a day', () {});
352+
test(
353+
'The limit of 3 trainings in a day (example of a few pseudo days of world championships)',
354+
() {
355+
final startDate = DateTime(2022, 6, 1);
356+
final highLevelCalendar = [
357+
CalendarMainCompetitionRecord(
358+
hill: zakopane,
359+
date: startDate,
360+
setup: CalendarMainCompetitionRecordSetup(
361+
qualificationsRules: ind,
362+
trialRoundRules: ind,
363+
trainingsRules: List.generate(
364+
7,
365+
(_) => ind,
366+
), // One of the trainings is instead of the trial round (cannot have two trial rounds)
367+
mainCompRules: ind,
368+
),
369+
),
370+
];
371+
final lowLevelCalendar =
372+
CalendarMainCompetitionRecordsToCalendarConverter().convert(highLevelCalendar);
373+
expect(
374+
lowLevelCalendar,
375+
[
376+
Competition(
377+
hill: zakopane,
378+
date: DateTime(2022, 5, 29),
379+
rules: ind,
380+
type: CompetitionType.training,
381+
),
382+
Competition(
383+
hill: zakopane,
384+
date: DateTime(2022, 5, 29),
385+
rules: ind,
386+
type: CompetitionType.training,
387+
),
388+
Competition(
389+
hill: zakopane,
390+
date: DateTime(2022, 5, 30),
391+
rules: ind,
392+
type: CompetitionType.training,
393+
),
394+
Competition(
395+
hill: zakopane,
396+
date: DateTime(2022, 5, 30),
397+
rules: ind,
398+
type: CompetitionType.training,
399+
),
400+
Competition(
401+
hill: zakopane,
402+
date: DateTime(2022, 5, 30),
403+
rules: ind,
404+
type: CompetitionType.training,
405+
),
406+
Competition(
407+
hill: zakopane,
408+
date: DateTime(2022, 5, 31),
409+
rules: ind,
410+
type: CompetitionType.training,
411+
),
412+
Competition(
413+
hill: zakopane,
414+
date: DateTime(2022, 5, 31),
415+
rules: ind,
416+
type: CompetitionType.training,
417+
),
418+
Competition(
419+
hill: zakopane,
420+
date: DateTime(2022, 5, 31),
421+
rules: ind,
422+
type: CompetitionType.qualifications,
423+
),
424+
Competition(
425+
hill: zakopane,
426+
date: DateTime(2022, 6, 1),
427+
rules: ind,
428+
type: CompetitionType.trialRound,
429+
),
430+
Competition(
431+
hill: zakopane,
432+
date: DateTime(2022, 6, 1),
433+
rules: ind,
434+
type: CompetitionType.competition,
435+
),
436+
],
437+
);
438+
});
353439
});
354440
}

0 commit comments

Comments
 (0)