Merge branch 'development' into feature/31-json-import-fuer-testdaten
This commit is contained in:
@@ -19,12 +19,12 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
return Future.wait(
|
||||
result.map((row) async {
|
||||
final group = await db.groupGameDao.getGroupOfGame(gameId: row.id);
|
||||
final player = await db.playerGameDao.getPlayersOfGame(gameId: row.id);
|
||||
final players = await db.playerGameDao.getPlayersOfGame(gameId: row.id);
|
||||
return Game(
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
group: group,
|
||||
players: player,
|
||||
players: players,
|
||||
createdAt: row.createdAt,
|
||||
winner: row.winnerId,
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ class PlayerGroupDao extends DatabaseAccessor<AppDatabase>
|
||||
return false;
|
||||
}
|
||||
|
||||
if (await db.playerDao.playerExists(playerId: player.id) == false) {
|
||||
if (!await db.playerDao.playerExists(playerId: player.id)) {
|
||||
db.playerDao.addPlayer(player: player);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,52 +117,47 @@ void main() {
|
||||
};
|
||||
|
||||
for (final game in allGames) {
|
||||
final expectedGame = testGames[game.id]!;
|
||||
final testGame = testGames[game.id]!;
|
||||
|
||||
// Game-Checks
|
||||
expect(game.id, expectedGame.id);
|
||||
expect(game.name, expectedGame.name);
|
||||
expect(game.createdAt, expectedGame.createdAt);
|
||||
expect(game.winner, expectedGame.winner);
|
||||
expect(game.id, testGame.id);
|
||||
expect(game.name, testGame.name);
|
||||
expect(game.createdAt, testGame.createdAt);
|
||||
expect(game.winner, testGame.winner);
|
||||
|
||||
// Group-Checks
|
||||
if (expectedGame.group != null) {
|
||||
expect(game.group!.id, expectedGame.group!.id);
|
||||
expect(game.group!.name, expectedGame.group!.name);
|
||||
expect(game.group!.createdAt, expectedGame.group!.createdAt);
|
||||
if (testGame.group != null) {
|
||||
expect(game.group!.id, testGame.group!.id);
|
||||
expect(game.group!.name, testGame.group!.name);
|
||||
expect(game.group!.createdAt, testGame.group!.createdAt);
|
||||
|
||||
// Group Members-Checks
|
||||
expect(
|
||||
game.group!.members.length,
|
||||
expectedGame.group!.members.length,
|
||||
);
|
||||
for (int i = 0; i < expectedGame.group!.members.length; i++) {
|
||||
expect(
|
||||
game.group!.members[i].id,
|
||||
expectedGame.group!.members[i].id,
|
||||
);
|
||||
expect(game.group!.members.length, testGame.group!.members.length);
|
||||
for (int i = 0; i < testGame.group!.members.length; i++) {
|
||||
expect(game.group!.members[i].id, testGame.group!.members[i].id);
|
||||
expect(
|
||||
game.group!.members[i].name,
|
||||
expectedGame.group!.members[i].name,
|
||||
testGame.group!.members[i].name,
|
||||
);
|
||||
expect(
|
||||
game.group!.members[i].createdAt,
|
||||
expectedGame.group!.members[i].createdAt,
|
||||
testGame.group!.members[i].createdAt,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
expect(game.group, null);
|
||||
}
|
||||
|
||||
// Players-Checks
|
||||
if (expectedGame.players != null) {
|
||||
expect(game.players!.length, expectedGame.players!.length);
|
||||
for (int i = 0; i < expectedGame.players!.length; i++) {
|
||||
expect(game.players![i].id, expectedGame.players![i].id);
|
||||
expect(game.players![i].name, expectedGame.players![i].name);
|
||||
expect(
|
||||
game.players![i].createdAt,
|
||||
expectedGame.players![i].createdAt,
|
||||
);
|
||||
if (testGame.players != null) {
|
||||
expect(game.players!.length, testGame.players!.length);
|
||||
for (int i = 0; i < testGame.players!.length; i++) {
|
||||
expect(game.players![i].id, testGame.players![i].id);
|
||||
expect(game.players![i].name, testGame.players![i].name);
|
||||
expect(game.players![i].createdAt, testGame.players![i].createdAt);
|
||||
}
|
||||
} else {
|
||||
expect(game.players, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,20 +91,17 @@ void main() {
|
||||
final testGroups = {testGroup1.id: testGroup1, testGroup2.id: testGroup2};
|
||||
|
||||
for (final group in allGroups) {
|
||||
final expectedGroup = testGroups[group.id]!;
|
||||
final testGroup = testGroups[group.id]!;
|
||||
|
||||
expect(group.id, expectedGroup.id);
|
||||
expect(group.name, expectedGroup.name);
|
||||
expect(group.createdAt, expectedGroup.createdAt);
|
||||
expect(group.id, testGroup.id);
|
||||
expect(group.name, testGroup.name);
|
||||
expect(group.createdAt, testGroup.createdAt);
|
||||
|
||||
expect(group.members.length, expectedGroup.members.length);
|
||||
for (int i = 0; i < expectedGroup.members.length; i++) {
|
||||
expect(group.members[i].id, expectedGroup.members[i].id);
|
||||
expect(group.members[i].name, expectedGroup.members[i].name);
|
||||
expect(
|
||||
group.members[i].createdAt,
|
||||
expectedGroup.members[i].createdAt,
|
||||
);
|
||||
expect(group.members.length, testGroup.members.length);
|
||||
for (int i = 0; i < testGroup.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ void main() {
|
||||
expect(allPlayers.length, 4);
|
||||
|
||||
// Map for connencting fetched players with expected players
|
||||
final testPlayer = {
|
||||
final testPlayers = {
|
||||
testPlayer1.id: testPlayer1,
|
||||
testPlayer2.id: testPlayer2,
|
||||
testPlayer3.id: testPlayer3,
|
||||
@@ -72,11 +72,11 @@ void main() {
|
||||
};
|
||||
|
||||
for (final player in allPlayers) {
|
||||
final expectedPlayer = testPlayer[player.id]!;
|
||||
final testPlayer = testPlayers[player.id]!;
|
||||
|
||||
expect(player.id, expectedPlayer.id);
|
||||
expect(player.name, expectedPlayer.name);
|
||||
expect(player.createdAt, expectedPlayer.createdAt);
|
||||
expect(player.id, testPlayer.id);
|
||||
expect(player.name, testPlayer.name);
|
||||
expect(player.createdAt, testPlayer.createdAt);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user