-
Notifications
You must be signed in to change notification settings - Fork 176
/
PeopleCounterTests.java
42 lines (35 loc) · 1.05 KB
/
PeopleCounterTests.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
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
final class ExerciseTests {
@Test
void counterStartsAtZero() {
var counter = new PeopleCounter(10);
assertThat(counter.value(), is(0));
}
@Test
void counterIncrementAdds1ToValue() {
var counter = new PeopleCounter(10);
counter.increment();
assertThat(counter.value(), is(1));
}
@Test
void counterResetSetsValueTo0() {
var counter = new PeopleCounter(10);
counter.increment();
counter.reset();
assertThat(counter.value(), is(0));
}
@Test
void counterCannotExceedMaximum() {
var counter = new PeopleCounter(1);
counter.increment();
counter.increment();
assertThat(counter.value(), is(1));
}
@Test
void counterMaximumCannotBeBelow0() {
assertThrows(IllegalArgumentException.class, () -> new PeopleCounter(-1));
}
}