diff --git a/lib/src/models/event_model.dart b/lib/src/models/event_model.dart index 0442e9e..28ba99b 100644 --- a/lib/src/models/event_model.dart +++ b/lib/src/models/event_model.dart @@ -46,4 +46,31 @@ class EventModel { "lowPriority": lowPriority, }; } + + @override + int get hashCode => + id.hashCode ^ + name.hashCode ^ + pendigTasks.hashCode ^ + when.hashCode ^ + media.hashCode ^ + tasks.hashCode ^ + highPriority.hashCode ^ + mediumPriority.hashCode ^ + lowPriority.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is EventModel && + runtimeType == other.runtimeType && + id == other.id && + name == other.name && + pendigTasks == other.pendigTasks && + when == other.when && + media == other.media && + tasks == other.tasks && + highPriority == other.highPriority && + mediumPriority == other.mediumPriority && + lowPriority == other.lowPriority; } diff --git a/lib/src/models/summary_model.dart b/lib/src/models/summary_model.dart index 53860d8..8f273c3 100644 --- a/lib/src/models/summary_model.dart +++ b/lib/src/models/summary_model.dart @@ -54,4 +54,33 @@ class SummaryModel { "addedFriday": addedFriday, }; } + + @override + int get hashCode => + completedMonday.hashCode ^ + addedMonday.hashCode ^ + completedTuesday.hashCode ^ + addedTuesday.hashCode ^ + completedWednesday.hashCode ^ + addedWednesday.hashCode ^ + completedThursday.hashCode ^ + addedThursday.hashCode ^ + completedFriday.hashCode ^ + addedFriday.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is SummaryModel && + runtimeType == other.runtimeType && + completedMonday == other.completedMonday && + addedMonday == other.addedMonday && + completedTuesday == other.completedTuesday && + addedTuesday == other.addedTuesday && + completedWednesday == other.completedWednesday && + addedWednesday == other.addedWednesday && + completedThursday == other.completedThursday && + addedThursday == other.addedThursday && + completedFriday == other.completedFriday && + addedFriday == other.addedFriday; } diff --git a/lib/src/models/task_model.dart b/lib/src/models/task_model.dart index 0855139..96339e3 100644 --- a/lib/src/models/task_model.dart +++ b/lib/src/models/task_model.dart @@ -34,4 +34,25 @@ class TaskModel { "event": event, }; } + + @override + int get hashCode => + id.hashCode ^ + text.hashCode ^ + priority.hashCode ^ + ownerUsername.hashCode ^ + done.hashCode ^ + event.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + runtimeType == other.runtimeType && + other is TaskModel && + id == other.id && + text == other.text && + priority == other.priority && + ownerUsername == other.ownerUsername && + done == other.done && + event == other.event; } diff --git a/lib/src/models/user_model.dart b/lib/src/models/user_model.dart index 61bfc35..0ce2dc2 100644 --- a/lib/src/models/user_model.dart +++ b/lib/src/models/user_model.dart @@ -22,14 +22,7 @@ class UserModel { this.pendingHigh, this.pendingMedium, this.pendingLow, - }) : assert(id != null), - assert(username != null), - assert(tasks != null), - assert(summary != null), - assert(userId != null), - assert(pendingHigh != null), - assert(pendingMedium != null), - assert(pendingLow != null); + }); ///Returns a [UserModel] from a map. UserModel.fromFirestore(Map firestoreMap, {String id}) @@ -42,4 +35,29 @@ class UserModel { pendingHigh = firestoreMap["pendingHigh"], pendingMedium = firestoreMap["pendingMedium"], pendingLow = firestoreMap["pendingLow"]; + + @override + int get hashCode => + id.hashCode ^ + username.hashCode ^ + tasks.hashCode ^ + summary.hashCode ^ + userId.hashCode ^ + pendingHigh.hashCode ^ + pendingMedium.hashCode ^ + pendingLow.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + runtimeType == other.runtimeType && + other is UserModel && + id == other.id && + username == other.username && + tasks == other.tasks && + summary == other.summary && + userId == other.userId && + pendingHigh == other.pendingHigh && + pendingMedium == other.pendingMedium && + pendingLow == other.pendingLow; } diff --git a/pubspec.yaml b/pubspec.yaml index f9ff4ef..4368a33 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,6 +22,7 @@ dependencies: http: ^0.12.0 sqflite: ^1.1.0 rxdart: ^0.20.0 + mockito: ^4.0.0 firebase_core: ^0.3.0 firebase_analytics: ^2.0.2 cloud_firestore: ^0.9.0