-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFoodENtrytest
81 lines (68 loc) · 2.27 KB
/
FoodENtrytest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package org.wof.foodministry;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/* tests folder, imports, and initial test were all set up for an Intellij IDE
http://stackoverflow.com/questions/19330832/setting-up-junit-with-intellij-idea
*/
public class FoodEntryTestClass {
// Creating a sample Date object with the same data for each test requires
// making the data object with defined, repeatable values.
// http://stackoverflow.com/questions/22326339/how-create-date-object-with-values-in-java
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = "2017-01-01 00:00:00";
Date date = sdf.parse(dateString);
// Simple variable types can be defined
int weight = 100;
int waste = 25;
String location = "Fairfax";
FoodEntry entry = new FoodEntry(weight, waste, location);
public FoodEntryTestClass() throws ParseException {
}
@Test
public void testGetWeightTrue(){
System.out.println("Testing getWeight() for true");
int result = entry.getWeight();
assertEquals(100, result);
}
@Test
public void testGetWeightFalse() {
System.out.println("Testing getWeight() for false");
int result = entry.getWeight();
assertNotEquals(10, result);
}
//TODO: Create true and false test cases for the other FoodEntry class variables
// Follow the pattern show for the getWeight() method
@Test
public void testGetWasteTrue(){
System.out.println("Testing getWaste() for true");
int result = entry.getWaste();
assertEquals(30, result);
}
@Test
public void testGetWasteFalse(){
System.out.println("Testing getWaste() for false");
int result = entry.getWaste();
assertNotEquals(100, result);
}
@Test
public void testGetLocationTrue() {
System.out.println("Testing getLocation() for true");
String result = entry.getLocation();
assertEquals("Fairfax", result);
}
@Test
public void testGetLocationFalse() {
System.out.println("Testing getLocation() for False");
String result = entry.getLocation();
assertNotEquals("Clarendon", result);
}
//TODO: Look into other unit test types to get complete testing coverage on your class
boolean @Test
public void firstTest() {
Assert.assertTrue(true);
}
}