-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathCatHouseTest.java
More file actions
116 lines (87 loc) · 2.66 KB
/
CatHouseTest.java
File metadata and controls
116 lines (87 loc) · 2.66 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
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
115
116
package rocks.zipcodewilmington;
import org.junit.Assert;
import org.junit.Test;
import rocks.zipcodewilmington.animals.Cat;
import rocks.zipcodewilmington.animals.animal_storage.CatHouse;
import java.util.Date;
/**
* @author leon on 4/19/18.
*/
public class CatHouseTest {
// TODO - Create tests for `void add(Cat cat)`
// TODO - Create tests for `void remove(Integer id)`
// TODO - Create tests for `void remove(Cat cat)`
// TODO - Create tests for `Cat getCatById(Integer id)`
// TODO - Create tests for `Integer getNumberOfCats()`
@Test
public void addCatTest(){
// Given
String givenName = "Garfield";
Date givenBirthDate = new Date();
Integer givenId = 0;
CatHouse.clear();
// When
Cat cat = new Cat(givenName, givenBirthDate, givenId);
CatHouse.add(cat);
int actual = CatHouse.getNumberOfCats();
// Then
Assert.assertEquals(1, actual);
}
@Test
public void removeCatByIdTest() {
// Given
String givenName = "Garfield";
Date givenBirthDate = new Date();
Integer givenId = 0;
CatHouse.clear();
// When
Cat cat = new Cat(givenName, givenBirthDate, givenId);
CatHouse.remove(0);
int actual = CatHouse.getNumberOfCats();
// Then
Assert.assertEquals(0, actual);
Assert.assertNull(CatHouse.getCatById(0));
}
@Test
public void removeCatTest() {
// Given
String givenName = "Garfield";
Date givenBirthDate = new Date();
Integer givenId = 0;
CatHouse.clear();
// When
Cat cat = new Cat(givenName, givenBirthDate, givenId);
CatHouse.remove(cat);
int actual = CatHouse.getNumberOfCats();
// Then
Assert.assertEquals(0, actual);
}
@Test
public void getCatByIdTest() {
// Given
CatHouse.clear();
String givenName = "Garfield";
Date givenBirthDate = new Date();
Integer givenId = 2;
Cat cat = new Cat(givenName, givenBirthDate, givenId);
CatHouse.add(cat);
// When
Cat actual = CatHouse.getCatById(givenId);
// Then
Assert.assertEquals(cat, actual);
}
@Test
public void getNumberOfCatsTest () {
// Given
CatHouse.clear();
String givenName = "Garfield";
Date givenBirthDate = new Date();
Integer givenId = 2;
Cat cat = new Cat(givenName, givenBirthDate, givenId);
CatHouse.add(cat);
// When
int actual = CatHouse.getNumberOfCats();
// Then
Assert.assertEquals(1, actual);
}
}