This commit is contained in:
Dieter Plaetinck
2024-05-04 14:20:08 +02:00
parent bffaa9a9c9
commit faa417d183
2 changed files with 28 additions and 2 deletions

View File

@@ -139,4 +139,21 @@ class NutritionalGoals {
//ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => Object.hash(
energy, protein, carbohydrates, carbohydratesSugar, fat, fatSaturated, fibres, sodium);
@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is NutritionalGoals &&
other.energy == energy &&
other.protein == protein &&
other.carbohydrates == carbohydrates &&
other.carbohydratesSugar == carbohydratesSugar &&
other.fat == fat &&
other.fatSaturated == fatSaturated &&
other.fibres == fibres &&
other.sodium == sodium;
}
}

View File

@@ -32,8 +32,17 @@ void main() {
group('model tests', () {
test('Test the nutritionalValues method for nutritional plans', () {
final values = NutritionalValues.values(4118.75, 32.75, 347.5, 9.5, 59.0, 37.75, 52.5, 30.5);
expect(plan.nutritionalGoals, values);
expect(
plan.nutritionalGoals,
NutritionalGoals(
energy: 4118.75,
protein: 32.75,
carbohydrates: 347.5,
carbohydratesSugar: 9.5,
fat: 59.0,
fatSaturated: 37.75,
fibres: 52.5,
sodium: 30.5));
});
test('Test the nutritionalValues method for meals', () {