diff --git a/lib/data/dto/game_session.dart b/lib/data/dto/game_session.dart index 5bd0bc0..b127e97 100644 --- a/lib/data/dto/game_session.dart +++ b/lib/data/dto/game_session.dart @@ -26,18 +26,19 @@ class GameSession extends ChangeNotifier { int roundNumber; List roundList; - GameSession( - {required this.id, - required this.createdAt, - required this.gameTitle, - required this.players, - required this.pointLimit, - required this.caboPenalty, - required this.isPointsLimitEnabled, - this.isGameFinished = false, - this.winner = '', - this.roundNumber = 1, - this.roundList = const []}); + GameSession({ + required this.id, + required this.createdAt, + required this.gameTitle, + required this.players, + required this.pointLimit, + required this.caboPenalty, + required this.isPointsLimitEnabled, + this.isGameFinished = false, + this.winner = '', + this.roundNumber = 1, + List? roundList, + }) : roundList = roundList ?? []; @override toString() { diff --git a/lib/data/dto/round.dart b/lib/data/dto/round.dart index 9caf39f..05307da 100644 --- a/lib/data/dto/round.dart +++ b/lib/data/dto/round.dart @@ -19,9 +19,9 @@ class Round { required this.gameId, required this.roundNum, required this.caboPlayerIndex, - this.kamikazePlayerIndex, required this.scores, required this.scoreUpdates, + this.kamikazePlayerIndex, }); @override diff --git a/test/data/round_test.dart b/test/data/round_test.dart index c1c0374..02ab7ce 100644 --- a/test/data/round_test.dart +++ b/test/data/round_test.dart @@ -8,6 +8,8 @@ void main() { const testKamikazePlayerIndex = 1; const testScores = [10, 20, 30]; const testScoreUpdates = [5, 15, 25]; + const testRoundId = 'testRoundId'; + const testGameId = 'testGameId'; setUp(() { round = Round( @@ -32,8 +34,8 @@ void main() { test('Constructor with null kamikazePlayerIndex', () { final roundWithoutKamikaze = Round( - roundId: 'testRoundId', - gameId: 'testGameId', + roundId: testRoundId, + gameId: testGameId, roundNum: testRoundNum, caboPlayerIndex: testCaboPlayerIndex, kamikazePlayerIndex: null, @@ -49,6 +51,8 @@ void main() { test('toJson() returns correct map', () { final jsonMap = round.toJson(); + expect(jsonMap['roundId'], equals(testRoundId)); + expect(jsonMap['gameId'], equals(testGameId)); expect(jsonMap['roundNum'], equals(testRoundNum)); expect(jsonMap['caboPlayerIndex'], equals(testCaboPlayerIndex)); expect(jsonMap['kamikazePlayerIndex'], equals(testKamikazePlayerIndex)); @@ -58,6 +62,8 @@ void main() { test('fromJson() creates correct Round object', () { final jsonMap = { + 'roundId': testRoundId, + 'gameId': testGameId, 'roundNum': testRoundNum, 'caboPlayerIndex': testCaboPlayerIndex, 'kamikazePlayerIndex': testKamikazePlayerIndex, @@ -76,6 +82,8 @@ void main() { test('fromJson() with null kamikazePlayerIndex', () { final jsonMap = { + 'roundId': testRoundId, + 'gameId': testGameId, 'roundNum': testRoundNum, 'caboPlayerIndex': testCaboPlayerIndex, 'kamikazePlayerIndex': null,