Neue Datenbank Struktur #156
@@ -20,7 +20,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
name: row.name,
|
name: row.name,
|
||||||
ruleset: row.ruleset,
|
ruleset: row.ruleset,
|
||||||
description: row.description,
|
description: row.description,
|
||||||
color: row.color != null ? int.tryParse(row.color!) : null,
|
color: row.color,
|
||||||
icon: row.icon,
|
icon: row.icon,
|
||||||
createdAt: row.createdAt,
|
createdAt: row.createdAt,
|
||||||
),
|
),
|
||||||
@@ -37,7 +37,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
name: result.name,
|
name: result.name,
|
||||||
ruleset: result.ruleset,
|
ruleset: result.ruleset,
|
||||||
description: result.description,
|
description: result.description,
|
||||||
|
flixcoo marked this conversation as resolved
|
|||||||
color: result.color != null ? int.tryParse(result.color!) : null,
|
color: result.color,
|
||||||
icon: result.icon,
|
icon: result.icon,
|
||||||
createdAt: result.createdAt,
|
createdAt: result.createdAt,
|
||||||
);
|
);
|
||||||
@@ -54,7 +54,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: Value(game.description),
|
||||||
color: Value(game.color?.toString()),
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
),
|
),
|
||||||
@@ -80,7 +80,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
|||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: Value(game.description),
|
||||||
color: Value(game.color?.toString()),
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
),
|
),
|
||||||
@@ -142,10 +142,10 @@ 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<void> updateGameColor({
|
Future<void> updateGameColor({
|
||||||
required String gameId,
|
required String gameId,
|
||||||
required int? newColor,
|
required String newColor,
|
||||||
}) async {
|
}) async {
|
||||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||||
GameTableCompanion(color: Value(newColor?.toString())),
|
GameTableCompanion(color: Value(newColor)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
|||||||
name: game.name,
|
name: game.name,
|
||||||
ruleset: game.ruleset ?? '',
|
ruleset: game.ruleset ?? '',
|
||||||
description: Value(game.description),
|
description: Value(game.description),
|
||||||
color: Value(game.color?.toString()),
|
color: game.color,
|
||||||
icon: Value(game.icon),
|
icon: Value(game.icon),
|
||||||
createdAt: game.createdAt,
|
createdAt: game.createdAt,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -682,9 +682,9 @@ class $GameTableTable extends GameTable
|
|||||||
late final GeneratedColumn<String> color = GeneratedColumn<String>(
|
late final GeneratedColumn<String> color = GeneratedColumn<String>(
|
||||||
'color',
|
'color',
|
||||||
aliasedName,
|
aliasedName,
|
||||||
true,
|
false,
|
||||||
type: DriftSqlType.string,
|
type: DriftSqlType.string,
|
||||||
requiredDuringInsert: false,
|
requiredDuringInsert: true,
|
||||||
);
|
);
|
||||||
static const VerificationMeta _iconMeta = const VerificationMeta('icon');
|
static const VerificationMeta _iconMeta = const VerificationMeta('icon');
|
||||||
@override
|
@override
|
||||||
@@ -763,6 +763,8 @@ class $GameTableTable extends GameTable
|
|||||||
_colorMeta,
|
_colorMeta,
|
||||||
color.isAcceptableOrUnknown(data['color']!, _colorMeta),
|
color.isAcceptableOrUnknown(data['color']!, _colorMeta),
|
||||||
);
|
);
|
||||||
|
} else if (isInserting) {
|
||||||
|
context.missing(_colorMeta);
|
||||||
}
|
}
|
||||||
if (data.containsKey('icon')) {
|
if (data.containsKey('icon')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
@@ -806,7 +808,7 @@ class $GameTableTable extends GameTable
|
|||||||
color: attachedDatabase.typeMapping.read(
|
color: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}color'],
|
data['${effectivePrefix}color'],
|
||||||
),
|
)!,
|
||||||
icon: attachedDatabase.typeMapping.read(
|
icon: attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string,
|
DriftSqlType.string,
|
||||||
data['${effectivePrefix}icon'],
|
data['${effectivePrefix}icon'],
|
||||||
@@ -829,7 +831,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
final String name;
|
final String name;
|
||||||
final String ruleset;
|
final String ruleset;
|
||||||
final String? description;
|
final String? description;
|
||||||
final String? color;
|
final String color;
|
||||||
final String? icon;
|
final String? icon;
|
||||||
final DateTime createdAt;
|
final DateTime createdAt;
|
||||||
const GameTableData({
|
const GameTableData({
|
||||||
@@ -837,7 +839,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
required this.name,
|
required this.name,
|
||||||
required this.ruleset,
|
required this.ruleset,
|
||||||
this.description,
|
this.description,
|
||||||
this.color,
|
required this.color,
|
||||||
this.icon,
|
this.icon,
|
||||||
required this.createdAt,
|
required this.createdAt,
|
||||||
});
|
});
|
||||||
@@ -850,9 +852,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
if (!nullToAbsent || description != null) {
|
if (!nullToAbsent || description != null) {
|
||||||
map['description'] = Variable<String>(description);
|
map['description'] = Variable<String>(description);
|
||||||
}
|
}
|
||||||
if (!nullToAbsent || color != null) {
|
|
||||||
map['color'] = Variable<String>(color);
|
map['color'] = Variable<String>(color);
|
||||||
}
|
|
||||||
if (!nullToAbsent || icon != null) {
|
if (!nullToAbsent || icon != null) {
|
||||||
map['icon'] = Variable<String>(icon);
|
map['icon'] = Variable<String>(icon);
|
||||||
}
|
}
|
||||||
@@ -868,9 +868,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
description: description == null && nullToAbsent
|
description: description == null && nullToAbsent
|
||||||
? const Value.absent()
|
? const Value.absent()
|
||||||
: Value(description),
|
: Value(description),
|
||||||
color: color == null && nullToAbsent
|
color: Value(color),
|
||||||
? const Value.absent()
|
|
||||||
: Value(color),
|
|
||||||
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
||||||
createdAt: Value(createdAt),
|
createdAt: Value(createdAt),
|
||||||
);
|
);
|
||||||
@@ -886,7 +884,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
name: serializer.fromJson<String>(json['name']),
|
name: serializer.fromJson<String>(json['name']),
|
||||||
ruleset: serializer.fromJson<String>(json['ruleset']),
|
ruleset: serializer.fromJson<String>(json['ruleset']),
|
||||||
description: serializer.fromJson<String?>(json['description']),
|
description: serializer.fromJson<String?>(json['description']),
|
||||||
color: serializer.fromJson<String?>(json['color']),
|
color: serializer.fromJson<String>(json['color']),
|
||||||
icon: serializer.fromJson<String?>(json['icon']),
|
icon: serializer.fromJson<String?>(json['icon']),
|
||||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||||
);
|
);
|
||||||
@@ -899,7 +897,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
'name': serializer.toJson<String>(name),
|
'name': serializer.toJson<String>(name),
|
||||||
'ruleset': serializer.toJson<String>(ruleset),
|
'ruleset': serializer.toJson<String>(ruleset),
|
||||||
'description': serializer.toJson<String?>(description),
|
'description': serializer.toJson<String?>(description),
|
||||||
'color': serializer.toJson<String?>(color),
|
'color': serializer.toJson<String>(color),
|
||||||
'icon': serializer.toJson<String?>(icon),
|
'icon': serializer.toJson<String?>(icon),
|
||||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||||
};
|
};
|
||||||
@@ -910,7 +908,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
String? name,
|
String? name,
|
||||||
String? ruleset,
|
String? ruleset,
|
||||||
Value<String?> description = const Value.absent(),
|
Value<String?> description = const Value.absent(),
|
||||||
Value<String?> color = const Value.absent(),
|
String? color,
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
DateTime? createdAt,
|
DateTime? createdAt,
|
||||||
}) => GameTableData(
|
}) => GameTableData(
|
||||||
@@ -918,7 +916,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
|||||||
name: name ?? this.name,
|
name: name ?? this.name,
|
||||||
ruleset: ruleset ?? this.ruleset,
|
ruleset: ruleset ?? this.ruleset,
|
||||||
description: description.present ? description.value : this.description,
|
description: description.present ? description.value : this.description,
|
||||||
color: color.present ? color.value : this.color,
|
color: color ?? this.color,
|
||||||
icon: icon.present ? icon.value : this.icon,
|
icon: icon.present ? icon.value : this.icon,
|
||||||
createdAt: createdAt ?? this.createdAt,
|
createdAt: createdAt ?? this.createdAt,
|
||||||
);
|
);
|
||||||
@@ -971,7 +969,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
final Value<String> name;
|
final Value<String> name;
|
||||||
final Value<String> ruleset;
|
final Value<String> ruleset;
|
||||||
final Value<String?> description;
|
final Value<String?> description;
|
||||||
final Value<String?> color;
|
final Value<String> color;
|
||||||
final Value<String?> icon;
|
final Value<String?> icon;
|
||||||
final Value<DateTime> createdAt;
|
final Value<DateTime> createdAt;
|
||||||
final Value<int> rowid;
|
final Value<int> rowid;
|
||||||
@@ -990,13 +988,14 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
this.description = const Value.absent(),
|
this.description = const Value.absent(),
|
||||||
this.color = const Value.absent(),
|
required String color,
|
||||||
this.icon = const Value.absent(),
|
this.icon = const Value.absent(),
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
}) : id = Value(id),
|
}) : id = Value(id),
|
||||||
name = Value(name),
|
name = Value(name),
|
||||||
ruleset = Value(ruleset),
|
ruleset = Value(ruleset),
|
||||||
|
color = Value(color),
|
||||||
createdAt = Value(createdAt);
|
createdAt = Value(createdAt);
|
||||||
static Insertable<GameTableData> custom({
|
static Insertable<GameTableData> custom({
|
||||||
Expression<String>? id,
|
Expression<String>? id,
|
||||||
@@ -1025,7 +1024,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
|||||||
Value<String>? name,
|
Value<String>? name,
|
||||||
Value<String>? ruleset,
|
Value<String>? ruleset,
|
||||||
Value<String?>? description,
|
Value<String?>? description,
|
||||||
Value<String?>? color,
|
Value<String>? color,
|
||||||
Value<String?>? icon,
|
Value<String?>? icon,
|
||||||
Value<DateTime>? createdAt,
|
Value<DateTime>? createdAt,
|
||||||
Value<int>? rowid,
|
Value<int>? rowid,
|
||||||
@@ -3665,7 +3664,7 @@ typedef $$GameTableTableCreateCompanionBuilder =
|
|||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
Value<String?> description,
|
Value<String?> description,
|
||||||
Value<String?> color,
|
required String color,
|
||||||
Value<String?> icon,
|
Value<String?> icon,
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
@@ -3676,7 +3675,7 @@ typedef $$GameTableTableUpdateCompanionBuilder =
|
|||||||
Value<String> name,
|
Value<String> name,
|
||||||
Value<String> ruleset,
|
Value<String> ruleset,
|
||||||
Value<String?> description,
|
Value<String?> description,
|
||||||
Value<String?> color,
|
Value<String> color,
|
||||||
Value<String?> icon,
|
Value<String?> icon,
|
||||||
Value<DateTime> createdAt,
|
Value<DateTime> createdAt,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
@@ -3910,7 +3909,7 @@ class $$GameTableTableTableManager
|
|||||||
Value<String> name = const Value.absent(),
|
Value<String> name = const Value.absent(),
|
||||||
Value<String> ruleset = const Value.absent(),
|
Value<String> ruleset = const Value.absent(),
|
||||||
Value<String?> description = const Value.absent(),
|
Value<String?> description = const Value.absent(),
|
||||||
Value<String?> color = const Value.absent(),
|
Value<String> color = const Value.absent(),
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
Value<DateTime> createdAt = const Value.absent(),
|
Value<DateTime> createdAt = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
@@ -3930,7 +3929,7 @@ class $$GameTableTableTableManager
|
|||||||
required String name,
|
required String name,
|
||||||
required String ruleset,
|
required String ruleset,
|
||||||
Value<String?> description = const Value.absent(),
|
Value<String?> description = const Value.absent(),
|
||||||
Value<String?> color = const Value.absent(),
|
required String color,
|
||||||
Value<String?> icon = const Value.absent(),
|
Value<String?> icon = const Value.absent(),
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class GameTable extends Table {
|
|||||||
TextColumn get name => text()();
|
TextColumn get name => text()();
|
||||||
TextColumn get ruleset => text()();
|
TextColumn get ruleset => text()();
|
||||||
|
gelbeinhalb marked this conversation as resolved
flixcoo
commented
Gleiche anmerkung wie oben, würde ich über einen Gleiche anmerkung wie oben, würde ich über einen `int` lösen
|
|||||||
TextColumn get description => text().nullable()();
|
TextColumn get description => text().nullable()();
|
||||||
TextColumn get color => text().nullable()();
|
TextColumn get color => text()();
|
||||||
TextColumn get icon => text().nullable()();
|
TextColumn get icon => text().nullable()();
|
||||||
DateTimeColumn get createdAt => dateTime()();
|
DateTimeColumn get createdAt => dateTime()();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Game {
|
|||||||
final String name;
|
final String name;
|
||||||
final String? ruleset;
|
final String? ruleset;
|
||||||
|
gelbeinhalb marked this conversation as resolved
flixcoo
commented
Ruleset sollte nicht optional, weil das immer gebraucht wird Ruleset sollte nicht optional, weil das immer gebraucht wird
Ruleset als enum
|
|||||||
final String? description;
|
final String? description;
|
||||||
final int? color;
|
final String color;
|
||||||
final String? icon;
|
final String? icon;
|
||||||
|
|
||||||
Game({
|
Game({
|
||||||
@@ -16,7 +16,7 @@ class Game {
|
|||||||
required this.name,
|
required this.name,
|
||||||
this.ruleset,
|
this.ruleset,
|
||||||
this.description,
|
this.description,
|
||||||
this.color,
|
required this.color,
|
||||||
|
flixcoo
commented
Description sollte nicht obligatorisch sein, sondern optional. Wenn nicht gesetzt soll es ein leerer String werden. Description sollte nicht obligatorisch sein, sondern optional. Wenn nicht gesetzt soll es ein leerer String werden.
gelbeinhalb
commented
Dachte man soll den als leeren String selber setzen müssen Dachte man soll den als leeren String selber setzen müssen
flixcoo
commented
würde das lieber so machen, weil man ja sonst immer unnötig die description setzten muss würde das lieber so machen, weil man ja sonst immer unnötig die description setzten muss
sneeex
commented
finde auch optional finde auch optional
|
|||||||
this.icon,
|
this.icon,
|
||||||
}) : id = id ?? const Uuid().v4(),
|
}) : id = id ?? const Uuid().v4(),
|
||||||
createdAt = createdAt ?? clock.now();
|
createdAt = createdAt ?? clock.now();
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
name: selectedGame.$1,
|
name: selectedGame.$1,
|
||||||
description: selectedGame.$2,
|
description: selectedGame.$2,
|
||||||
ruleset: selectedGame.$3.name,
|
ruleset: selectedGame.$3.name,
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Use the selected game from the list
|
// Use the selected game from the list
|
||||||
@@ -210,6 +211,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
name: selectedGame.$1,
|
name: selectedGame.$1,
|
||||||
description: selectedGame.$2,
|
description: selectedGame.$2,
|
||||||
ruleset: selectedGame.$3.name,
|
ruleset: selectedGame.$3.name,
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Add the game to the database if it doesn't exist
|
// Add the game to the database if it doesn't exist
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void main() {
|
|||||||
name: 'Chess',
|
name: 'Chess',
|
||||||
ruleset: 'winner.single',
|
ruleset: 'winner.single',
|
||||||
description: 'A classic strategy game',
|
description: 'A classic strategy game',
|
||||||
color: 0xFF0000FF,
|
color: '0xFF0000FF',
|
||||||
icon: 'chess_icon',
|
icon: 'chess_icon',
|
||||||
);
|
);
|
||||||
testGame2 = Game(
|
testGame2 = Game(
|
||||||
@@ -34,13 +34,14 @@ void main() {
|
|||||||
name: 'Poker',
|
name: 'Poker',
|
||||||
ruleset: 'Texas Hold\'em rules',
|
ruleset: 'Texas Hold\'em rules',
|
||||||
description: 'winner.multiple',
|
description: 'winner.multiple',
|
||||||
color: 0xFFFF0000,
|
color: '0xFFFF0000',
|
||||||
icon: 'poker_icon',
|
icon: 'poker_icon',
|
||||||
);
|
);
|
||||||
testGame3 = Game(
|
testGame3 = Game(
|
||||||
id: 'game3',
|
id: 'game3',
|
||||||
name: 'Monopoly',
|
name: 'Monopoly',
|
||||||
description: 'A board game about real estate',
|
description: 'A board game about real estate',
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -130,7 +131,7 @@ void main() {
|
|||||||
|
|
||||||
// Verifies that a game with null optional fields can be added and retrieved.
|
// Verifies that a game with null optional fields can be added and retrieved.
|
||||||
test('addGame handles game with null optional fields', () async {
|
test('addGame handles game with null optional fields', () async {
|
||||||
final gameWithNulls = Game(name: 'Simple Game');
|
final gameWithNulls = Game(name: 'Simple Game', color: '0xFF000000');
|
||||||
final result = await database.gameDao.addGame(game: gameWithNulls);
|
final result = await database.gameDao.addGame(game: gameWithNulls);
|
||||||
expect(result, true);
|
expect(result, true);
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(fetchedGame.name, 'Simple Game');
|
expect(fetchedGame.name, 'Simple Game');
|
||||||
expect(fetchedGame.description, isNull);
|
expect(fetchedGame.description, isNull);
|
||||||
expect(fetchedGame.color, isNull);
|
expect(fetchedGame.color, '0xFF000000');
|
||||||
expect(fetchedGame.icon, isNull);
|
expect(fetchedGame.icon, isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -336,35 +337,20 @@ void main() {
|
|||||||
|
|
||||||
await database.gameDao.updateGameColor(
|
await database.gameDao.updateGameColor(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newColor: 0xFF00FF00,
|
newColor: '0xFF00FF00',
|
||||||
);
|
);
|
||||||
|
|
||||||
final updatedGame = await database.gameDao.getGameById(
|
final updatedGame = await database.gameDao.getGameById(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
);
|
);
|
||||||
expect(updatedGame.color, 0xFF00FF00);
|
expect(updatedGame.color, '0xFF00FF00');
|
||||||
});
|
|
||||||
|
|
||||||
// Verifies that updateGameColor can set the color to null.
|
|
||||||
test('updateGameColor can set color to null', () async {
|
|
||||||
await database.gameDao.addGame(game: testGame1);
|
|
||||||
|
|
||||||
await database.gameDao.updateGameColor(
|
|
||||||
gameId: testGame1.id,
|
|
||||||
newColor: null,
|
|
||||||
);
|
|
||||||
|
|
||||||
final updatedGame = await database.gameDao.getGameById(
|
|
||||||
gameId: testGame1.id,
|
|
||||||
);
|
|
||||||
expect(updatedGame.color, isNull);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verifies that updateGameColor does nothing when game doesn't exist.
|
// Verifies that updateGameColor does nothing when game doesn't exist.
|
||||||
test('updateGameColor does nothing for non-existent game', () async {
|
test('updateGameColor does nothing for non-existent game', () async {
|
||||||
await database.gameDao.updateGameColor(
|
await database.gameDao.updateGameColor(
|
||||||
gameId: 'non-existent-id',
|
gameId: 'non-existent-id',
|
||||||
newColor: 0xFF00FF00,
|
newColor: '0xFF00FF00',
|
||||||
);
|
);
|
||||||
|
|
||||||
final allGames = await database.gameDao.getAllGames();
|
final allGames = await database.gameDao.getAllGames();
|
||||||
@@ -470,6 +456,7 @@ void main() {
|
|||||||
final specialGame = Game(
|
final specialGame = Game(
|
||||||
name: 'Game\'s & "Special" <Name>',
|
name: 'Game\'s & "Special" <Name>',
|
||||||
description: 'Description with émojis 🎮🎲',
|
description: 'Description with émojis 🎮🎲',
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
await database.gameDao.addGame(game: specialGame);
|
await database.gameDao.addGame(game: specialGame);
|
||||||
|
|
||||||
@@ -487,6 +474,7 @@ void main() {
|
|||||||
ruleset: '',
|
ruleset: '',
|
||||||
description: '',
|
description: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
await database.gameDao.addGame(game: emptyGame);
|
await database.gameDao.addGame(game: emptyGame);
|
||||||
|
|
||||||
@@ -506,6 +494,7 @@ void main() {
|
|||||||
name: longString,
|
name: longString,
|
||||||
description: longString,
|
description: longString,
|
||||||
ruleset: longString,
|
ruleset: longString,
|
||||||
|
color: '0xFF000000',
|
||||||
);
|
);
|
||||||
await database.gameDao.addGame(game: longGame);
|
await database.gameDao.addGame(game: longGame);
|
||||||
|
|
||||||
@@ -527,7 +516,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
await database.gameDao.updateGameColor(
|
await database.gameDao.updateGameColor(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
newColor: 0xFF123456,
|
newColor: '0xFF123456',
|
||||||
);
|
);
|
||||||
await database.gameDao.updateGameDescription(
|
await database.gameDao.updateGameDescription(
|
||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
@@ -538,7 +527,7 @@ void main() {
|
|||||||
gameId: testGame1.id,
|
gameId: testGame1.id,
|
||||||
);
|
);
|
||||||
expect(updatedGame.name, 'Updated Name');
|
expect(updatedGame.name, 'Updated Name');
|
||||||
expect(updatedGame.color, 0xFF123456);
|
expect(updatedGame.color, '0xFF123456');
|
||||||
expect(updatedGame.description, 'Updated Description');
|
expect(updatedGame.description, 'Updated Description');
|
||||||
expect(updatedGame.ruleset, testGame1.ruleset);
|
expect(updatedGame.ruleset, testGame1.ruleset);
|
||||||
expect(updatedGame.icon, testGame1.icon);
|
expect(updatedGame.icon, testGame1.icon);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void main() {
|
|||||||
name: 'Test Group 2',
|
name: 'Test Group 2',
|
||||||
members: [testPlayer4, testPlayer5],
|
members: [testPlayer4, testPlayer5],
|
||||||
);
|
);
|
||||||
testGame = Game(name: 'Test Game');
|
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
||||||
testMatch1 = Match(
|
testMatch1 = Match(
|
||||||
name: 'First Test Match',
|
name: 'First Test Match',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void main() {
|
|||||||
name: 'Test Group',
|
name: 'Test Group',
|
||||||
members: [testPlayer1, testPlayer2, testPlayer3],
|
members: [testPlayer1, testPlayer2, testPlayer3],
|
||||||
);
|
);
|
||||||
testGame = Game(name: 'Test Game');
|
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
||||||
testMatchOnlyGroup = Match(
|
testMatchOnlyGroup = Match(
|
||||||
name: 'Test Match with Group',
|
name: 'Test Match with Group',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ void main() {
|
|||||||
testPlayer1 = Player(name: 'Alice');
|
testPlayer1 = Player(name: 'Alice');
|
||||||
testPlayer2 = Player(name: 'Bob');
|
testPlayer2 = Player(name: 'Bob');
|
||||||
testPlayer3 = Player(name: 'Charlie');
|
testPlayer3 = Player(name: 'Charlie');
|
||||||
testGame = Game(name: 'Test Game');
|
testGame = Game(name: 'Test Game', color: '0xFF000000');
|
||||||
testMatch1 = Match(
|
testMatch1 = Match(
|
||||||
name: 'Test Match 1',
|
name: 'Test Match 1',
|
||||||
game: testGame,
|
game: testGame,
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ void main() {
|
|||||||
name: 'Team Gamma',
|
name: 'Team Gamma',
|
||||||
members: [testPlayer1, testPlayer3],
|
members: [testPlayer1, testPlayer3],
|
||||||
);
|
);
|
||||||
testGame1 = Game(name: 'Game 1');
|
testGame1 = Game(name: 'Game 1', color: '0xFF000000');
|
||||||
testGame2 = Game(name: 'Game 2');
|
testGame2 = Game(name: 'Game 2', color: '0xFF000000');
|
||||||
});
|
});
|
||||||
|
|
||||||
await database.playerDao.addPlayersAsList(
|
await database.playerDao.addPlayersAsList(
|
||||||
|
|||||||
Reference in New Issue
Block a user
Funktioniert das tatsächlich? Ist das getestet, dass dann auch ein ruleset (color) gefunden wird wenn du den enum speicherst?
Ja glaube das hat funktioniert