public IMenu GetMenu(MenuType type, IInput menuInput = null, IOutput menuOutput = null, bool allowBack = false, bool allowHelp = true, bool allowStatus = true, string prompt = "", string errorText = "", string helpText = "", List <MenuAction> menuActions = null, List <MenuAction> specialMenuActions = null, bool shuffleOptions = false, IChanceService chanceService = null, IMenu subMenu = null) { IMenu ret; IMenu realFactoryMenu = _menuFactory.GetMenu(type, menuInput, menuOutput, allowBack, allowHelp, allowStatus, prompt, errorText, helpText, menuActions, specialMenuActions, shuffleOptions, chanceService, subMenu); if (!_returnMenus.ContainsKey(type) || _returnMenus[type].Count == 0) { ret = realFactoryMenu; } else { ret = _returnMenus[type].Dequeue(); MockMenu retAsMockMenu = ret as MockMenu; if (retAsMockMenu != null) { retAsMockMenu.SetMenuActions(menuActions); retAsMockMenu.SetOutput(menuOutput); retAsMockMenu.SetPrompt(prompt); retAsMockMenu.SetInnerMenu(realFactoryMenu); } } return(ret); }
public void CorrectlyPassesBattleMove_SubMenuRequiresBattleMove() { MockMenu mockSubMenu = new MockMenu(requiresBattleMoveInput: true, input: _menuInput, output: _menuOutput); mockSubMenu.SetNextSelection(new MenuSelection[] { null }); MenuSelection expectedMenuSelection = new MenuSelection("foo", new DoNothingMove(), null); mockSubMenu.SetNextBattleMoveRequiredSelection(expectedMenuSelection); List <MenuAction> menuActions = new List <MenuAction> { new MenuAction("fight", move: new DoNothingMove(), subMenu: mockSubMenu) }; Menu menu = new Menu(false, false, false, "pick one", Globals.GenericErrorMessage, null, menuActions, _menuInput, _menuOutput); BuildMenu(menu); _menuInput.Push("1"); MenuSelection returnedSelection = menu.GetInput(); Assert.NotNull(returnedSelection); Assert.AreEqual(expectedMenuSelection, returnedSelection); }
public void GetInput_ReturnsCorrectMenuSelection_SubMenuRequiresBattleMoveInput() { //arrange MockMenu mockTargetMenu = new MockMenu(requiresBattleMoveInput: true, input: _input, output: _output); mockTargetMenu.SetEchoMode(); KeysOffOwnerNumberInputMenu menu = new KeysOffOwnerNumberInputMenu("foo", _input, _output, mockTargetMenu); int expectedReturnedNumber = 1; _owner.SetHealth(expectedReturnedNumber + 1); menu.Build(_owner, _ownerTeam, _enemyTeam, null); _input.Push(expectedReturnedNumber.ToString()); BattleMove eatPotatoMove = new DoNothingMove("eats a potato"); //act NumberInputMenuSelection returnedSelection = menu.GetInput(eatPotatoMove, null) as NumberInputMenuSelection; //assert Assert.NotNull(returnedSelection); Assert.AreEqual(expectedReturnedNumber, returnedSelection.Number); Assert.AreEqual(eatPotatoMove, returnedSelection.Move); }
private void PickNextArea_MenuSetup_DesertGroupings(WorldSubRegion firstMenuSelection, WorldSubRegion secondMenuSelection, out MockMenu firstMenu, out MockMenu secondMenu) { firstMenu = new MockMenu(); firstMenu.SetChanceService(_chanceService); firstMenu.SetNextSelection(new TypedMenuSelection <WorldSubRegion>(firstMenuSelection, "", null, null)); secondMenu = new MockMenu(); secondMenu.SetChanceService(_chanceService); secondMenu.SetNextSelection(new TypedMenuSelection <WorldSubRegion>(secondMenuSelection, "", null, null)); _menuFactory.SetMenu(MenuType.NonSpecificMenu, firstMenu); _menuFactory.SetMenu(MenuType.NonSpecificMenu, secondMenu); _chanceService.SetShuffleIndices(new [] { 0, 1, 2 }); _chanceService.SetShuffleIndices(new [] { 0, 1, 2 }); }
private void PickNextArea_MenuSetup_RegionalGroupings(WorldRegion firstMenuSelection, out MockMenu menu) { menu = new MockMenu(); menu.SetNextSelection(new TypedMenuSelection <WorldRegion>(firstMenuSelection, "", null, null)); _menuFactory.SetMenu(MenuType.NonSpecificMenu, menu); }