Browse Source

Added getSize() method to MenuManager with test

feature-menu
Nick Stolbov 3 years ago
parent
commit
08f8fbc596
  1. 6
      src/main/java/Application/MenuManager.java
  2. 9
      src/test/java/Application/MenuManagerTest.java

6
src/main/java/Application/MenuManager.java

@ -16,6 +16,12 @@ public class MenuManager {
menuList.add(menu);
}
public int getSize() {
if(inRootMenu())
return menuList.size();
return currentMenu.getSubMenuList().size();
}
public void select(int i) {
if (currentMenu == null)
this.currentMenu = menuList.get(i);

9
src/test/java/Application/MenuManagerTest.java

@ -73,4 +73,13 @@ class MenuManagerTest {
mm.select(0);
assertEquals(mm.getFormattedMenuList(), "1: Menu1.1\n");
}
@Test
void getSize() {
assertEquals(mm.getSize(), 2);
mm.select(0);
assertEquals(mm.getSize(), 1);
mm.select(0);
assertEquals(mm.getSize(), 0);
}
}
Loading…
Cancel
Save