Commit 34f3401
Changed files (2)
health_data_store
lib
src
test
src
health_data_store/lib/src/types/blood_pressure_record.dart
@@ -0,0 +1,21 @@
+
+import 'package:freezed_annotation/freezed_annotation.dart';
+
+part 'blood_pressure_record.freezed.dart';
+
+/// Immutable representation of a blood pressure measurement.
+@freezed
+class BloodPressureRecord with _$BloodPressureRecord {
+ /// Create a immutable representation of a blood pressure measurement.
+ const factory BloodPressureRecord({
+ /// Timestamp when the measurement was taken.
+ required DateTime time,
+ /// Systolic value of the measurement.
+ int? sys,
+ /// Diastolic value of the measurement.
+ int? dia,
+ /// Pulse value of the measurement.
+ int? pul,
+ }) = _BloodPressureRecord;
+}
+// TODO: create class for note and color/pin
health_data_store/test/src/types/blood_pressure_record_test.dart
@@ -0,0 +1,41 @@
+import 'package:health_data_store/src/types/blood_pressure_record.dart';
+import 'package:test/test.dart';
+
+void main() {
+ test('should initialize with all data', () {
+ final time = DateTime.now();
+ final record = BloodPressureRecord(
+ time: time,
+ sys: 123,
+ dia: 56,
+ pul: 78,
+ );
+ expect(record.time, time);
+ expect(record.sys, 123);
+ expect(record.dia, 56);
+ expect(record.pul, 78);
+ expect(record, equals(BloodPressureRecord(
+ time: time,
+ sys: 123,
+ dia: 56,
+ pul: 78,
+ )));
+ });
+ test('should initialize with partial data', () {
+ final time = DateTime.now();
+ final record = BloodPressureRecord(
+ time: time,
+ dia: 56,
+ );
+ expect(record.time, time);
+ expect(record.sys, null);
+ expect(record.dia, 56);
+ expect(record.pul, null);
+ expect(record, isNot(equals(BloodPressureRecord(
+ time: time,
+ sys: 123,
+ dia: 56,
+ pul: 78,
+ ))));
+ });
+}