-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathPetUtilsTest.java
More file actions
81 lines (63 loc) · 1.96 KB
/
PetUtilsTest.java
File metadata and controls
81 lines (63 loc) · 1.96 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
package io.zipcoder;
import io.zipcoder.io.zipcoder.pets.Compare;
import io.zipcoder.io.zipcoder.pets.Pet;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
public class PetUtilsTest {
@Test
public void printList() {
//Given
PetUtils utils = new PetUtils();
//When
utils.addPet("Hugo", "Dog");
utils.addPet("Bob", "Cat");
//Then
String expected = ("[[Hugo, Dog], [Bob, Cat]]");
String actual = utils.printList();
Assert.assertEquals(expected, actual);
}
@Test
public void setNumberOfPets() {
//Given
PetUtils petUtils = new PetUtils();
petUtils.addPet("Hugo", "Dog");
petUtils.addPet("Bob", "Cat");
petUtils.addPet("John", "Unicorn");
int expected = 3;
petUtils.setNumberOfPets(expected);
//When
int actual = petUtils.getNumberOfPets();
//Then
Assert.assertEquals(expected, actual);
}
@Test
public void addPet() {
//Given
PetUtils utils = new PetUtils();
utils.addPet("Hugo", "Dog");
String expected = ("[Hugo, Dog]");
String actual = utils.pets.get(0).toString();
Assert.assertEquals(expected, actual);
}
@Test
public void containsPet() {
PetUtils utils = new PetUtils();
utils.addPet("Bob", "Cat");
Assert.assertTrue(utils.containsPet("Bob", "Cat"));
}
@Test
public void compare(){
//Given
Compare compare = new Compare();
PetUtils petUtils = new PetUtils();
petUtils.addPet("Hugo", "Dog");
petUtils.addPet("Bob", "Cat");
petUtils.addPet("John", "Unicorn");
Collections.sort(petUtils.getPets(), compare);
String expected = "[[Bob, Cat], [Hugo, Dog], [John, Unicorn]]";
String actual = petUtils.getPets().toString();
Assert.assertEquals(expected, actual);
}
}