2023-02-16 01:59:15 +01:00
|
|
|
import 'package:smoke_cess_app/interface/db_record.dart';
|
|
|
|
import 'package:smoke_cess_app/models/mood.dart';
|
2023-02-26 23:29:47 +01:00
|
|
|
import 'package:smoke_cess_app/models/relapse.dart';
|
2023-02-16 01:59:15 +01:00
|
|
|
import 'package:smoke_cess_app/models/sleep.dart';
|
2023-03-02 13:19:08 +01:00
|
|
|
import 'package:smoke_cess_app/models/workout.dart';
|
2023-02-26 16:17:57 +01:00
|
|
|
import 'package:smoke_cess_app/services/database_service.dart';
|
2023-03-02 16:12:54 +01:00
|
|
|
// ignore: depend_on_referenced_packages
|
2023-02-26 16:17:57 +01:00
|
|
|
import 'package:sqflite_common/sqlite_api.dart';
|
2023-02-16 01:59:15 +01:00
|
|
|
|
2023-02-26 16:17:57 +01:00
|
|
|
class DatabaseMock implements DatabaseService {
|
|
|
|
static final DatabaseMock _databaseMock = DatabaseMock._internal();
|
|
|
|
factory DatabaseMock() {
|
|
|
|
return _databaseMock;
|
|
|
|
}
|
|
|
|
DatabaseMock._internal();
|
|
|
|
|
|
|
|
final List<Mood> _moodRecords = [];
|
|
|
|
final List<Sleep> _sleepRecords = [];
|
2023-02-26 23:29:47 +01:00
|
|
|
final List<Relapse> _relapseRecords = [];
|
2023-03-02 19:04:40 +01:00
|
|
|
final List<Workout> _workoutRecords = [];
|
2023-02-16 01:59:15 +01:00
|
|
|
|
2023-02-26 16:17:57 +01:00
|
|
|
@override
|
|
|
|
Future<int> addMood(Mood mood) {
|
|
|
|
_moodRecords.add(mood);
|
|
|
|
return Future.value(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<int> addSleep(Sleep sleep) {
|
|
|
|
_sleepRecords.add(sleep);
|
|
|
|
return Future.value(1);
|
2023-02-16 01:59:15 +01:00
|
|
|
}
|
|
|
|
|
2023-02-26 16:17:57 +01:00
|
|
|
@override
|
2023-03-02 13:19:08 +01:00
|
|
|
Future<int> addWorkout(Workout workout) {
|
|
|
|
_workoutRecords.add(workout);
|
|
|
|
return Future.value(1);
|
|
|
|
}
|
|
|
|
|
2023-02-26 23:29:47 +01:00
|
|
|
@override
|
|
|
|
Future<int> addRelapse(Relapse relapse) {
|
|
|
|
_relapseRecords.add(relapse);
|
|
|
|
return Future.value(1);
|
|
|
|
}
|
|
|
|
|
2023-03-02 13:19:08 +01:00
|
|
|
@override
|
2023-02-26 16:17:57 +01:00
|
|
|
Future<Database> get database => DatabaseService.instance.database;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<Mood>> getMoodRecords() {
|
|
|
|
return Future.value(_moodRecords);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<Sleep>> getSleepRecords() {
|
|
|
|
return Future.value(_sleepRecords);
|
|
|
|
}
|
2023-02-26 23:29:47 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<Relapse>> getRelapseRecords() {
|
|
|
|
return Future.value(_relapseRecords);
|
|
|
|
}
|
2023-03-02 19:04:40 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<Workout>> getWorkoutRecords() {
|
|
|
|
return Future.value(_workoutRecords);
|
|
|
|
}
|
2023-02-16 01:59:15 +01:00
|
|
|
}
|