Ejemplo n.º 1
0
        public void TestProcessInputCommandInvalid()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                TopScores scores = new TopScores();
                MockLabyrinthBoard testBoard = new MockLabyrinthBoard(closedLabyrinth);
                MockingUserInterface userInterface = new MockingUserInterface();
                userInterface.FakeInput = "ninja";
                testEngine = new Engine(testBoard, scores, userInterface);
                testEngine.Start();

                StringBuilder expectedString = new StringBuilder();
                expectedString.Append("Invalid command");
                expectedString.Append(Environment.NewLine);
                expectedString.Append("\nEnter your move (L=left, R=right, U=up, D=down):");
                expectedString.Append("Good Bye!");
                expectedString.Append(Environment.NewLine);

                string expected = expectedString.ToString();
                string output = sw.ToString();
                output = output.Substring(output.Length - 77);

                Assert.AreEqual<string>(expected, output);
            }
        }
Ejemplo n.º 2
0
        public void TestProcessInputCommandExit()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                TopScores scores = new TopScores();
                MockLabyrinthBoard testBoard = new MockLabyrinthBoard(closedLabyrinth);
                MockingUserInterface userInterface = new MockingUserInterface();
                userInterface.FakeInput = "exit";
                testEngine = new Engine(testBoard, scores, userInterface);
                testEngine.Start();

                StringBuilder expectedString = new StringBuilder();
                expectedString.Append("Good Bye!");
                expectedString.Append(Environment.NewLine);

                string expected = expectedString.ToString();
                string output = sw.ToString();
                output = output.Substring(output.Length - 11);

                Assert.AreEqual<string>(expected, output);
            }
        }
Ejemplo n.º 3
0
        public void TestProcessInputCommandRestart()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                TopScores scores = new TopScores();
                MockLabyrinthBoard testBoard = new MockLabyrinthBoard(closedLabyrinth);
                MockingUserInterface userInterface = new MockingUserInterface();
                userInterface.FakeInput = "restart";
                testEngine = new Engine(testBoard, scores, userInterface);
                testEngine.Start();

                string expected = testBoard.ToString();
                string output = testEngine.Labyrinth.ToString();

                Assert.AreNotEqual<string>(expected, output);
            }
        }
Ejemplo n.º 4
0
        public void TestWalkInLabirinth()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                TopScores scores = new TopScores();
                MockLabyrinthBoard testBoard = new MockLabyrinthBoard(mockLabyrinth);
                MockingUserInterface userInterface = new MockingUserInterface();
                userInterface.FakeInput = "L";
                userInterface.SimulateWin = true;
                testEngine = new Engine(testBoard, scores, userInterface);
                testEngine.Start();

                StringBuilder expectedString = new StringBuilder();
                expectedString.Append("Congratulations! You escaped in 3 moves.");
                expectedString.Append(Environment.NewLine);
                expectedString.Append("Please, enter your name:");

                string expected = expectedString.ToString();
                string output = sw.ToString();
                output = output.Substring(output.Length - 395,66);

                Assert.AreEqual<string>(expected, output);
            }
        }
Ejemplo n.º 5
0
 public void TestUserDefinedConstructorForExceptions()
 {
     testEngine = new Engine(null, null, null);
 }
Ejemplo n.º 6
0
        public void TestStartMethodForCorrectOutput()
        {
            using (StringWriter sw = new StringWriter())
            {
                Console.SetOut(sw);

                TopScores scores = new TopScores();
                MockLabyrinthBoard testBoard = new MockLabyrinthBoard(mockLabyrinth);
                MockingUserInterface userInterface = new MockingUserInterface();
                userInterface.FakeInput = "exit";
                testEngine = new Engine(testBoard,scores,userInterface);
                testEngine.Start();

                string welcomeString = "Welcome to “Labirinth” game. Your goal is to escape. \nUse 'top' to view the top scoreboard, \n'restart' to start a new game \nand 'exit' to quit the game.\n";
                string boardString = testBoard.ToString();
                string enterMoveString = "\nEnter your move (L=left, R=right, U=up, D=down):";

                StringBuilder startMethodOutput = new StringBuilder();
                startMethodOutput.Append(welcomeString);
                startMethodOutput.Append(Environment.NewLine);
                startMethodOutput.Append(boardString);
                startMethodOutput.Append(enterMoveString);
                startMethodOutput.Append("Good Bye!");
                startMethodOutput.Append(Environment.NewLine);

                string expected = startMethodOutput.ToString();
                string output = sw.ToString();

                Assert.AreEqual<string>(expected, output);
            }
        }
Ejemplo n.º 7
0
 public void TestDefaultConstructorForExceptions()
 {
     testEngine = new Engine();
     // Checking for exceptions.
 }
Ejemplo n.º 8
0
        public void TestProcessInputDirectionUp()
        {
            TopScores scores = new TopScores();
            MockLabyrinthBoard testBoard = new MockLabyrinthBoard(mockLabyrinth);
            int positionY = testBoard.PiecePositionRow;
            MockingUserInterface userInterface = new MockingUserInterface();
            userInterface.FakeInput = "U";
            testEngine = new Engine(testBoard, scores, userInterface);
            testEngine.Start();

            Assert.AreEqual<int>(positionY - 1, testEngine.Labyrinth.PiecePositionRow);
        }
Ejemplo n.º 9
0
 public static void Main(string[] args)
 {
     Engine game = new Engine();
     game.Start();
 }