|
|
@ -0,0 +1,38 @@ |
|
|
|
package Application; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.AfterEach; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
class MenuManagerTest { |
|
|
|
|
|
|
|
MenuManager mm; |
|
|
|
Menu rootMenu; |
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
void setUp() { |
|
|
|
rootMenu = new Menu("Root"); |
|
|
|
Menu menu1 = new Menu("Menu1"); |
|
|
|
Menu menu2 = new Menu("Menu2"); |
|
|
|
Menu menu1_1 = new Menu("Menu1.1"); |
|
|
|
menu1.addMenu(menu1_1); |
|
|
|
rootMenu.addMenu(menu1); |
|
|
|
rootMenu.addMenu(menu2); |
|
|
|
mm = new MenuManager(rootMenu); |
|
|
|
} |
|
|
|
|
|
|
|
@AfterEach |
|
|
|
void tearDown() { |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void testSelectFunction(){ |
|
|
|
assertEquals(mm.getCurrentMenu(), rootMenu); |
|
|
|
mm.select(0); |
|
|
|
assertEquals(mm.getCurrentMenu(), rootMenu.getMenu(0)); |
|
|
|
mm.select(0); |
|
|
|
assertEquals(mm.getCurrentMenu(), rootMenu.getMenu(0).getMenu(0)); |
|
|
|
} |
|
|
|
} |