Fixed tests

This commit is contained in:
2025-08-23 18:27:23 +02:00
parent 25274ed914
commit 892d127144
3 changed files with 24 additions and 15 deletions

View File

@@ -26,18 +26,19 @@ class GameSession extends ChangeNotifier {
int roundNumber; int roundNumber;
List<Round> roundList; List<Round> roundList;
GameSession( GameSession({
{required this.id, required this.id,
required this.createdAt, required this.createdAt,
required this.gameTitle, required this.gameTitle,
required this.players, required this.players,
required this.pointLimit, required this.pointLimit,
required this.caboPenalty, required this.caboPenalty,
required this.isPointsLimitEnabled, required this.isPointsLimitEnabled,
this.isGameFinished = false, this.isGameFinished = false,
this.winner = '', this.winner = '',
this.roundNumber = 1, this.roundNumber = 1,
this.roundList = const []}); List<Round>? roundList,
}) : roundList = roundList ?? [];
@override @override
toString() { toString() {

View File

@@ -19,9 +19,9 @@ class Round {
required this.gameId, required this.gameId,
required this.roundNum, required this.roundNum,
required this.caboPlayerIndex, required this.caboPlayerIndex,
this.kamikazePlayerIndex,
required this.scores, required this.scores,
required this.scoreUpdates, required this.scoreUpdates,
this.kamikazePlayerIndex,
}); });
@override @override

View File

@@ -8,6 +8,8 @@ void main() {
const testKamikazePlayerIndex = 1; const testKamikazePlayerIndex = 1;
const testScores = [10, 20, 30]; const testScores = [10, 20, 30];
const testScoreUpdates = [5, 15, 25]; const testScoreUpdates = [5, 15, 25];
const testRoundId = 'testRoundId';
const testGameId = 'testGameId';
setUp(() { setUp(() {
round = Round( round = Round(
@@ -32,8 +34,8 @@ void main() {
test('Constructor with null kamikazePlayerIndex', () { test('Constructor with null kamikazePlayerIndex', () {
final roundWithoutKamikaze = Round( final roundWithoutKamikaze = Round(
roundId: 'testRoundId', roundId: testRoundId,
gameId: 'testGameId', gameId: testGameId,
roundNum: testRoundNum, roundNum: testRoundNum,
caboPlayerIndex: testCaboPlayerIndex, caboPlayerIndex: testCaboPlayerIndex,
kamikazePlayerIndex: null, kamikazePlayerIndex: null,
@@ -49,6 +51,8 @@ void main() {
test('toJson() returns correct map', () { test('toJson() returns correct map', () {
final jsonMap = round.toJson(); final jsonMap = round.toJson();
expect(jsonMap['roundId'], equals(testRoundId));
expect(jsonMap['gameId'], equals(testGameId));
expect(jsonMap['roundNum'], equals(testRoundNum)); expect(jsonMap['roundNum'], equals(testRoundNum));
expect(jsonMap['caboPlayerIndex'], equals(testCaboPlayerIndex)); expect(jsonMap['caboPlayerIndex'], equals(testCaboPlayerIndex));
expect(jsonMap['kamikazePlayerIndex'], equals(testKamikazePlayerIndex)); expect(jsonMap['kamikazePlayerIndex'], equals(testKamikazePlayerIndex));
@@ -58,6 +62,8 @@ void main() {
test('fromJson() creates correct Round object', () { test('fromJson() creates correct Round object', () {
final jsonMap = { final jsonMap = {
'roundId': testRoundId,
'gameId': testGameId,
'roundNum': testRoundNum, 'roundNum': testRoundNum,
'caboPlayerIndex': testCaboPlayerIndex, 'caboPlayerIndex': testCaboPlayerIndex,
'kamikazePlayerIndex': testKamikazePlayerIndex, 'kamikazePlayerIndex': testKamikazePlayerIndex,
@@ -76,6 +82,8 @@ void main() {
test('fromJson() with null kamikazePlayerIndex', () { test('fromJson() with null kamikazePlayerIndex', () {
final jsonMap = { final jsonMap = {
'roundId': testRoundId,
'gameId': testGameId,
'roundNum': testRoundNum, 'roundNum': testRoundNum,
'caboPlayerIndex': testCaboPlayerIndex, 'caboPlayerIndex': testCaboPlayerIndex,
'kamikazePlayerIndex': null, 'kamikazePlayerIndex': null,