-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBirdWatcherTest.java
More file actions
83 lines (66 loc) · 2.31 KB
/
BirdWatcherTest.java
File metadata and controls
83 lines (66 loc) · 2.31 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
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
public class BirdWatcherTest {
private static final int DAY1 = 0;
private static final int DAY2 = 2;
private static final int DAY3 = 5;
private static final int DAY4 = 3;
private static final int DAY5 = 7;
private static final int DAY6 = 8;
private static final int TODAY = 4;
private BirdWatcher birdWatcher;
private int lastWeek[] = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY};
@Before
public void setUp() {
birdWatcher = new BirdWatcher(lastWeek);
}
@Test
public void itTestGetLastWeek() {
assertThat(birdWatcher.getLastWeek())
.containsExactly(DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY);
}
@Test
public void itTestGetToday() {
assertThat(birdWatcher.getToday()).isEqualTo(TODAY);
}
@Test
public void itShouldReturnZeroIfBirdWatcherLastWeekIsEmpty() {
int[] lastWeekEmpty = new int[0];
birdWatcher = new BirdWatcher(lastWeekEmpty);
assertThat(birdWatcher.getToday()).isEqualTo(0);
}
@Test
public void itIncrementTodaysCount() {
birdWatcher.incrementTodaysCount();
assertThat(birdWatcher.getToday()).isEqualTo(TODAY + 1);
}
@Test
public void itHasDayWithoutBirds() {
assertThat(birdWatcher.hasDayWithoutBirds()).isTrue();
}
@Test
public void itShouldNotHaveDaysWithoutBirds() {
birdWatcher = new BirdWatcher(new int[]{1, 2, 5, 3, 7, 8, 4});
assertThat(birdWatcher.hasDayWithoutBirds()).isFalse();
}
@Test
public void itTestGetCountForFirstDays() {
assertThat(birdWatcher.getCountForFirstDays(4)).isEqualTo(DAY1 + DAY2 + DAY3 + DAY4);
}
@Test
public void itTestGetCountForMoreDaysThanTheArraySize() {
assertThat(birdWatcher.getCountForFirstDays(10))
.isEqualTo(DAY1 + DAY2 + DAY3 + DAY4 + DAY5 + DAY6 + TODAY);
}
@Test
public void itTestGetCountForBusyDays() {
// DAY3, DAY5 and DAY6 are all >= 5 birds
assertThat(birdWatcher.getBusyDays()).isEqualTo(3);
}
@Test
public void itShouldNotHaveBusyDays() {
birdWatcher = new BirdWatcher(new int[]{1, 2, 3, 3, 2, 1, 4});
assertThat(birdWatcher.getBusyDays()).isEqualTo(0);
}
}