Commit 87bc19b
Changed files (1)
health_data_store
test
health_data_store/test/src/health_data_store_test.dart
@@ -4,6 +4,7 @@ import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';
import 'database_manager_test.dart';
+import 'types/blood_pressure_record_test.dart';
void main() {
sqfliteTestInit();
@@ -12,5 +13,27 @@ void main() {
await openDatabase(inMemoryDatabasePath));
expect(store, isNotNull);
});
- // TODO: implement more tests
+ test('should construct repositories', () async {
+ final store = await HealthDataStore.load(
+ await openDatabase(inMemoryDatabasePath));
+ expect(store, isNotNull);
+ expect(() => store!.medRepo, returnsNormally);
+ expect(() => store!.intakeRepo, returnsNormally);
+ expect(() => store!.bpRepo, returnsNormally);
+ expect(() => store!.noteRepo, returnsNormally);
+ });
+ test('constructed repos should wor', () async {
+ final store = await HealthDataStore.load(
+ await openDatabase(inMemoryDatabasePath));
+ expect(store, isNotNull);
+ final bpRepo = store!.bpRepo;
+ final r = mockRecord(time: 10000, sys: 123, dia: 45, pul: 67);
+ await bpRepo.add(r);
+ final data = await bpRepo.get(DateRange(
+ start: DateTime.fromMillisecondsSinceEpoch(5000),
+ end: DateTime.fromMillisecondsSinceEpoch(20000),
+ ));
+ expect(data.length, 1);
+ expect(data, contains(r));
+ });
}