Renamed folder to "models"
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tallee/core/enums.dart';
|
||||
import 'package:tallee/data/db/database.dart';
|
||||
import 'package:tallee/data/dto/game.dart';
|
||||
import 'package:tallee/data/models/game.dart';
|
||||
|
||||
void main() {
|
||||
late AppDatabase database;
|
||||
@@ -54,7 +54,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('Game Tests', () {
|
||||
|
||||
// Verifies that getAllGames returns an empty list when the database has no games.
|
||||
test('getAllGames returns empty list when no games exist', () async {
|
||||
final allGames = await database.gameDao.getAllGames();
|
||||
@@ -106,7 +105,7 @@ void main() {
|
||||
// Verifies that getGameById throws a StateError when the game doesn't exist.
|
||||
test('getGameById throws exception for non-existent game', () async {
|
||||
expect(
|
||||
() => database.gameDao.getGameById(gameId: 'non-existent-id'),
|
||||
() => database.gameDao.getGameById(gameId: 'non-existent-id'),
|
||||
throwsA(isA<StateError>()),
|
||||
);
|
||||
});
|
||||
@@ -134,7 +133,13 @@ void main() {
|
||||
|
||||
// Verifies that a game with empty 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: GameColor.green, icon: '');
|
||||
final gameWithNulls = Game(
|
||||
name: 'Simple Game',
|
||||
ruleset: Ruleset.lowestScore,
|
||||
description: 'A simple game',
|
||||
color: GameColor.green,
|
||||
icon: '',
|
||||
);
|
||||
final result = await database.gameDao.addGame(game: gameWithNulls);
|
||||
expect(result, true);
|
||||
|
||||
@@ -419,9 +424,7 @@ void main() {
|
||||
|
||||
// Verifies that getGameCount updates correctly after deleting a game.
|
||||
test('getGameCount updates correctly after deletion', () async {
|
||||
await database.gameDao.addGamesAsList(
|
||||
games: [testGame1, testGame2],
|
||||
);
|
||||
await database.gameDao.addGamesAsList(games: [testGame1, testGame2]);
|
||||
|
||||
final countBefore = await database.gameDao.getGameCount();
|
||||
expect(countBefore, 2);
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:drift/drift.dart' hide isNull;
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tallee/data/db/database.dart';
|
||||
import 'package:tallee/data/dto/player.dart';
|
||||
import 'package:tallee/data/models/player.dart';
|
||||
|
||||
void main() {
|
||||
late AppDatabase database;
|
||||
@@ -35,7 +35,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('Player Tests', () {
|
||||
|
||||
// Verifies that players can be added and retrieved with all fields intact.
|
||||
test('Adding and fetching single player works correctly', () async {
|
||||
await database.playerDao.addPlayer(player: testPlayer1);
|
||||
@@ -264,16 +263,22 @@ 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!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~', description: '');
|
||||
test(
|
||||
'Player with special characters in name is stored correctly',
|
||||
() async {
|
||||
final specialPlayer = Player(
|
||||
name: 'Test!@#\$%^&*()_+-=[]{}|;\':",.<>?/`~',
|
||||
description: '',
|
||||
);
|
||||
|
||||
await database.playerDao.addPlayer(player: specialPlayer);
|
||||
await database.playerDao.addPlayer(player: specialPlayer);
|
||||
|
||||
final fetchedPlayer = await database.playerDao.getPlayerById(
|
||||
playerId: specialPlayer.id,
|
||||
);
|
||||
expect(fetchedPlayer.name, specialPlayer.name);
|
||||
});
|
||||
final fetchedPlayer = await database.playerDao.getPlayerById(
|
||||
playerId: specialPlayer.id,
|
||||
);
|
||||
expect(fetchedPlayer.name, specialPlayer.name);
|
||||
},
|
||||
);
|
||||
|
||||
// Verifies that a player with description is stored correctly.
|
||||
test('Player with description is stored correctly', () async {
|
||||
@@ -293,7 +298,10 @@ 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', description: '');
|
||||
final playerWithoutDescription = Player(
|
||||
name: 'No Description Player',
|
||||
description: '',
|
||||
);
|
||||
|
||||
await database.playerDao.addPlayer(player: playerWithoutDescription);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user