package junit.test;
import static org.junit.Assert.*;
import junit.Book;
import junit.Library;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class JUnit4LibraryTest {
private Library library;
@Before
public void beforeDoTest() throws Exception {
library=new Library();
}
@Test
public void addBookToLibrary() {
Book masterSpring=new Book();
masterSpring.setTitle("master spring");
masterSpring.setAuthor("Sam");
masterSpring.setIntroduce("about spring framework");
library.addBook(masterSpring);
boolean result=library.checkAvailabilityByTitle("master spring");
Assert.assertEquals("The Library have the book master spring ", true,result);
}
@Test
public void bookAvailabilityInLibraryByTitle() {
Book antBook=new Book();
antBook.setTitle("Ant develop and integration reference");
antBook.setAuthor("Sam");
library.addBook(antBook);
boolean result=library.checkAvailabilityByTitle("Ant develop and integration reference");
Assert.assertEquals("The Library have the book 'Ant develop and integration reference'", true,result);
}
@After
public void afterAllTest() throws Exception {
library=null;
}
}