/
BookSetIdentifierShould.java
38 lines (28 loc) · 1.07 KB
/
BookSetIdentifierShould.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
package com.gnorsilva;
import org.junit.Test;
import static com.gnorsilva.PotterBooks.*;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class BookSetIdentifierShould {
@Test
public void identify_a_single_book_set_as_one_book() throws Exception {
BookSetIdentifier identifier = new BookSetIdentifier(new Order(A));
int numberOfUniqueBooks = identifier.nextNumberOfUniqueBooks();
assertThat(numberOfUniqueBooks, is(1));
}
@Test
public void identify_two_identical_books_as_two_sets_of_one_book() throws Exception {
BookSetIdentifier identifier = new BookSetIdentifier(new Order(A,A));
assertThat(identifier.nextNumberOfUniqueBooks(), is(1));
assertThat(identifier.nextNumberOfUniqueBooks(), is(1));
}
private class BookSetIdentifier {
private final Order order;
public BookSetIdentifier(Order order) {
this.order = order;
}
public int nextNumberOfUniqueBooks() {
return order.getNumberOfBooks();
}
}
}