package com.twu.biblioteca;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;
import static com.twu.biblioteca.PredefinedBooksDetails.*;

/**
 * Created by qiyuesong on 16/6/15.
 */
public class BookTest {
    private Book bookA, bookB;
    @Before
    public void setup() {
        bookA = new Book(BOOK_FOUR_NAME, BOOK_FOUR_AUTHOR, BOOK_FOUR_PUBLISHING_YEAR);
        bookB = new Book(BOOK_FIVE_NAME, BOOK_FIVE_AUTHOR, BOOK_FIVE_PUBLISHING_YEAR);
    }

    @Test
    public void testIdBookNameIsCorrect() {
        assertEquals(BOOK_FOUR_NAME, bookA.getBookName());
        assertEquals(BOOK_FIVE_NAME, bookB.getBookName());
    }

    @Test
    public void testIfBookAuthorIsCorrect() {
        assertEquals(BOOK_FOUR_AUTHOR, bookA.getAuthor());
        assertEquals(BOOK_FIVE_AUTHOR, bookB.getAuthor());
    }

    @Test
    public void testIfBookPublishingTimeIsCorrect() {
        assertEquals(BOOK_FOUR_PUBLISHING_YEAR, bookA.getPublishingYear());
        assertEquals(BOOK_FIVE_PUBLISHING_YEAR, bookB.getPublishingYear());
    }

    @Test
    public void testBookCheckoutAndCheckInOperations() {
        assertFalse(bookA.getCheckOutStatus());
        bookA.checkOut();
        assertTrue(bookA.getCheckOutStatus());
        bookA.checkIn();
        assertFalse(bookA.getCheckOutStatus());

        assertFalse(bookB.getCheckOutStatus());
        bookB.checkOut();
        assertTrue(bookB.getCheckOutStatus());
        bookB.checkIn();
        assertFalse(bookB.getCheckOutStatus());
    }

    @Test
    public void testBookEquality() {
        assertEquals(bookA, bookA);
        assertNotEquals(bookA, bookB);
    }
}

@@ -514,21 +514,22 @@
 id testI
-d
+f
 Book
+A
 NameIsCo
@@ -593,24 +593,86 @@
 ookName());%0A
+    %7D%0A%0A    @Test%0A    public void testIfBookBNameIsCorrect() %7B%0A
         asse
@@ -762,16 +762,17 @@
 tIfBookA
+A
 uthorIsC
@@ -837,24 +837,89 @@
 tAuthor());%0A
+    %7D%0A%0A    @Test%0A    public void testIfBookBAAuthorIsCorrect() %7B%0A
         asse
@@ -1008,16 +1008,17 @@
 stIfBook
+A
 Publishi
@@ -1109,24 +1109,96 @@
 ingYear());%0A
+    %7D%0A%0A    @Test%0A    public void testIfBookBPublishingTimeIsCorrect() %7B%0A
         asse

break tests for name, author and publishing year in book tests into independent ones