Skip to content
Snippets Groups Projects
Commit 9aafff31 authored by HSoreide's avatar HSoreide
Browse files

Correct some small logical errors in the unit tests of the Ingredient class

parent 716fdaf3
No related branches found
No related tags found
1 merge request!7Create food and recipe classes with tests
Pipeline #205582 passed
......@@ -63,7 +63,7 @@ public class Ingredient {
* @param amount The amount of an ingredient as double.
*/
public void setAmount(double amount) {
if(amount < 0.0f) {
if(amount <= 0.0f) {
throw new IllegalArgumentException("The amount of an ingredient cannot be zero or negative.");
}
this.amount = amount;
......
......@@ -48,7 +48,7 @@ class IngredientTest {
@DisplayName("Change of food amount works for valid amount.")
void setAmountWorksForValidAmount() {
testIngredient.setAmount(2.5);
assertEquals(new Ingredient(FoodItem.LEMON, 2.5f, MeasuringUnit.KG), testIngredient);
assertEquals(new Ingredient(FoodItem.ONION, 2.5f, MeasuringUnit.KG), testIngredient);
}
@Test
......@@ -62,7 +62,7 @@ class IngredientTest {
@DisplayName("Change of measuring unit works for valid unit.")
void setUnitWorksForValidUnit() {
testIngredient.setUnit(MeasuringUnit.TBS);
assertEquals(new Ingredient(FoodItem.LEMON, 0.5f, MeasuringUnit.TBS), testIngredient);
assertEquals(new Ingredient(FoodItem.ONION, 0.5f, MeasuringUnit.TBS), testIngredient);
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment