forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBirdWatcherTest.java
More file actions
109 lines (96 loc) · 4.15 KB
/
Copy pathBirdWatcherTest.java
File metadata and controls
109 lines (96 loc) · 4.15 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
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BirdWatcherTest {
@Test
@Tag("task:1")
@DisplayName("The getLastWeek method correctly returns last week's counts")
public void itTestGetLastWeek() {
assertThat(BirdWatcher.getLastWeek()).isEqualTo(new int[] {0, 2, 5, 3, 7, 8, 4});
}
@Test
@Tag("task:2")
@DisplayName("The getToday method correctly returns today's counts")
public void itTestGetToday() {
int[] counts = new int[] {8, 8, 9, 5, 4, 7, 10};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.getToday()).isEqualTo(10);
}
@Test
@Tag("task:3")
@DisplayName("The incrementTodaysCount method correctly increments today's counts")
public void itIncrementTodaysCount() {
int[] counts = new int[] {8, 8, 9, 2, 1, 6, 4};
BirdWatcher birdWatcher = new BirdWatcher(counts);
birdWatcher.incrementTodaysCount();
assertThat(birdWatcher.getToday()).isEqualTo(5);
}
@Test
@Tag("task:4")
@DisplayName("The hasDayWithoutBirds method returns true when at least one day had no visits")
public void itHasDayWithoutBirds() {
int[] counts = new int[] {5, 5, 4, 0, 7, 6, 7};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.hasDayWithoutBirds()).isTrue();
}
@Test
@Tag("task:4")
@DisplayName("The hasDayWithoutBirds method returns false when no day had zero visits")
public void itShouldNotHaveDaysWithoutBirds() {
int[] counts = new int[] {4, 5, 9, 10, 9, 4, 3};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.hasDayWithoutBirds()).isFalse();
}
@Test
@Tag("task:4")
@DisplayName("The hasDayWithoutBirds method returns true if the last day has zero visits")
public void itHasLastDayWithoutBirds() {
int[] counts = new int[] {1, 2, 5, 3, 7, 8, 0};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.hasDayWithoutBirds()).isTrue();
}
@Test
@Tag("task:5")
@DisplayName("The getCountForFirstDays method returns correct visits' count for given number of days")
public void itTestGetCountForFirstDays() {
int[] counts = new int[] {5, 9, 12, 6, 8, 8, 17};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.getCountForFirstDays(4)).isEqualTo(32);
}
@Test
@Tag("task:5")
@DisplayName("The getCountForFirstDays method returns overall count when number of days is higher than array size")
public void itTestGetCountForMoreDaysThanTheArraySize() {
int[] counts = new int[] {5, 9, 12, 6, 8, 8, 17};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.getCountForFirstDays(10)).isEqualTo(65);
}
@Test
@Tag("task:5")
@DisplayName("The incrementTodaysCount method adds one to getCountForFirstDays method")
public void itIncrementDoesNotChangeCountForOtherDays() {
int[] counts = new int[] {5, 1, 0, 4, 2, 3, 0};
BirdWatcher birdWatcher = new BirdWatcher(counts);
int countPriorIncrement = birdWatcher.getCountForFirstDays(7);
birdWatcher.incrementTodaysCount();
int countAfterIncrement = birdWatcher.getCountForFirstDays(7);
assertThat(countPriorIncrement).isEqualTo(countAfterIncrement - 1);
}
@Test
@Tag("task:6")
@DisplayName("The getBusyDays method returns the correct count of busy days")
public void itTestGetCountForBusyDays() {
int[] counts = new int[] {4, 9, 5, 7, 8, 8, 2};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.getBusyDays()).isEqualTo(5);
}
@Test
@Tag("task:6")
@DisplayName("The getBusyDays method correctly returns zero in case of no busy days")
public void itShouldNotHaveBusyDays() {
int[] counts = new int[] {1, 2, 3, 3, 2, 1, 4};
BirdWatcher birdWatcher = new BirdWatcher(counts);
assertThat(birdWatcher.getBusyDays()).isEqualTo(0);
}
}