package com.twu.biblioteca;

import com.twu.model.menuoption.InvalidMenuOption;
import com.twu.model.menuoption.ListBooksMenuOption;
import com.twu.model.menuoption.MenuOption;
import com.twu.model.menuoption.QuitMenuOption;
import com.twu.io.output.ConsoleOutput;
import org.junit.Before;
import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class MenuTest {

    private Menu menu;

    @Before
    public void setUp(){
        menu = new Menu();
    }

    @Test
    public void shouldReturnMenuOptions(){
        ArrayList<String> expectedMenuOptions = getMenuOptions();
        ConsoleOutput expectedOutput = new ConsoleOutput(expectedMenuOptions);

        ConsoleOutput output = menu.getMenuOptions();

        assertEquals(expectedOutput, output);
    }

    private ArrayList<String> getMenuOptions() {
        ArrayList<String> expectedMenuOptions = new ArrayList<>();
        expectedMenuOptions.add("Menu\n");
        expectedMenuOptions.add("\t1. List Books");
        expectedMenuOptions.add("\t2. Quit");
        expectedMenuOptions.add("\nPlease enter your choice : ");
        return expectedMenuOptions;
    }

    @Test
    public void
    shouldReturnListBooksMenuOptionFromMenuOptionInputChoiceForListBooks(){
        MenuOption listBooksMenuOption = menu.getMenuForOption("1");
        assertTrue(listBooksMenuOption instanceof ListBooksMenuOption);
    }

    @Test
    public void shouldReturnQuitMenuOptionFromMenuOptionInputChoiceForQuit(){
        MenuOption quitMenuOption = menu.getMenuForOption("2");
        assertTrue(quitMenuOption instanceof QuitMenuOption);
    }

    @Test
    public void
    shouldReturnInvalidMenuOptionFromMenuOptionInputChoiceWhichIsInvalid(){
        MenuOption invalidMenuOption = menu.getMenuForOption("0");
        assertTrue(invalidMenuOption instanceof InvalidMenuOption);
    }
}

@@ -419,19 +419,114 @@
 .assertT
-rue
+hat;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.hamcrest.CoreMatchers.instanceOf
 ;%0A%0Apubli
@@ -1423,26 +1423,22 @@
         
-MenuOption
+String
  listBoo
@@ -1456,34 +1456,11 @@
 n = 
-menu.getMenuForOption(
 %221%22
-)
 ;%0A  
@@ -1476,31 +1476,81 @@
 ertT
-rue(listBooksMenuOption
+hat(menu.getMenuForOption(listBooksMenuOption),%0A                         
  ins
@@ -1554,19 +1554,19 @@
 instance
-of 
+Of(
 ListBook
@@ -1568,32 +1568,39 @@
 tBooksMenuOption
+.class)
 );%0A    %7D%0A%0A    @T
@@ -1689,26 +1689,22 @@
         
-MenuOption
+String
  quitMen
@@ -1717,34 +1717,11 @@
 n = 
-menu.getMenuForOption(
 %222%22
-)
 ;%0A  
@@ -1737,26 +1737,66 @@
 ertT
-rue(quitMenuOption
+hat(menu.getMenuForOption(quitMenuOption),%0A               
  ins
@@ -1800,19 +1800,19 @@
 instance
-of 
+Of(
 QuitMenu
@@ -1809,32 +1809,39 @@
 f(QuitMenuOption
+.class)
 );%0A    %7D%0A%0A    @T
@@ -1944,26 +1944,22 @@
         
-MenuOption
+String
  invalid
@@ -1975,34 +1975,11 @@
 n = 
-menu.getMenuForOption(
 %220%22
-)
 ;%0A  
@@ -1995,29 +1995,39 @@
 ertT
-rue(invalid
+hat(menu.get
 Menu
+For
 Option
+(%220%22),
  ins
@@ -2035,11 +2035,11 @@
 ance
-of 
+Of(
 Inva
@@ -2051,16 +2051,23 @@
 nuOption
+.class)
 );%0A    %7D

Refactor assertions to make them more readable