|
@@ -0,0 +1,73 @@
|
|
1
|
+package io.zipcoder;
|
|
2
|
+
|
|
3
|
+import org.junit.Assert;
|
|
4
|
+import org.junit.Before;
|
|
5
|
+import org.junit.Test;
|
|
6
|
+
|
|
7
|
+import java.util.HashMap;
|
|
8
|
+
|
|
9
|
+public class ItemsTest {
|
|
10
|
+
|
|
11
|
+ Items items = new Items();
|
|
12
|
+
|
|
13
|
+ @Before
|
|
14
|
+ public void setUp() throws Exception {
|
|
15
|
+ Item item1 = new Item("Milk", 3.40, "Food", "11/12/2020");
|
|
16
|
+ Item item2 = new Item("Milk", 1.45, "Food", "11/12/2020");
|
|
17
|
+ Item item3 = new Item("Milk", 3.40, "Food", "12/5/2020");
|
|
18
|
+ Item item4 = new Item("Cookies", 1.75, "Food", "11/12/2020");
|
|
19
|
+ Item item5 = new Item("Apples", 0.75, "Food", "11/12/2020");
|
|
20
|
+ Item item6 = new Item("Bread", 1.00, "Food", "11/12/2020");
|
|
21
|
+ Item item7 = new Item("Bread", 1.40, "Food", "11/12/2020");
|
|
22
|
+ Item item8 = new Item("Bread", 1.00, "Food", "11/12/2020");
|
|
23
|
+
|
|
24
|
+ items.add(item1);
|
|
25
|
+ items.add(item2);
|
|
26
|
+ items.add(item3);
|
|
27
|
+ items.add(item4);
|
|
28
|
+ items.add(item5);
|
|
29
|
+ items.add(item6);
|
|
30
|
+ items.add(item7);
|
|
31
|
+ items.add(item8);
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ @Test
|
|
35
|
+ public void testGetMilk() {
|
|
36
|
+ Items milkItems = items.getMilks();
|
|
37
|
+ int expected = 3;
|
|
38
|
+ int actual = milkItems.size();
|
|
39
|
+ Assert.assertEquals(expected, actual);
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ @Test
|
|
43
|
+ public void testGetBread() {
|
|
44
|
+ Items breadItems = items.getBread();
|
|
45
|
+ int expected = 3;
|
|
46
|
+ int actual = breadItems.size();
|
|
47
|
+ Assert.assertEquals(expected, actual);
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ @Test
|
|
51
|
+ public void testGetCookies() {
|
|
52
|
+ Items cookieItems = items.getCookies();
|
|
53
|
+ int expected = 1;
|
|
54
|
+ int actual = cookieItems.size();
|
|
55
|
+ Assert.assertEquals(expected, actual);
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ @Test
|
|
59
|
+ public void testGetApples() {
|
|
60
|
+ Items appleItems = items.getApples();
|
|
61
|
+ int expected = 1;
|
|
62
|
+ int actual = appleItems.size();
|
|
63
|
+ Assert.assertEquals(expected, actual);
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ @Test
|
|
67
|
+ public void testGetMilkPrices() {
|
|
68
|
+ Items milkItems = items.getMilks();
|
|
69
|
+ HashMap<Double, Integer> milkPrices = milkItems.getPriceCount();
|
|
70
|
+ Assert.assertEquals(2, (int) milkPrices.get(3.40));
|
|
71
|
+ Assert.assertEquals(1, (int) milkPrices.get(1.45));
|
|
72
|
+ }
|
|
73
|
+}
|