예제 #1
0
        public void TestGetName_AppropriatelyPrintsError_NoNameSpecified()
        {
            _input.Push("");
            const string expected = "Alkeeros";

            _input.Push(expected);

            var name = _menu.GetName();

            Assert.AreEqual(expected, name);

            var outputs      = _output.GetOutputs();
            var clearIndices = _output.GetClearIndices();

            Assert.AreEqual(3, outputs.Length);

            //0 and 2 index are the prompt
            Assert.AreEqual(NameInputMenu.NameRequiredErrorMessage + "\n", outputs[1].Message);
            Assert.AreEqual(MockOutputMessageType.Error, outputs[1].Type);

            Assert.AreEqual(1, clearIndices.Length);
            Assert.AreEqual(2, clearIndices[0]);
        }
예제 #2
0
        public void CorrectlyPrintsCurscenes()
        {
            //Arrange
            ColorString[] firstSceneLines =
            {
                new ColorString("There once was a man named Gold Roger"),
                new ColorString("He had fame, wealth, and power beyond your wildest dreams"),
                new ColorString("Before they hung him from the gallows,"),
                new ColorString("These were the words he said:")
            };

            SingleScene firstScene = new SingleScene(firstSceneLines);

            ColorString[] secondSceneLines =
            {
                new ColorString("If you want my treasure, you can have it!"),
                new ColorString("I left everything I had in that place")
            };

            SingleScene secondScene = new SingleScene(secondSceneLines);

            SingleScene[] scenes =
            {
                firstScene,
                secondScene
            };

            Cutscene cutscene = new Cutscene(scenes);

            //Act
            cutscene.ExecuteCutscene(_input, _output, (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1), (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1));

            //Assert
            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedNumberOfLines = firstSceneLines.Length + secondSceneLines.Length;

            Assert.AreEqual(expectedNumberOfLines, outputs.Length);

            int[] clearIndices = _output.GetClearIndices();
            Assert.AreEqual(scenes.Length, clearIndices.Length);

            int nextClearIndex = firstSceneLines.Length;

            Assert.AreEqual(nextClearIndex, clearIndices[0]);

            nextClearIndex += secondSceneLines.Length;
            Assert.AreEqual(nextClearIndex, clearIndices[1]);
        }
        public void BattleManagerCorrectlyIdentifiesBellInIntro()
        {
            List <Bell> bells = GetBells(BellType.Copper, BellType.Silver);

            _humanFighter.SetMove(_runawayMove);
            _enemy.SetMove(_doNothingMove);

            _battleManager.Battle(_humanTeam, _enemyTeam, bells.Cast <TerrainInteractable>().ToList());

            MockOutputMessage[] outputs = _output.GetOutputs();

            int bellIntroIndex = 1 + _enemyTeam.Fighters.Count; //"time for a battle" and then each "encountered ____"

            foreach (Bell bell in bells)
            {
                MockOutputMessage output = outputs[bellIntroIndex];

                Assert.AreEqual($"There is a {bell.DisplayName} on the field\n", output.Message);

                bellIntroIndex++;
            }

            Assert.AreEqual(bellIntroIndex, _output.GetClearIndices()[1]);
        }
예제 #4
0
        public void GetInput_ReturnsInputIfValidTextSpecified([Values("fight", "item", "run")] string input)
        {
            _menuInput.Push(input);
            MenuSelection ret = _menu.GetInput();

            var outputs      = _menuOutput.GetOutputs();
            var clearIndices = _menuOutput.GetClearIndices();

            Assert.AreEqual(_fullMenuPromptLength, outputs.Length);

            TestMenuOutput(outputs, 0, clearIndices, 0);

            Assert.AreEqual(input, ret.Description);
        }