@Test public void testThatWhenMainMenuIsNotPresentThenAddMainMenuPerformsReplaceAndCommit() { givenThatMainMenuIsNotPresent(); menuSwitcher.addMainMenu(); InOrder inOrder = inOrder(fragmentTransaction, fragmentTransaction); inOrder.verify(fragmentTransaction).replace(eq(R.id.menu_container), any(MainMenuFragment.class), eq(MainMenuFragment.TAG)); inOrder.verify(fragmentTransaction).commit(); }
public MainMenu addMainMenu() { if (mainMenuIsPresent()) { return Classes.from(fragmentManager.findFragmentByTag(MainMenuFragment.TAG)); } else { MainMenu mainMenu = new MainMenuFragment(); fragmentManager.beginTransaction().replace(R.id.menu_container, mainMenu.getFragment(), MainMenuFragment.TAG).commit(); return mainMenu; } }
MenuSwitcher { public MainMenu addMainMenu() { if (mainMenuIsPresent()) { return Classes.from(fragmentManager.findFragmentByTag(MainMenuFragment.TAG)); } else { MainMenu mainMenu = new MainMenuFragment(); fragmentManager.beginTransaction().replace(R.id.menu_container, mainMenu.getFragment(), MainMenuFragment.TAG).commit(); return mainMenu; } } }
MenuSwitcher { public MainMenu addMainMenu() { if (mainMenuIsPresent()) { return Classes.from(fragmentManager.findFragmentByTag(MainMenuFragment.TAG)); } else { MainMenu mainMenu = new MainMenuFragment(); fragmentManager.beginTransaction().replace(R.id.menu_container, mainMenu.getFragment(), MainMenuFragment.TAG).commit(); return mainMenu; } } @VisibleForTesting protected  MenuSwitcher(FragmentManager fragmentManager); }
MenuSwitcher { public MainMenu addMainMenu() { if (mainMenuIsPresent()) { return Classes.from(fragmentManager.findFragmentByTag(MainMenuFragment.TAG)); } else { MainMenu mainMenu = new MainMenuFragment(); fragmentManager.beginTransaction().replace(R.id.menu_container, mainMenu.getFragment(), MainMenuFragment.TAG).commit(); return mainMenu; } } @VisibleForTesting protected  MenuSwitcher(FragmentManager fragmentManager); static MenuSwitcher newInstance(); MainMenu addMainMenu(); WorldEditorMenu addEditorMenu(); ImageLoader addImageLoader(); }
MenuSwitcher { public MainMenu addMainMenu() { if (mainMenuIsPresent()) { return Classes.from(fragmentManager.findFragmentByTag(MainMenuFragment.TAG)); } else { MainMenu mainMenu = new MainMenuFragment(); fragmentManager.beginTransaction().replace(R.id.menu_container, mainMenu.getFragment(), MainMenuFragment.TAG).commit(); return mainMenu; } } @VisibleForTesting protected  MenuSwitcher(FragmentManager fragmentManager); static MenuSwitcher newInstance(); MainMenu addMainMenu(); WorldEditorMenu addEditorMenu(); ImageLoader addImageLoader();  }