public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new NumberInputMenu("foo", _input, _output, MinValue, MaxValue); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menu = new KeysOffOwnerNumberInputMenu("foo", _input, _output); _owner = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _ownerTeam = new TestTeam(_owner); _enemyTeam = new TestTeam((TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1)); }
private static bool Foo() { SelectEnemyTeamMenuManager enemyTeamGenerator = new SelectEnemyTeamMenuManager(Globals.Input, Globals.Output); BattleConfigurationSpecialFlag battleFlag; Team enemyTeam = enemyTeamGenerator.GetTeam(new MenuManager(Globals.Input, Globals.Output, Globals.MenuFactory), Globals.Input, Globals.Output, out battleFlag); NumberInputMenu levelInputMenu = new NumberInputMenu("What levels will your fighters be (min 1. Max 5)?", Globals.Input, Globals.Output, 1, 5); NumberInputMenuSelection levelInput = levelInputMenu.GetInput() as NumberInputMenuSelection; if (levelInput == null) { throw new Exception("something went terribly wrong, a NumberInputMenu did not return a NumberInputMenuSelection"); } int level = levelInput.Number; var playerOne = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, level, "Dante"); var playerTwo = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, level, "Arrokoh"); var playerTeam = new Team(new MenuManager(Globals.Input, Globals.Output, Globals.MenuFactory), playerOne, playerTwo); BattleMove doNothing = MoveFactory.Get(BattleMoveType.DoNothing); BattleMove feintAttack = MoveFactory.Get(BattleMoveType.Attack, "feint"); BattleMove shieldBuster = MoveFactory.Get(BattleMoveType.ShieldBuster); foreach (HumanFighter fighter in playerTeam.Fighters) { fighter.AddMove(doNothing); fighter.AddMove(feintAttack); fighter.AddMove(shieldBuster); } FakeBattleManager manager = new FakeBattleManager(Globals.ChanceService, Globals.Input, Globals.Output); manager.Battle(playerTeam, enemyTeam, config: new BattleManagerBattleConfiguration { SpecialBattleFlag = battleFlag }); return(true); }
public void CorrectlyReplacesMinAndMaxStringPlaceholders([Values(1, 3)] int minValue, [Values(4, 9)] int maxValue) { string promptBeforeReplacement = $"min: {Globals.MinValueReplacementString}, max: {Globals.MaxValueReplacementString}"; string minValueAsString = minValue.ToString(); string maxValueAsString = maxValue.ToString(); NumberInputMenu menu = new NumberInputMenu(promptBeforeReplacement, _input, _output, minValue, maxValue); _input.Push(minValueAsString); menu.GetInput(); MockOutputMessage output = _output.GetOutputs()[0]; string expectedOutput = promptBeforeReplacement.Replace(Globals.MinValueReplacementString, minValueAsString); expectedOutput = expectedOutput.Replace(Globals.MaxValueReplacementString, maxValueAsString); Assert.AreEqual(expectedOutput + "\n", output.Message); }
public void CorrectlyDisallowsNonNumberInput() { _menu = new NumberInputMenu("", _input, _output, 0, 5); _input.Push("abc", "f12", "1"); _menu.GetInput(); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.AreEqual(5, outputs.Length); MockOutputMessage output = outputs[1]; const string nonNumberError = "input not recognized as a number\n"; Assert.AreEqual(nonNumberError, output.Message); Assert.AreEqual(ConsoleColor.Red, Globals.ErrorColor); output = outputs[3]; Assert.AreEqual(nonNumberError, output.Message); Assert.AreEqual(ConsoleColor.Red, Globals.ErrorColor); }