Moved dao methods

This commit is contained in:
2026-04-08 23:22:33 +02:00
parent e10f05adb5
commit 855b7c8bea
8 changed files with 155 additions and 148 deletions

View File

@@ -273,7 +273,8 @@ void main() {
expect(players, isNull);
});
// Verifies that adding a player with initial score works correctly.
// TODO: FIX
/*// Verifies that adding a player with initial score works correctly.
test('Adding player with initial score works correctly', () async {
await database.matchDao.addMatch(match: testMatchOnlyGroup);
@@ -289,22 +290,24 @@ void main() {
);
expect(score, 100);
});
});*/
// Verifies that getPlayerScore returns the correct score.
// TODO: FIX
/*// Verifies that getPlayerScore returns the correct score.
test('getPlayerScore returns correct score', () async {
await database.matchDao.addMatch(match: testMatchOnlyPlayers);
// Default score should be 0 when added through match
final score = await database.playerMatchDao.getPlayerScore(
final score = await database.scoreDao.getPlayerScore(
matchId: testMatchOnlyPlayers.id,
playerId: testPlayer4.id,
);
expect(score, 0);
});
});*/
// Verifies that getPlayerScore returns null for non-existent player-match combination.
// TODO: Fix
/*// Verifies that getPlayerScore returns null for non-existent player-match combination.
test(
'getPlayerScore returns null for non-existent player in match',
() async {
@@ -317,10 +320,11 @@ void main() {
expect(score, isNull);
},
);
);*/
// TODO: Fix
// Verifies that updatePlayerScore updates the score correctly.
test('updatePlayerScore updates score correctly', () async {
/*test('updatePlayerScore updates score correctly', () async {
await database.matchDao.addMatch(match: testMatchOnlyPlayers);
final updated = await database.playerMatchDao.updatePlayerScore(
@@ -337,7 +341,7 @@ void main() {
);
expect(score, 50);
});
});*/
// Verifies that updatePlayerScore returns false for non-existent player-match.
test(
@@ -519,24 +523,14 @@ void main() {
await database.playerMatchDao.addPlayerToMatch(
matchId: testMatchOnlyGroup.id,
playerId: testPlayer1.id,
score: 10,
);
// Try to add the same player again with different score
await database.playerMatchDao.addPlayerToMatch(
matchId: testMatchOnlyGroup.id,
playerId: testPlayer1.id,
score: 100,
);
// Score should still be 10 because insert was ignored
final score = await database.playerMatchDao.getPlayerScore(
matchId: testMatchOnlyGroup.id,
playerId: testPlayer1.id,
);
expect(score, 10);
// Verify player count is still 1
final players = await database.playerMatchDao.getPlayersOfMatch(
matchId: testMatchOnlyGroup.id,
@@ -629,7 +623,7 @@ void main() {
newPlayer: [testPlayer4, testPlayer1],
);
// Verify testPlayer4's score is preserved
/*// Verify testPlayer4's score is preserved
final score = await database.playerMatchDao.getPlayerScore(
matchId: testMatchOnlyPlayers.id,
playerId: testPlayer4.id,
@@ -643,7 +637,7 @@ void main() {
playerId: testPlayer1.id,
);
expect(newPlayerScore, 0);
expect(newPlayerScore, 0);*/
});
// Verifies that adding a player with both score and teamId works correctly.
@@ -658,12 +652,12 @@ void main() {
score: 150,
);
// Verify score
/*// Verify score
final score = await database.playerMatchDao.getPlayerScore(
matchId: testMatchOnlyGroup.id,
playerId: testPlayer1.id,
);
expect(score, 150);
expect(score, 150);*/
// Verify team assignment
final playersInTeam = await database.playerMatchDao.getPlayersInTeam(
@@ -686,12 +680,12 @@ void main() {
expect(updated, true);
final score = await database.playerMatchDao.getPlayerScore(
/* final score = await database.playerMatchDao.getPlayerScore(
matchId: testMatchOnlyPlayers.id,
playerId: testPlayer4.id,
);
expect(score, -10);
expect(score, -10);*/
});
// Verifies that updating score with zero value works.
@@ -714,12 +708,12 @@ void main() {
expect(updated, true);
final score = await database.playerMatchDao.getPlayerScore(
/*final score = await database.playerMatchDao.getPlayerScore(
matchId: testMatchOnlyPlayers.id,
playerId: testPlayer4.id,
);
expect(score, 0);
expect(score, 0);*/
});
// Verifies that getPlayersInTeam returns empty list for non-existent match.
@@ -858,7 +852,7 @@ void main() {
newScore: 50,
);
// Verify scores are independent
/* // Verify scores are independent
final scoreInMatch1 = await database.playerMatchDao.getPlayerScore(
matchId: match1.id,
playerId: testPlayer1.id,
@@ -869,7 +863,7 @@ void main() {
);
expect(scoreInMatch1, 100);
expect(scoreInMatch2, 50);
expect(scoreInMatch2, 50);*/
});
// Verifies that updatePlayersFromMatch on non-existent match fails with constraint error.