package com.twu.biblioteca.service;

import com.twu.biblioteca.entity.Book;
import com.twu.biblioteca.entity.Library;
import com.twu.biblioteca.entity.User;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class LibraryServiceTest {

    private LibraryService libraryService;

    @Before
    public void initLibraryService() {

        libraryService = new LibraryService();
    }

    @Test
    public void canInitUsersTest() {

        User user = new User("zhzhang", "1111", "customer");
        assertEquals(user.getName(), libraryService.initUsers().get(0).getName());
        assertEquals(user.getPassword(), libraryService.initUsers().get(0).getPassword());
    }

    @Test
    public void canInitBooksTest() {

        Book book = new Book("Refactoring: Improving the Design of Existing Code", "Martin Fowler", "July 8, 1999");
        assertEquals(book.getName(), libraryService.initBooks().get(0).getName());
        assertEquals(book.getAuthor(), libraryService.initBooks().get(0).getAuthor());
    }

    @Test
    public void canShowWelcomeMessageTest() {

        String welcomeMessage = "----------   WELCOME TO BIBLIOTECA   ----------";
        assertEquals(welcomeMessage, libraryService.showWelcomeMessage());
    }

    @Test
    public void canShowMainMenuForCustomerTest() {

        String welcomeMessage = "----------   Main  Menu   ----------\n" +
                                "\n[0] Exit BIBLIOTECA\n" +
                                "[1] List Books of Library\n" +
                                "[2] Check Out Book\n" +
                                "[3] Return Book\n" +
                                "\nPlease Enter Your Choice :";
        assertEquals(welcomeMessage, libraryService.showMainMenuForCustomer());
    }

    @Test
    public void canShowBooksOfLibraryTest() {

        Library library = new Library(libraryService);
        libraryService.showBooksOfLibrary(library);
    }

//    @Test
//    public void canCheckOutBookTest() {
//
//        libraryService.checkOutBook();
//    }
}

@@ -199,16 +199,68 @@
 .Test;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 import s
@@ -764,32 +764,459 @@
 word());%0A    %7D%0A%0A
+    @Test%0A    public void canGetAvailableBooks() %7B%0A%0A        Book book = new Book(%22Refactoring: Improving the Design of Existing Code%22, %22Martin Fowler%22, %22July 8, 1999%22);%0A        book.setIsBorrowed(true);%0A        List%3CBook%3E books = new ArrayList%3CBook%3E();%0A        books.add(book);%0A        System.out.println(libraryService.getAvailableBooks(books));%0A        assertEquals(0, libraryService.getAvailableBooks(books).size());%0A    %7D%0A%0A
     @Test%0A    pu
@@ -2394,24 +2394,26 @@
 ryService);%0A
+//
         libr

complete test canGetAvailbleBooks codes