forked from sh-vasily/java-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LibraryImplTest.java
39 lines (30 loc) · 1.23 KB
/
LibraryImplTest.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
import org.junit.jupiter.api.Test;
import ru.msu.vmk.Book;
import ru.msu.vmk.LibraryImpl;
import org.junit.jupiter.api.Assertions;
public class LibraryImplTest {
@Test
public void addBookTest(){
var library = new LibraryImpl();
library.addNewBook(new Book("book"));
var availableBooks = library.findAvailableBooks();
Assertions.assertEquals(1, availableBooks.size());
Assertions.assertEquals("book", availableBooks.get(0).getTitle());
}
@Test
public void borrowAndReturnBookTest(){
var library = new LibraryImpl();
var book = new Book("book");
library.addNewBook(book);
var availableBooks = library.findAvailableBooks();
Assertions.assertEquals(1, availableBooks.size());
Assertions.assertEquals("book", availableBooks.get(0).getTitle());
library.borrowBook(book, "student");
availableBooks = library.findAvailableBooks();
Assertions.assertEquals(0, availableBooks.size());
library.returnBook(book, "student");
availableBooks = library.findAvailableBooks();
Assertions.assertEquals(1, availableBooks.size());
Assertions.assertEquals("book", availableBooks.get(0).getTitle());
}
}