package com.twu.biblioteca;

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

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.LinkedList;

import static com.twu.biblioteca.MainMenuOptionConstants.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * Created by qiyuesong on 18/6/15.
 */
public class MainMenuTest {
    private final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    private MainMenu menu;

    @Before
    public void setup() {
        System.setOut(new PrintStream(outStream));

        LinkedList<String> menuList = new LinkedList<String>();
        menuList.add(MAIN_MENU_LIST_BOOKS_OPTION);
        menu = new MainMenu(menuList);
    }

    @After
    public void cleanUp() {
        System.setOut(null);
    }

    @Test
    public void testMenuList(){
        assertEquals(1, menu.getMenuList().size());
        assertTrue(menu.getMenuList().contains(MAIN_MENU_LIST_BOOKS_OPTION));
    }

    @Test
    public void testShowMenu(){
        menu.showMainMenu();
        assertEquals("Main Menu\nList Books\n", outStream.toString());
    }
}

@@ -726,16 +726,68 @@
 PTION);%0A
+        menuList.add(MAIN_MENU_LIST_MOVIES_OPTION);%0A
         
@@ -817,16 +817,16 @@
 uList);%0A
-
     %7D%0A%0A 
@@ -962,17 +962,17 @@
 tEquals(
-1
+2
 , menu.g
@@ -1145,24 +1145,24 @@
 MainMenu();%0A
-
         asse
@@ -1193,16 +1193,29 @@
 t Books%5C
+nList Movies%5C
 n%22, outS

update main menu class tests to support list movies operation