package com.twu.biblioteca.service;

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

import java.util.ArrayList;
import java.util.List;

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 -----\n";
        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() {

        List<Book> books = new ArrayList<Book>();
        libraryService.showBooksOfLibrary(books);
    }

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

@@ -69,16 +69,58 @@
 y.Book;%0A
+import com.twu.biblioteca.entity.Library;%0A
 import c
@@ -1914,45 +1914,50 @@
   Li
-st%3CBook%3E books = new ArrayList%3CBook%3E(
+brary library = new Library(libraryService
 );%0A 
@@ -2001,13 +2001,15 @@
 ary(
-books
+library
 );%0A 

correct LibraryService books