all parameters are now required
This commit is contained in:
@@ -44,6 +44,7 @@ void main() {
|
||||
ruleset: Ruleset.highestScore,
|
||||
description: 'A board game about real estate',
|
||||
color: '0xFF000000',
|
||||
icon: '',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -133,7 +134,7 @@ void main() {
|
||||
|
||||
// Verifies that a game with null optional fields can be added and retrieved.
|
||||
test('addGame handles game with null optional fields', () async {
|
||||
final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000');
|
||||
final gameWithNulls = Game(name: 'Simple Game', ruleset: Ruleset.lowestScore, description: 'A simple game', color: '0xFF000000', icon: '');
|
||||
final result = await database.gameDao.addGame(game: gameWithNulls);
|
||||
expect(result, true);
|
||||
|
||||
@@ -374,19 +375,19 @@ void main() {
|
||||
expect(updatedGame.icon, 'new_chess_icon');
|
||||
});
|
||||
|
||||
// Verifies that updateGameIcon can set the icon to null.
|
||||
test('updateGameIcon can set icon to null', () async {
|
||||
// Verifies that updateGameIcon can update the icon.
|
||||
test('updateGameIcon updates icon correctly', () async {
|
||||
await database.gameDao.addGame(game: testGame1);
|
||||
|
||||
await database.gameDao.updateGameIcon(
|
||||
gameId: testGame1.id,
|
||||
newIcon: null,
|
||||
newIcon: 'new_icon',
|
||||
);
|
||||
|
||||
final updatedGame = await database.gameDao.getGameById(
|
||||
gameId: testGame1.id,
|
||||
);
|
||||
expect(updatedGame.icon, isNull);
|
||||
expect(updatedGame.icon, 'new_icon');
|
||||
});
|
||||
|
||||
// Verifies that updateGameIcon does nothing when game doesn't exist.
|
||||
@@ -460,6 +461,7 @@ void main() {
|
||||
ruleset: Ruleset.multipleWinners,
|
||||
description: 'Description with émojis 🎮🎲',
|
||||
color: '0xFF000000',
|
||||
icon: '',
|
||||
);
|
||||
await database.gameDao.addGame(game: specialGame);
|
||||
|
||||
@@ -498,6 +500,7 @@ void main() {
|
||||
description: longString,
|
||||
ruleset: Ruleset.multipleWinners,
|
||||
color: '0xFF000000',
|
||||
icon: '',
|
||||
);
|
||||
await database.gameDao.addGame(game: longGame);
|
||||
|
||||
|
||||
@@ -29,27 +29,31 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
testGroup1 = Group(
|
||||
name: 'Test Group',
|
||||
description: '',
|
||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||
);
|
||||
testGroup2 = Group(
|
||||
id: 'gr2',
|
||||
name: 'Second Group',
|
||||
description: '',
|
||||
members: [testPlayer2, testPlayer3, testPlayer4],
|
||||
);
|
||||
testGroup3 = Group(
|
||||
id: 'gr2',
|
||||
name: 'Second Group',
|
||||
description: '',
|
||||
members: [testPlayer2, testPlayer4],
|
||||
);
|
||||
testGroup4 = Group(
|
||||
id: 'gr2',
|
||||
name: 'Second Group',
|
||||
description: '',
|
||||
members: [testPlayer1, testPlayer2, testPlayer3, testPlayer4],
|
||||
);
|
||||
});
|
||||
@@ -262,14 +266,14 @@ void main() {
|
||||
|
||||
final updated = await database.groupDao.updateGroupDescription(
|
||||
groupId: groupWithDescription.id,
|
||||
newDescription: null,
|
||||
newDescription: 'Updated description',
|
||||
);
|
||||
expect(updated, true);
|
||||
|
||||
final result = await database.groupDao.getGroupById(
|
||||
groupId: groupWithDescription.id,
|
||||
);
|
||||
expect(result.description, isNull);
|
||||
expect(result.description, 'Updated description');
|
||||
});
|
||||
|
||||
// Verifies that updateGroupDescription returns false for a non-existent group.
|
||||
@@ -324,6 +328,7 @@ void main() {
|
||||
test('Group with empty members list is stored correctly', () async {
|
||||
final emptyGroup = Group(
|
||||
name: 'Empty Group',
|
||||
description: '',
|
||||
members: [],
|
||||
);
|
||||
await database.groupDao.addGroup(group: emptyGroup);
|
||||
|
||||
@@ -36,26 +36,29 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer5 = Player(name: 'Eve');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
testPlayer5 = Player(name: 'Eve', description: '');
|
||||
testGroup1 = Group(
|
||||
name: 'Test Group 2',
|
||||
description: '',
|
||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||
);
|
||||
testGroup2 = Group(
|
||||
name: 'Test Group 2',
|
||||
description: '',
|
||||
members: [testPlayer4, testPlayer5],
|
||||
);
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
|
||||
testMatch1 = Match(
|
||||
name: 'First Test Match',
|
||||
game: testGame,
|
||||
group: testGroup1,
|
||||
players: [testPlayer4, testPlayer5],
|
||||
winner: testPlayer4,
|
||||
notes: '',
|
||||
);
|
||||
testMatch2 = Match(
|
||||
name: 'Second Test Match',
|
||||
@@ -63,17 +66,20 @@ void main() {
|
||||
group: testGroup2,
|
||||
players: [testPlayer1, testPlayer2, testPlayer3],
|
||||
winner: testPlayer2,
|
||||
notes: '',
|
||||
);
|
||||
testMatchOnlyPlayers = Match(
|
||||
name: 'Test Match with Players',
|
||||
game: testGame,
|
||||
players: [testPlayer1, testPlayer2, testPlayer3],
|
||||
winner: testPlayer3,
|
||||
notes: '',
|
||||
);
|
||||
testMatchOnlyGroup = Match(
|
||||
name: 'Test Match with Group',
|
||||
game: testGame,
|
||||
group: testGroup2,
|
||||
notes: '',
|
||||
);
|
||||
});
|
||||
await database.playerDao.addPlayersAsList(
|
||||
|
||||
@@ -26,12 +26,13 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
testGroup = Group(
|
||||
name: 'Test Group',
|
||||
description: '',
|
||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||
);
|
||||
});
|
||||
@@ -186,7 +187,7 @@ void main() {
|
||||
|
||||
// Verifies that getPlayersOfGroup returns empty list for group with no members.
|
||||
test('getPlayersOfGroup returns empty list for empty group', () async {
|
||||
final emptyGroup = Group(name: 'Empty Group', members: []);
|
||||
final emptyGroup = Group(name: 'Empty Group', description: '', members: []);
|
||||
await database.groupDao.addGroup(group: emptyGroup);
|
||||
|
||||
final players = await database.playerGroupDao.getPlayersOfGroup(
|
||||
@@ -230,7 +231,7 @@ void main() {
|
||||
|
||||
// Verifies that a player can be in multiple groups.
|
||||
test('Player can be in multiple groups', () async {
|
||||
final secondGroup = Group(name: 'Second Group', members: []);
|
||||
final secondGroup = Group(name: 'Second Group', description: '', members: []);
|
||||
await database.groupDao.addGroup(group: testGroup);
|
||||
await database.groupDao.addGroup(group: secondGroup);
|
||||
|
||||
@@ -255,7 +256,7 @@ void main() {
|
||||
|
||||
// Verifies that removing player from one group doesn't affect other groups.
|
||||
test('Removing player from one group does not affect other groups', () async {
|
||||
final secondGroup = Group(name: 'Second Group', members: [testPlayer1]);
|
||||
final secondGroup = Group(name: 'Second Group', description: '', members: [testPlayer1]);
|
||||
await database.groupDao.addGroup(group: testGroup);
|
||||
await database.groupDao.addGroup(group: secondGroup);
|
||||
|
||||
|
||||
@@ -37,26 +37,29 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer5 = Player(name: 'Eve');
|
||||
testPlayer6 = Player(name: 'Frank');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
testPlayer5 = Player(name: 'Eve', description: '');
|
||||
testPlayer6 = Player(name: 'Frank', description: '');
|
||||
testGroup = Group(
|
||||
name: 'Test Group',
|
||||
description: '',
|
||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||
);
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
|
||||
testMatchOnlyGroup = Match(
|
||||
name: 'Test Match with Group',
|
||||
game: testGame,
|
||||
group: testGroup,
|
||||
notes: '',
|
||||
);
|
||||
testMatchOnlyPlayers = Match(
|
||||
name: 'Test Match with Players',
|
||||
game: testGame,
|
||||
players: [testPlayer4, testPlayer5, testPlayer6],
|
||||
notes: '',
|
||||
);
|
||||
testTeam1 = Team(
|
||||
name: 'Team Alpha',
|
||||
@@ -226,8 +229,8 @@ void main() {
|
||||
'Adding the same player to separate matches works correctly',
|
||||
() async {
|
||||
final playersList = [testPlayer1, testPlayer2, testPlayer3];
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
|
||||
|
||||
await Future.wait([
|
||||
database.matchDao.addMatch(match: match1),
|
||||
@@ -760,8 +763,8 @@ void main() {
|
||||
// Verifies that removePlayerFromMatch does not affect other matches.
|
||||
test('removePlayerFromMatch does not affect other matches', () async {
|
||||
final playersList = [testPlayer1, testPlayer2];
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
|
||||
|
||||
await Future.wait([
|
||||
database.matchDao.addMatch(match: match1),
|
||||
@@ -793,8 +796,8 @@ void main() {
|
||||
// Verifies that updating scores for players in different matches are independent.
|
||||
test('Player scores are independent across matches', () async {
|
||||
final playersList = [testPlayer1];
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList);
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList);
|
||||
final match1 = Match(name: 'Match 1', game: testGame, players: playersList, notes: '');
|
||||
final match2 = Match(name: 'Match 2', game: testGame, players: playersList, notes: '');
|
||||
|
||||
await Future.wait([
|
||||
database.matchDao.addMatch(match: match1),
|
||||
|
||||
@@ -24,10 +24,10 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Test Player');
|
||||
testPlayer2 = Player(name: 'Second Player');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer1 = Player(name: 'Test Player', description: '');
|
||||
testPlayer2 = Player(name: 'Second Player', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
});
|
||||
});
|
||||
tearDown(() async {
|
||||
@@ -265,7 +265,7 @@ void main() {
|
||||
|
||||
// Verifies that a player with special characters in name is stored correctly.
|
||||
test('Player with special characters in name is stored correctly', () async {
|
||||
final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~');
|
||||
final specialPlayer = Player(name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~', description: '');
|
||||
|
||||
await database.playerDao.addPlayer(player: specialPlayer);
|
||||
|
||||
@@ -293,14 +293,14 @@ void main() {
|
||||
|
||||
// Verifies that a player with null description is stored correctly.
|
||||
test('Player with null description is stored correctly', () async {
|
||||
final playerWithoutDescription = Player(name: 'No Description Player');
|
||||
final playerWithoutDescription = Player(name: 'No Description Player', description: '');
|
||||
|
||||
await database.playerDao.addPlayer(player: playerWithoutDescription);
|
||||
|
||||
final fetchedPlayer = await database.playerDao.getPlayerById(
|
||||
playerId: playerWithoutDescription.id,
|
||||
);
|
||||
expect(fetchedPlayer.description, isNull);
|
||||
expect(fetchedPlayer.description, '');
|
||||
});
|
||||
|
||||
// Verifies that multiple updates to the same player work correctly.
|
||||
@@ -340,7 +340,7 @@ void main() {
|
||||
|
||||
// Verifies that a player with empty string name is stored correctly.
|
||||
test('Player with empty string name is stored correctly', () async {
|
||||
final emptyNamePlayer = Player(name: '');
|
||||
final emptyNamePlayer = Player(name: '', description: '');
|
||||
|
||||
await database.playerDao.addPlayer(player: emptyNamePlayer);
|
||||
|
||||
@@ -353,7 +353,7 @@ void main() {
|
||||
// Verifies that a player with very long name is stored correctly.
|
||||
test('Player with very long name is stored correctly', () async {
|
||||
final longName = 'A' * 1000;
|
||||
final longNamePlayer = Player(name: longName);
|
||||
final longNamePlayer = Player(name: longName, description: '');
|
||||
|
||||
await database.playerDao.addPlayer(player: longNamePlayer);
|
||||
|
||||
|
||||
@@ -29,19 +29,21 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testGame = Game(name: 'Test Game', ruleset: Ruleset.singleWinner, description: 'A test game', color: '0xFF000000', icon: '');
|
||||
testMatch1 = Match(
|
||||
name: 'Test Match 1',
|
||||
game: testGame,
|
||||
players: [testPlayer1, testPlayer2],
|
||||
notes: '',
|
||||
);
|
||||
testMatch2 = Match(
|
||||
name: 'Test Match 2',
|
||||
game: testGame,
|
||||
players: [testPlayer2, testPlayer3],
|
||||
notes: '',
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ void main() {
|
||||
);
|
||||
|
||||
withClock(fakeClock, () {
|
||||
testPlayer1 = Player(name: 'Alice');
|
||||
testPlayer2 = Player(name: 'Bob');
|
||||
testPlayer3 = Player(name: 'Charlie');
|
||||
testPlayer4 = Player(name: 'Diana');
|
||||
testPlayer1 = Player(name: 'Alice', description: '');
|
||||
testPlayer2 = Player(name: 'Bob', description: '');
|
||||
testPlayer3 = Player(name: 'Charlie', description: '');
|
||||
testPlayer4 = Player(name: 'Diana', description: '');
|
||||
testTeam1 = Team(
|
||||
name: 'Team Alpha',
|
||||
members: [testPlayer1, testPlayer2],
|
||||
@@ -49,8 +49,8 @@ void main() {
|
||||
name: 'Team Gamma',
|
||||
members: [testPlayer1, testPlayer3],
|
||||
);
|
||||
testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000');
|
||||
testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000');
|
||||
testGame1 = Game(name: 'Game 1', ruleset: Ruleset.singleWinner, description: 'Test game 1', color: '0xFF000000', icon: '');
|
||||
testGame2 = Game(name: 'Game 2', ruleset: Ruleset.highestScore, description: 'Test game 2', color: '0xFF000000', icon: '');
|
||||
});
|
||||
|
||||
await database.playerDao.addPlayersAsList(
|
||||
@@ -344,8 +344,8 @@ void main() {
|
||||
// Verifies that teams with overlapping members are independent.
|
||||
test('Teams with overlapping members are independent', () async {
|
||||
// Create two matches since player_match has primary key {playerId, matchId}
|
||||
final match1 = Match(name: 'Match 1', game: testGame1);
|
||||
final match2 = Match(name: 'Match 2', game: testGame2);
|
||||
final match1 = Match(name: 'Match 1', game: testGame1, notes: '');
|
||||
final match2 = Match(name: 'Match 2', game: testGame2, notes: '');
|
||||
await database.matchDao.addMatch(match: match1);
|
||||
await database.matchDao.addMatch(match: match2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user