-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.java
114 lines (99 loc) · 3.25 KB
/
tests.java
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package junittests;
import static org.junit.Assert.*;
import java.sql.Array;
import java.util.ArrayList;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import model.Donor;
import model.Inventory;
import model.Item;
import model.Recipient;
import view.DonorHomePage;
/**
* Author Artem Davtyan - [email protected]
*/
public class tests {
//Donor tests
public int postest = 1;
//bad values
public Donor badDonerinstace = new Donor("Good", "lastName", "DOBMonth", "DOBDay", "DOBYear",
"gender", "street", "city", "state", "zip", "email", "username", "password");
public Donor goodDonerinstace = new Donor("Bad", "lastName", "DOBMonth", "DOBDay", "DOBYear",
"gender", "street", "city", "state", "zip", "email", "username", "password");
//Item Tests
public Item donorBasicItem = new Item("Ham", "Food", 3, 7.00);
//Item Array#1
public ArrayList<Item> myItemArray = new ArrayList<>();
//Item Array#2
public ArrayList<Item> mySecondItemArray = new ArrayList<>();
//Recipient Tests
public Recipient goodrecipientTest = new Recipient("Good", "lastName", "DOBMonth", "DOBDay", "DOBYear",
"gender", "street", "city", "state", "zip", "email", "username", "password");
public Recipient badRecipientTest = new Recipient("Bad", "lastName", "DOBMonth", "DOBDay", "DOBYear",
"gender", "street", "city", "state", "zip", "email", "username", "password");
@Before
public void setUp() throws Exception {
}
//Objects
@Test
public final void testDonorObjectsEquality() {
//equality with a new doner
assertNotEquals(badDonerinstace, new Donor("Tester", "lastName", "DOBMonth", "DOBDay", "DOBYear",
"gender", "street", "city", "state", "zip", "email", "username", "password"));
//object with changed strings
assertNotEquals(badDonerinstace, goodDonerinstace);
}
//Donor
@Test
public final void testAddDonatedItem() {
//is donor size more than 3 now?
donorBasicItem.quantity++;
myItemArray.add(donorBasicItem);
myItemArray.add(donorBasicItem);
myItemArray.add(donorBasicItem);
assertEquals(myItemArray.size(), 3);
}
//Item
@Test
public final void testQuantitySuccess() {
int pos = 1;
if(donorBasicItem.quantity > pos )
{
assertTrue(true);
}
}
//Donor
@Test
public final void testQuantityFalirures() {
//Test positions and quality of objects
int pos = 1;
if(donorBasicItem.quantity < pos )
{
assertTrue(false);
}
}
//Recipient
@Test
public void testRecipient() {
//Check if recipients and Donors are the same
assertNotSame(goodDonerinstace, goodrecipientTest);
//They are not of the same type or instance, so
//they shouldn't be the same, even when the strings are.
assertNotSame(badDonerinstace, badRecipientTest);
//Test our objects
assertNotSame(badDonerinstace, goodDonerinstace);
}
@Test
public void testEquals() {
//Check against two way errors for the instances
assertNotEquals(badDonerinstace, goodDonerinstace);
assertNotEquals(badDonerinstace, badRecipientTest);
assertNotEquals(goodDonerinstace, goodrecipientTest);
}
//Donor, Item, Recipient
@Test
public void testToString() {
assertNotEquals(goodrecipientTest.toString(), goodDonerinstace.toString());
}
}