Refactoring
This commit is contained in:
@@ -117,14 +117,14 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
|
|
||||||
/* Update */
|
/* Update */
|
||||||
|
|
||||||
/// Updates the name of the game with the given [gameId] to [newName].
|
/// Updates the name of the game with the given [gameId] to [name].
|
||||||
Future<bool> updateGameName({
|
Future<bool> updateGameName({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required String newName,
|
required String name,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(name: Value(newName)),
|
GameTableCompanion(name: Value(name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
@@ -132,11 +132,11 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
/// Updates the ruleset of the game with the given [gameId].
|
/// Updates the ruleset of the game with the given [gameId].
|
||||||
Future<bool> updateGameRuleset({
|
Future<bool> updateGameRuleset({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required Ruleset newRuleset,
|
required Ruleset ruleset,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(ruleset: Value(newRuleset.name)),
|
GameTableCompanion(ruleset: Value(ruleset.name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
@@ -144,11 +144,11 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
/// Updates the description of the game with the given [gameId].
|
/// Updates the description of the game with the given [gameId].
|
||||||
Future<bool> updateGameDescription({
|
Future<bool> updateGameDescription({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required String newDescription,
|
required String description,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(description: Value(newDescription)),
|
GameTableCompanion(description: Value(description)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
@@ -156,11 +156,11 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
/// Updates the color of the game with the given [gameId].
|
/// Updates the color of the game with the given [gameId].
|
||||||
Future<bool> updateGameColor({
|
Future<bool> updateGameColor({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required GameColor newColor,
|
required GameColor color,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(color: Value(newColor.name)),
|
GameTableCompanion(color: Value(color.name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
@@ -168,11 +168,11 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
/// Updates the icon of the game with the given [gameId].
|
/// Updates the icon of the game with the given [gameId].
|
||||||
Future<bool> updateGameIcon({
|
Future<bool> updateGameIcon({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required String newIcon,
|
required String icon,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(icon: Value(newIcon)),
|
GameTableCompanion(icon: Value(icon)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,28 +213,28 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
|||||||
|
|
||||||
/* Update */
|
/* Update */
|
||||||
|
|
||||||
/// Updates the name of the group with the given [id] to [newName].
|
/// Updates the name of the group with the given [id] to [name].
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> updateGroupName({
|
Future<bool> updateGroupName({
|
||||||
required String groupId,
|
required String groupId,
|
||||||
required String newName,
|
required String name,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(
|
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(
|
||||||
GroupTableCompanion(name: Value(newName)),
|
GroupTableCompanion(name: Value(name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the description of the group with the given [groupId] to [newDescription].
|
/// Updates the description of the group with the given [groupId] to [description].
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> updateGroupDescription({
|
Future<bool> updateGroupDescription({
|
||||||
required String groupId,
|
required String groupId,
|
||||||
required String newDescription,
|
required String description,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(
|
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(
|
||||||
GroupTableCompanion(description: Value(newDescription)),
|
GroupTableCompanion(description: Value(description)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,30 +395,30 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
|
|
||||||
/* Update */
|
/* Update */
|
||||||
|
|
||||||
/// Changes the name of the match with the given [matchId] to [newName].
|
/// Changes the name of the match with the given [matchId] to [name].
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> updateMatchName({
|
Future<bool> updateMatchName({
|
||||||
required String matchId,
|
required String matchId,
|
||||||
required String newName,
|
required String name,
|
||||||
}) async {
|
}) async {
|
||||||
final query = update(matchTable)..where((g) => g.id.equals(matchId));
|
final query = update(matchTable)..where((g) => g.id.equals(matchId));
|
||||||
final rowsAffected = await query.write(
|
final rowsAffected = await query.write(
|
||||||
MatchTableCompanion(name: Value(newName)),
|
MatchTableCompanion(name: Value(name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the group of the match with the given [matchId].
|
/// Updates the group of the match with the given [matchId].
|
||||||
/// Replaces the existing group association with the new group specified by [newGroupId].
|
/// Replaces the existing group association with the new group specified by [groupId].
|
||||||
/// Pass null to remove the group association.
|
/// Pass null to remove the group association.
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> updateMatchGroup({
|
Future<bool> updateMatchGroup({
|
||||||
required String matchId,
|
required String matchId,
|
||||||
required String? newGroupId,
|
required String? groupId,
|
||||||
}) async {
|
}) async {
|
||||||
final query = update(matchTable)..where((g) => g.id.equals(matchId));
|
final query = update(matchTable)..where((g) => g.id.equals(matchId));
|
||||||
final rowsAffected = await query.write(
|
final rowsAffected = await query.write(
|
||||||
MatchTableCompanion(groupId: Value(newGroupId)),
|
MatchTableCompanion(groupId: Value(groupId)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,10 +158,10 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
|
|
||||||
/* Update */
|
/* Update */
|
||||||
|
|
||||||
/// Updates the name of the player with the given [playerId] to [newName].
|
/// Updates the name of the player with the given [playerId] to [name].
|
||||||
Future<bool> updatePlayerName({
|
Future<bool> updatePlayerName({
|
||||||
required String playerId,
|
required String playerId,
|
||||||
required String newName,
|
required String name,
|
||||||
}) async {
|
}) async {
|
||||||
// Get previous name and name count for the player before updating
|
// Get previous name and name count for the player before updating
|
||||||
final previousPlayerName =
|
final previousPlayerName =
|
||||||
@@ -173,13 +173,13 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
|
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(playerTable)..where((p) => p.id.equals(playerId))).write(
|
await (update(playerTable)..where((p) => p.id.equals(playerId))).write(
|
||||||
PlayerTableCompanion(name: Value(newName)),
|
PlayerTableCompanion(name: Value(name)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update name count for the new name
|
// Update name count for the new name
|
||||||
final count = await calculateNameCount(name: newName);
|
final count = await calculateNameCount(name: name);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
await (update(playerTable)..where((p) => p.name.equals(newName))).write(
|
await (update(playerTable)..where((p) => p.name.equals(name))).write(
|
||||||
PlayerTableCompanion(nameCount: Value(count)),
|
PlayerTableCompanion(nameCount: Value(count)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -200,15 +200,15 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the description of the player with the given [playerId] to
|
/// Updates the description of the player with the given [playerId] to
|
||||||
/// [newDescription].
|
/// [description].
|
||||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||||
Future<bool> updatePlayerDescription({
|
Future<bool> updatePlayerDescription({
|
||||||
required String playerId,
|
required String playerId,
|
||||||
required String newDescription,
|
required String description,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(playerTable)..where((g) => g.id.equals(playerId))).write(
|
await (update(playerTable)..where((g) => g.id.equals(playerId))).write(
|
||||||
PlayerTableCompanion(description: Value(newDescription)),
|
PlayerTableCompanion(description: Value(description)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,18 +116,18 @@ class PlayerMatchDao extends DatabaseAccessor<AppDatabase>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the players associated with a match based on the provided
|
/// Updates the players associated with a match based on the provided
|
||||||
/// [newPlayer] list. It adds new players and removes players that are no
|
/// [player] list. It adds new players and removes players that are no
|
||||||
/// longer associated with the match.
|
/// longer associated with the match.
|
||||||
Future<bool> updateMatchPlayers({
|
Future<bool> updateMatchPlayers({
|
||||||
required String matchId,
|
required String matchId,
|
||||||
required List<Player> newPlayer,
|
required List<Player> player,
|
||||||
}) async {
|
}) async {
|
||||||
if (newPlayer.isEmpty) return false;
|
if (player.isEmpty) return false;
|
||||||
|
|
||||||
final currentPlayers = await getPlayersOfMatch(matchId: matchId);
|
final currentPlayers = await getPlayersOfMatch(matchId: matchId);
|
||||||
// Create sets of player IDs for easy comparison
|
// Create sets of player IDs for easy comparison
|
||||||
final currentPlayerIds = currentPlayers.map((p) => p.id).toSet();
|
final currentPlayerIds = currentPlayers.map((p) => p.id).toSet();
|
||||||
final newPlayerIdsSet = newPlayer.map((p) => p.id).toSet();
|
final newPlayerIdsSet = player.map((p) => p.id).toSet();
|
||||||
|
|
||||||
// Are the current and new player identical?
|
// Are the current and new player identical?
|
||||||
if (currentPlayerIds.containsAll(newPlayerIdsSet) &&
|
if (currentPlayerIds.containsAll(newPlayerIdsSet) &&
|
||||||
|
|||||||
@@ -162,19 +162,19 @@ class ScoreEntryDao extends DatabaseAccessor<AppDatabase>
|
|||||||
Future<bool> updateScore({
|
Future<bool> updateScore({
|
||||||
required String playerId,
|
required String playerId,
|
||||||
required String matchId,
|
required String matchId,
|
||||||
required ScoreEntry newEntry,
|
required ScoreEntry entry,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(scoreEntryTable)..where(
|
await (update(scoreEntryTable)..where(
|
||||||
(s) =>
|
(s) =>
|
||||||
s.playerId.equals(playerId) &
|
s.playerId.equals(playerId) &
|
||||||
s.matchId.equals(matchId) &
|
s.matchId.equals(matchId) &
|
||||||
s.roundNumber.equals(newEntry.roundNumber),
|
s.roundNumber.equals(entry.roundNumber),
|
||||||
))
|
))
|
||||||
.write(
|
.write(
|
||||||
ScoreEntryTableCompanion(
|
ScoreEntryTableCompanion(
|
||||||
score: Value(newEntry.score),
|
score: Value(entry.score),
|
||||||
change: Value(newEntry.change),
|
change: Value(entry.change),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
|
|||||||
@@ -153,11 +153,11 @@ class TeamDao extends DatabaseAccessor<AppDatabase> with _$TeamDaoMixin {
|
|||||||
/// Updates the name of the team with the given [teamId].
|
/// Updates the name of the team with the given [teamId].
|
||||||
Future<bool> updateTeamName({
|
Future<bool> updateTeamName({
|
||||||
required String teamId,
|
required String teamId,
|
||||||
required String newName,
|
required String name,
|
||||||
}) async {
|
}) async {
|
||||||
final rowsAffected =
|
final rowsAffected =
|
||||||
await (update(teamTable)..where((t) => t.id.equals(teamId))).write(
|
await (update(teamTable)..where((t) => t.id.equals(teamId))).write(
|
||||||
TeamTableCompanion(name: Value(newName)),
|
TeamTableCompanion(name: Value(name)),
|
||||||
);
|
);
|
||||||
return rowsAffected > 0;
|
return rowsAffected > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
if (widget.groupToEdit!.name != groupName) {
|
if (widget.groupToEdit!.name != groupName) {
|
||||||
successfullNameChange = await db.groupDao.updateGroupName(
|
successfullNameChange = await db.groupDao.updateGroupName(
|
||||||
groupId: widget.groupToEdit!.id,
|
groupId: widget.groupToEdit!.id,
|
||||||
newName: groupName,
|
name: groupName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -271,14 +271,14 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
if (widget.matchToEdit!.name != updatedMatch.name) {
|
if (widget.matchToEdit!.name != updatedMatch.name) {
|
||||||
await db.matchDao.updateMatchName(
|
await db.matchDao.updateMatchName(
|
||||||
matchId: widget.matchToEdit!.id,
|
matchId: widget.matchToEdit!.id,
|
||||||
newName: updatedMatch.name,
|
name: updatedMatch.name,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.matchToEdit!.group?.id != updatedMatch.group?.id) {
|
if (widget.matchToEdit!.group?.id != updatedMatch.group?.id) {
|
||||||
await db.matchDao.updateMatchGroup(
|
await db.matchDao.updateMatchGroup(
|
||||||
matchId: widget.matchToEdit!.id,
|
matchId: widget.matchToEdit!.id,
|
||||||
newGroupId: updatedMatch.group?.id,
|
groupId: updatedMatch.group?.id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ void main() {
|
|||||||
const newName = 'New name';
|
const newName = 'New name';
|
||||||
await database.groupDao.updateGroupName(
|
await database.groupDao.updateGroupName(
|
||||||
groupId: testGroup1.id,
|
groupId: testGroup1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
final result = await database.groupDao.getGroupById(
|
final result = await database.groupDao.getGroupById(
|
||||||
@@ -223,7 +223,7 @@ void main() {
|
|||||||
test('updateGroupName() returns false for non-existent group', () async {
|
test('updateGroupName() returns false for non-existent group', () async {
|
||||||
final updated = await database.groupDao.updateGroupName(
|
final updated = await database.groupDao.updateGroupName(
|
||||||
groupId: 'non-existent-id',
|
groupId: 'non-existent-id',
|
||||||
newName: 'New name',
|
name: 'New name',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
});
|
});
|
||||||
@@ -234,7 +234,7 @@ void main() {
|
|||||||
const newDescription = 'New description';
|
const newDescription = 'New description';
|
||||||
final updated = await database.groupDao.updateGroupDescription(
|
final updated = await database.groupDao.updateGroupDescription(
|
||||||
groupId: testGroup1.id,
|
groupId: testGroup1.id,
|
||||||
newDescription: newDescription,
|
description: newDescription,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ void main() {
|
|||||||
() async {
|
() async {
|
||||||
final updated = await database.groupDao.updateGroupDescription(
|
final updated = await database.groupDao.updateGroupDescription(
|
||||||
groupId: 'non-existent-id',
|
groupId: 'non-existent-id',
|
||||||
newDescription: 'New description',
|
description: 'New description',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
},
|
},
|
||||||
@@ -262,11 +262,11 @@ void main() {
|
|||||||
|
|
||||||
await database.groupDao.updateGroupName(
|
await database.groupDao.updateGroupName(
|
||||||
groupId: testGroup1.id,
|
groupId: testGroup1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
await database.groupDao.updateGroupDescription(
|
await database.groupDao.updateGroupDescription(
|
||||||
groupId: testGroup1.id,
|
groupId: testGroup1.id,
|
||||||
newDescription: newDescription,
|
description: newDescription,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedGroup = await database.groupDao.getGroupById(
|
final updatedGroup = await database.groupDao.getGroupById(
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ void main() {
|
|||||||
const newName = 'New name';
|
const newName = 'New name';
|
||||||
await database.matchDao.updateMatchName(
|
await database.matchDao.updateMatchName(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
final fetchedMatch = await database.matchDao.getMatchById(
|
final fetchedMatch = await database.matchDao.getMatchById(
|
||||||
@@ -280,7 +280,7 @@ void main() {
|
|||||||
test('updateMatchName() does nothing for non-existent match', () async {
|
test('updateMatchName() does nothing for non-existent match', () async {
|
||||||
final updated = await database.matchDao.updateMatchName(
|
final updated = await database.matchDao.updateMatchName(
|
||||||
matchId: 'non-existing-id',
|
matchId: 'non-existing-id',
|
||||||
newName: 'New Name',
|
name: 'New Name',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ void main() {
|
|||||||
|
|
||||||
await database.matchDao.updateMatchGroup(
|
await database.matchDao.updateMatchGroup(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newGroupId: testGroup2.id,
|
groupId: testGroup2.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
final fetchedMatch = await database.matchDao.getMatchById(
|
final fetchedMatch = await database.matchDao.getMatchById(
|
||||||
@@ -306,7 +306,7 @@ void main() {
|
|||||||
test('updateMatchGroup() does nothing for non-existent match', () async {
|
test('updateMatchGroup() does nothing for non-existent match', () async {
|
||||||
final updated = await database.matchDao.updateMatchGroup(
|
final updated = await database.matchDao.updateMatchGroup(
|
||||||
matchId: 'non-existing-id',
|
matchId: 'non-existing-id',
|
||||||
newGroupId: 'group-id',
|
groupId: 'group-id',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ void main() {
|
|||||||
const newName = 'New name';
|
const newName = 'New name';
|
||||||
await database.matchDao.updateMatchName(
|
await database.matchDao.updateMatchName(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
final fetchedMatch = await database.matchDao.getMatchById(
|
final fetchedMatch = await database.matchDao.getMatchById(
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ void main() {
|
|||||||
const newName = 'New name';
|
const newName = 'New name';
|
||||||
await database.teamDao.updateTeamName(
|
await database.teamDao.updateTeamName(
|
||||||
teamId: testTeam1.id,
|
teamId: testTeam1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
fetchedTeam = await database.teamDao.getTeamById(teamId: testTeam1.id);
|
fetchedTeam = await database.teamDao.getTeamById(teamId: testTeam1.id);
|
||||||
@@ -273,7 +273,7 @@ void main() {
|
|||||||
test('updateTeamName() does nothing for non-existent team', () async {
|
test('updateTeamName() does nothing for non-existent team', () async {
|
||||||
final updated = await database.teamDao.updateTeamName(
|
final updated = await database.teamDao.updateTeamName(
|
||||||
teamId: 'non-existing-id',
|
teamId: 'non-existing-id',
|
||||||
newName: 'New Name',
|
name: 'New Name',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.gameDao.updateGameName(
|
final updated = await database.gameDao.updateGameName(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ void main() {
|
|||||||
test('updateGameName() does nothing for non-existent game', () async {
|
test('updateGameName() does nothing for non-existent game', () async {
|
||||||
final updated = await database.gameDao.updateGameName(
|
final updated = await database.gameDao.updateGameName(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newName: 'New name',
|
name: 'New name',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.gameDao.updateGameRuleset(
|
final updated = await database.gameDao.updateGameRuleset(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newRuleset: ruleset,
|
ruleset: ruleset,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ void main() {
|
|||||||
test('updateGameRuleset() does nothing for non-existent game', () async {
|
test('updateGameRuleset() does nothing for non-existent game', () async {
|
||||||
final updated = await database.gameDao.updateGameRuleset(
|
final updated = await database.gameDao.updateGameRuleset(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newRuleset: Ruleset.lowestScore,
|
ruleset: Ruleset.lowestScore,
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.gameDao.updateGameDescription(
|
final updated = await database.gameDao.updateGameDescription(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newDescription: newDescription,
|
description: newDescription,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ void main() {
|
|||||||
() async {
|
() async {
|
||||||
final updated = await database.gameDao.updateGameDescription(
|
final updated = await database.gameDao.updateGameDescription(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newDescription: 'New description',
|
description: 'New description',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ void main() {
|
|||||||
|
|
||||||
await database.gameDao.updateGameColor(
|
await database.gameDao.updateGameColor(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newColor: GameColor.green,
|
color: GameColor.green,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedGame = await database.gameDao.getGameById(
|
final updatedGame = await database.gameDao.getGameById(
|
||||||
@@ -292,7 +292,7 @@ void main() {
|
|||||||
test('updateGameColor() does nothing for non-existent game', () async {
|
test('updateGameColor() does nothing for non-existent game', () async {
|
||||||
final updated = await database.gameDao.updateGameColor(
|
final updated = await database.gameDao.updateGameColor(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newColor: GameColor.green,
|
color: GameColor.green,
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.gameDao.updateGameIcon(
|
final updated = await database.gameDao.updateGameIcon(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newIcon: newIcon,
|
icon: newIcon,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -319,7 +319,7 @@ void main() {
|
|||||||
test('updateGameIcon() does nothing for non-existent game', () async {
|
test('updateGameIcon() does nothing for non-existent game', () async {
|
||||||
final updated = await database.gameDao.updateGameIcon(
|
final updated = await database.gameDao.updateGameIcon(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newIcon: 'New icon',
|
icon: 'New icon',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -333,19 +333,19 @@ void main() {
|
|||||||
const newName = 'New name';
|
const newName = 'New name';
|
||||||
await database.gameDao.updateGameName(
|
await database.gameDao.updateGameName(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
const newGameColor = GameColor.teal;
|
const newGameColor = GameColor.teal;
|
||||||
await database.gameDao.updateGameColor(
|
await database.gameDao.updateGameColor(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newColor: newGameColor,
|
color: newGameColor,
|
||||||
);
|
);
|
||||||
|
|
||||||
const newDescription = 'New description';
|
const newDescription = 'New description';
|
||||||
await database.gameDao.updateGameDescription(
|
await database.gameDao.updateGameDescription(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newDescription: newDescription,
|
description: newDescription,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedGame = await database.gameDao.getGameById(
|
final updatedGame = await database.gameDao.getGameById(
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ void main() {
|
|||||||
|
|
||||||
await database.playerDao.updatePlayerName(
|
await database.playerDao.updatePlayerName(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
newName: newName,
|
name: newName,
|
||||||
);
|
);
|
||||||
|
|
||||||
final player = await database.playerDao.getPlayerById(
|
final player = await database.playerDao.getPlayerById(
|
||||||
@@ -225,7 +225,7 @@ void main() {
|
|||||||
test('updatePlayerName() does nothing for non-existent player', () async {
|
test('updatePlayerName() does nothing for non-existent player', () async {
|
||||||
final updated = await database.playerDao.updatePlayerName(
|
final updated = await database.playerDao.updatePlayerName(
|
||||||
playerId: 'non-existent-id',
|
playerId: 'non-existent-id',
|
||||||
newName: 'New name',
|
name: 'New name',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.playerDao.updatePlayerDescription(
|
final updated = await database.playerDao.updatePlayerDescription(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
newDescription: newDescription,
|
description: newDescription,
|
||||||
);
|
);
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ void main() {
|
|||||||
() async {
|
() async {
|
||||||
final updated = await database.playerDao.updatePlayerDescription(
|
final updated = await database.playerDao.updatePlayerDescription(
|
||||||
playerId: 'non-existent-id',
|
playerId: 'non-existent-id',
|
||||||
newDescription: 'New description',
|
description: 'New description',
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ void main() {
|
|||||||
|
|
||||||
await database.playerDao.updatePlayerName(
|
await database.playerDao.updatePlayerName(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
newName: 'First Update',
|
name: 'First Update',
|
||||||
);
|
);
|
||||||
|
|
||||||
var fetchedPlayer = await database.playerDao.getPlayerById(
|
var fetchedPlayer = await database.playerDao.getPlayerById(
|
||||||
@@ -279,7 +279,7 @@ void main() {
|
|||||||
|
|
||||||
await database.playerDao.updatePlayerName(
|
await database.playerDao.updatePlayerName(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
newName: 'Second Update',
|
name: 'Second Update',
|
||||||
);
|
);
|
||||||
|
|
||||||
fetchedPlayer = await database.playerDao.getPlayerById(
|
fetchedPlayer = await database.playerDao.getPlayerById(
|
||||||
@@ -289,7 +289,7 @@ void main() {
|
|||||||
|
|
||||||
await database.playerDao.updatePlayerDescription(
|
await database.playerDao.updatePlayerDescription(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
newDescription: 'Third Update',
|
description: 'Third Update',
|
||||||
);
|
);
|
||||||
|
|
||||||
fetchedPlayer = await database.playerDao.getPlayerById(
|
fetchedPlayer = await database.playerDao.getPlayerById(
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ void main() {
|
|||||||
|
|
||||||
await database.playerMatchDao.updateMatchPlayers(
|
await database.playerMatchDao.updateMatchPlayers(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newPlayer: newPlayers,
|
player: newPlayers,
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedPlayers = await database.playerMatchDao.getPlayersOfMatch(
|
final updatedPlayers = await database.playerMatchDao.getPlayersOfMatch(
|
||||||
@@ -337,7 +337,7 @@ void main() {
|
|||||||
final newPlayersList = [testPlayer1, testPlayer2];
|
final newPlayersList = [testPlayer1, testPlayer2];
|
||||||
await database.playerMatchDao.updateMatchPlayers(
|
await database.playerMatchDao.updateMatchPlayers(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newPlayer: newPlayersList,
|
player: newPlayersList,
|
||||||
);
|
);
|
||||||
|
|
||||||
matchPlayers = await database.matchDao.getMatchById(
|
matchPlayers = await database.matchDao.getMatchById(
|
||||||
@@ -356,7 +356,7 @@ void main() {
|
|||||||
|
|
||||||
final updated = await database.playerMatchDao.updateMatchPlayers(
|
final updated = await database.playerMatchDao.updateMatchPlayers(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newPlayer: originalPlayers,
|
player: originalPlayers,
|
||||||
);
|
);
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ void main() {
|
|||||||
await database.matchDao.addMatch(match: testMatch1);
|
await database.matchDao.addMatch(match: testMatch1);
|
||||||
final updated = await database.playerMatchDao.updateMatchPlayers(
|
final updated = await database.playerMatchDao.updateMatchPlayers(
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newPlayer: [],
|
player: [],
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ void main() {
|
|||||||
final updated = await database.scoreEntryDao.updateScore(
|
final updated = await database.scoreEntryDao.updateScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newEntry: newEntry,
|
entry: newEntry,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(updated, isTrue);
|
expect(updated, isTrue);
|
||||||
@@ -455,7 +455,7 @@ void main() {
|
|||||||
final updated = await database.scoreEntryDao.updateScore(
|
final updated = await database.scoreEntryDao.updateScore(
|
||||||
playerId: testPlayer1.id,
|
playerId: testPlayer1.id,
|
||||||
matchId: testMatch1.id,
|
matchId: testMatch1.id,
|
||||||
newEntry: entryRound1,
|
entry: entryRound1,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(updated, isFalse);
|
expect(updated, isFalse);
|
||||||
|
|||||||
Reference in New Issue
Block a user