-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventoryTest.java
More file actions
81 lines (71 loc) · 2.41 KB
/
InventoryTest.java
File metadata and controls
81 lines (71 loc) · 2.41 KB
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
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class InventoryTest {
@Test
@SuppressWarnings("unused")
public void testInventoryAdd() {
Inventory inventory;
try{
inventory = new Inventory();
} catch (Exception e) {
System.out.println("Error creating inventory");
}
Produce produce = new Produce("Apple", "Fall");
Inventory.addProduce(produce, 5);
assertTrue(Inventory.contains("Apple"));
assertEquals(5, Inventory.getCount("Apple"));
}
@Test
@SuppressWarnings("unused")
public void testInventoryRemove() {
Inventory inventory;
try{
inventory = new Inventory();
} catch (Exception e) {
System.out.println("Error creating inventory");
}
Produce produce = new Produce("Apple", "Fall");
Inventory.addProduce(produce, 5);
Inventory.removeProduce("Apple", 3);
assertEquals(2, Inventory.getCount("Apple"));
}
@Test
@SuppressWarnings("unused")
public void testInventoryGetProduce() {
Inventory inventory;
try{
inventory = new Inventory();
} catch (Exception e) {
System.out.println("Error creating inventory");
}
Produce produce = new Produce("Apple", "Fall");
Inventory.addProduce(produce, 5);
assertEquals(produce, Inventory.getProduce("Apple"));
}
@Test
public void testInventoryToString() {
Inventory inventory = null; // Initialize the inventory variable
try{
inventory = new Inventory();
} catch (Exception e) {
System.out.println("Error creating inventory");
}
Produce produce = new Produce("Apple", "Fall");
Inventory.addProduce(produce, 5);
String expectedToString = "Apple: \n Count: 5\n Status: Out of Season\n";
assertEquals(expectedToString, inventory.toString());
}
@Test
@SuppressWarnings("unused")
public void testInventoryInStock() {
Inventory inventory;
try{
inventory = new Inventory();
} catch (Exception e) {
System.out.println("Error creating inventory");
}
Produce produce = new Produce("Apple", "Fall");
Inventory.addProduce(produce, 5);
assertTrue(Inventory.inStock("Apple", 5));
}
}