-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @author Saadman Haq s160081 | ||
*/ | ||
|
||
package application; | ||
|
||
import javax.xml.bind.JAXBElement; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @author Saadman Haq s160081 | ||
*/ | ||
|
||
package application; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package jUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import application.Model; | ||
import application.Recipe; | ||
import application.Recipe.Ingredients; | ||
import application.Recipe.Ingredients.Ingredient; | ||
|
||
class ModelTest { | ||
private Recipe.Ingredients.Ingredient ingredient = new Recipe.Ingredients.Ingredient(); | ||
private Recipe rec; | ||
|
||
@Test | ||
void testSecondsToHHMMSS() { | ||
Model testTime = new Model(); | ||
String test1 = testTime.secondsToHHMMSS(2000); | ||
String test2 = "00:33:20"; | ||
assertEquals(test2,test1); | ||
} | ||
|
||
@Test | ||
void testSecondsToCollapsingHHMMSS() { | ||
Model test = new Model(); | ||
String test1 = test.secondsToCollapsingHHMMSS(120); | ||
String test2 = "2:00"; | ||
assertEquals(test2, test1); | ||
} | ||
|
||
@Test | ||
void testGetTime() { //works if you comment line 60-70 in Model, NPE otherwise | ||
Model test = new Model(); | ||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); | ||
String str = sdf.format(new Date()); | ||
String test1 = test.getTime(); | ||
assertEquals(str, test1); | ||
} | ||
|
||
// @Test | ||
// void testIngredientQuantityMultiplier() { | ||
// ingredient.setIname("bread"); | ||
// ingredient.setQuantity("100"); | ||
// ingredient.setUnit("g"); | ||
// Model.ingredientsQuantityMultiplier(2); | ||
// assertEquals("200",Model.recipe.getIngredients().getIngredient()); | ||
// } | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package jUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import application.Recipe; | ||
import application.Recipe.Ingredients.Ingredient; | ||
|
||
class RecipeTest { | ||
private Recipe rec; | ||
private Ingredient ing; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
rec = new Recipe(); | ||
ing = new Recipe.Ingredients.Ingredient(); | ||
rec.setTitle("asciuta"); | ||
rec.setID(Byte.parseByte("1")); | ||
rec.setStartdate("12.04.2014"); | ||
rec.setChangedate("14.06.2018"); | ||
rec.setTarget("For 4-5 people"); | ||
|
||
rec.setIngredients(new Recipe.Ingredients()); | ||
ing.setIname("spaghetti"); | ||
ing.setQuantity("300"); | ||
ing.setUnit("g"); | ||
|
||
|
||
|
||
} | ||
|
||
@Test | ||
void test() { | ||
String title = "asciuta"; | ||
String ID = "1"; | ||
String sd = "12.04.2014"; | ||
String cd = "14.06.2018"; | ||
String tar = "For 4-5 people"; | ||
|
||
assertEquals(title, rec.getTitle()); | ||
assertEquals(Byte.parseByte(ID), rec.getID()); | ||
assertEquals(sd, rec.getStartdate()); | ||
assertEquals(cd, rec.getChangedate()); | ||
assertEquals(tar, rec.getTarget()); | ||
|
||
|
||
} | ||
|
||
} |