|
| 1 | +import 'package:flutter_test/flutter_test.dart'; |
| 2 | +import 'package:sj_manager/models/db/event_series/standings/score/basic_score_types.dart'; |
| 3 | +import 'package:sj_manager/models/db/event_series/standings/standings_positions_map_creator/standings_positions_creator.dart'; |
| 4 | +import 'package:sj_manager/models/db/event_series/standings/standings_positions_map_creator/standings_positions_with_ex_aequos_creator.dart'; |
| 5 | +import 'package:sj_manager/models/db/event_series/standings/standings_positions_map_creator/standings_positions_with_no_ex_aequo_creator.dart'; |
| 6 | +import 'package:sj_manager/models/db/event_series/standings/standings_record.dart'; |
| 7 | + |
| 8 | +void main() { |
| 9 | + late StandingsPositionsCreator<StandingsRecord<String, PointsScore>> creator; |
| 10 | + const recordsWithoutExAequo = [ |
| 11 | + StandingsRecord(entity: 'Maciej Kot', score: PointsScore(140.5)), |
| 12 | + StandingsRecord(entity: 'Dawid Kubacki', score: PointsScore(137.2)), |
| 13 | + StandingsRecord(entity: 'Kamil Stoch', score: PointsScore(132.5)), |
| 14 | + StandingsRecord(entity: 'Jakub Wolny', score: PointsScore(130.4)), |
| 15 | + StandingsRecord(entity: 'Paweł Wasek', score: PointsScore(128.5)), |
| 16 | + StandingsRecord(entity: 'Andrzej Stękała', score: PointsScore(111.5)), |
| 17 | + ]; |
| 18 | + |
| 19 | + const recordsWithExAequos = [ |
| 20 | + StandingsRecord(entity: 'Maciej Kot', score: PointsScore(140.5)), |
| 21 | + StandingsRecord(entity: 'Dawid Kubacki', score: PointsScore(140.5)), |
| 22 | + StandingsRecord(entity: 'Piotr Żyła', score: PointsScore(140.5)), |
| 23 | + StandingsRecord(entity: 'Kamil Stoch', score: PointsScore(130.1)), |
| 24 | + StandingsRecord(entity: 'Jakub Wolny', score: PointsScore(129.0)), |
| 25 | + StandingsRecord(entity: 'Paweł Wasek', score: PointsScore(129.0)), |
| 26 | + StandingsRecord(entity: 'Andrzej Stękała', score: PointsScore(110.0)), |
| 27 | + StandingsRecord(entity: 'Kacper Tomasiak', score: PointsScore(110.0)), |
| 28 | + StandingsRecord(entity: 'Stefan Hula', score: PointsScore(107.6)), |
| 29 | + StandingsRecord(entity: 'Tymek Amilkiewicz', score: PointsScore(103.5)), |
| 30 | + ]; |
| 31 | + |
| 32 | + group('When no aequos', () { |
| 33 | + const expected = { |
| 34 | + 1: [StandingsRecord(entity: 'Maciej Kot', score: PointsScore(140.5))], |
| 35 | + 2: [StandingsRecord(entity: 'Dawid Kubacki', score: PointsScore(137.2))], |
| 36 | + 3: [StandingsRecord(entity: 'Kamil Stoch', score: PointsScore(132.5))], |
| 37 | + 4: [StandingsRecord(entity: 'Jakub Wolny', score: PointsScore(130.4))], |
| 38 | + 5: [StandingsRecord(entity: 'Paweł Wasek', score: PointsScore(128.5))], |
| 39 | + 6: [StandingsRecord(entity: 'Andrzej Stękała', score: PointsScore(111.5))], |
| 40 | + }; |
| 41 | + test('No ex aequos for StandingsPositionsWithNoExAequoCreator', () { |
| 42 | + creator = StandingsPositionsWithNoExAequoCreator(); |
| 43 | + final positions = creator.create(recordsWithoutExAequo); |
| 44 | + expect(positions, expected); |
| 45 | + }); |
| 46 | + test('No ex aequos for StandingsPositionsWithExAequosCreator', () { |
| 47 | + creator = StandingsPositionsWithExAequosCreator(); |
| 48 | + final positions = creator.create(recordsWithoutExAequo); |
| 49 | + expect(positions, expected); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + group('When there are ex aequos', () { |
| 54 | + test('Ex aequos for StandingsPositionsWithNoExAequoCreator', () { |
| 55 | + creator = StandingsPositionsWithNoExAequoCreator(); |
| 56 | + final positions = creator.create(recordsWithExAequos); |
| 57 | + expect(positions, const { |
| 58 | + 1: [StandingsRecord(entity: 'Maciej Kot', score: PointsScore(140.5))], |
| 59 | + 2: [StandingsRecord(entity: 'Dawid Kubacki', score: PointsScore(140.5))], |
| 60 | + 3: [StandingsRecord(entity: 'Piotr Żyła', score: PointsScore(140.5))], |
| 61 | + 4: [StandingsRecord(entity: 'Kamil Stoch', score: PointsScore(130.1))], |
| 62 | + 5: [StandingsRecord(entity: 'Jakub Wolny', score: PointsScore(129.0))], |
| 63 | + 6: [StandingsRecord(entity: 'Paweł Wasek', score: PointsScore(129.0))], |
| 64 | + 7: [StandingsRecord(entity: 'Andrzej Stękała', score: PointsScore(110.0))], |
| 65 | + 8: [StandingsRecord(entity: 'Kacper Tomasiak', score: PointsScore(110.0))], |
| 66 | + 9: [StandingsRecord(entity: 'Stefan Hula', score: PointsScore(107.6))], |
| 67 | + 10: [StandingsRecord(entity: 'Tymek Amilkiewicz', score: PointsScore(103.5))], |
| 68 | + }); |
| 69 | + }); |
| 70 | + test('Ex aequos for StandingsPositionsWithNoAequosCreator', () { |
| 71 | + creator = StandingsPositionsWithExAequosCreator(); |
| 72 | + final positions = creator.create(recordsWithExAequos); |
| 73 | + expect(positions, const { |
| 74 | + 1: [ |
| 75 | + StandingsRecord(entity: 'Maciej Kot', score: PointsScore(140.5)), |
| 76 | + StandingsRecord(entity: 'Dawid Kubacki', score: PointsScore(140.5)), |
| 77 | + StandingsRecord(entity: 'Piotr Żyła', score: PointsScore(140.5)), |
| 78 | + ], |
| 79 | + 4: [ |
| 80 | + StandingsRecord(entity: 'Kamil Stoch', score: PointsScore(130.1)), |
| 81 | + ], |
| 82 | + 5: [ |
| 83 | + StandingsRecord(entity: 'Jakub Wolny', score: PointsScore(129.0)), |
| 84 | + StandingsRecord(entity: 'Paweł Wasek', score: PointsScore(129.0)), |
| 85 | + ], |
| 86 | + 7: [ |
| 87 | + StandingsRecord(entity: 'Andrzej Stękała', score: PointsScore(110.0)), |
| 88 | + StandingsRecord(entity: 'Kacper Tomasiak', score: PointsScore(110.0)), |
| 89 | + ], |
| 90 | + 9: [StandingsRecord(entity: 'Stefan Hula', score: PointsScore(107.6))], |
| 91 | + 10: [StandingsRecord(entity: 'Tymek Amilkiewicz', score: PointsScore(103.5))], |
| 92 | + }); |
| 93 | + }); |
| 94 | + }); |
| 95 | +} |
0 commit comments