Compare commits
3 Commits
961c6bb679
...
32f3f68da9
| Author | SHA1 | Date | |
|---|---|---|---|
| 32f3f68da9 | |||
| 229750ffcf | |||
| fe9239ee02 |
@@ -10,6 +10,9 @@ class PlayerGroupDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$PlayerGroupDaoMixin {
|
||||
PlayerGroupDao(super.db);
|
||||
|
||||
/// No need for a groupHasPlayers method since the members attribute is
|
||||
/// not nullable
|
||||
|
||||
/// Adds a [player] to a group with the given [groupId].
|
||||
/// If the player is already in the group, no action is taken.
|
||||
/// If the player does not exist in the player table, they are added.
|
||||
|
||||
@@ -104,7 +104,25 @@ void main() {
|
||||
expect(result.group, null);
|
||||
});
|
||||
|
||||
// TODO: test getGroupOfGame()
|
||||
test('Retrieving group of a game works correctly', () async {});
|
||||
test('Retrieving group of a game works correctly', () async {
|
||||
await database.gameDao.addGame(game: gameWithGroup);
|
||||
final group = await database.groupGameDao.getGroupOfGame(
|
||||
gameId: gameWithGroup.id,
|
||||
);
|
||||
|
||||
if (group == null) {
|
||||
fail('Group should not be null');
|
||||
}
|
||||
|
||||
expect(group.id, testgroup.id);
|
||||
expect(group.name, testgroup.name);
|
||||
expect(group.createdAt, testgroup.createdAt);
|
||||
expect(group.members.length, testgroup.members.length);
|
||||
for (int i = 0; i < group.members.length; i++) {
|
||||
expect(group.members[i].id, testgroup.members[i].id);
|
||||
expect(group.members[i].name, testgroup.members[i].name);
|
||||
expect(group.members[i].createdAt, testgroup.members[i].createdAt);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ void main() {
|
||||
expect(removed, true);
|
||||
|
||||
final result = await database.gameDao.getGameById(
|
||||
gameId: testgameWithGroup.id,
|
||||
gameId: testgameWithPlayers.id,
|
||||
);
|
||||
expect(result.players!.length, testgameWithGroup.players!.length - 1);
|
||||
expect(result.players!.length, testgameWithPlayers.players!.length - 1);
|
||||
|
||||
final playerExists = result.players!.any(
|
||||
(p) => p.id == playerToRemove.id,
|
||||
|
||||
@@ -41,6 +41,9 @@ void main() {
|
||||
});
|
||||
|
||||
group('Player-Group Tests', () {
|
||||
/// No need to test if group has players since the members attribute is
|
||||
/// not nullable
|
||||
|
||||
test('Adding a player to a group works correctly', () async {
|
||||
await database.groupDao.addGroup(group: testgroup);
|
||||
await database.playerDao.addPlayer(player: player4);
|
||||
|
||||
Reference in New Issue
Block a user