Esempio n. 1
0
 public void TestInitializeLabyrinthMap_CreateGame7x7_LabyrinthSizeIs7Rows()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     target.InitializeLabyrinthMap();
     int expected = 7;
     int actual = target.labyrinthMap.GetLength(0);
     Assert.AreEqual(expected, actual);
 }
Esempio n. 2
0
 public void TestInitializeLabyrinthMapInitial_CreateGame7x7_PlayerPositionIsAt3x3()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     target.InitializeLabyrinthMap();
     int expected = 0;
     int actual = target.labyrinthMap[3, 3];
     Assert.AreEqual(expected, actual);
 }
Esempio n. 3
0
 public void TestInitializeLabyrinthMapInitial_CreateGame7x7_LabyrinthIsSolvable()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     target.InitializeLabyrinthMap();
     PlayerPosition playerInitialPosition = new PlayerPosition(3,3);
     bool isLabirinthSolvable = GameUtilities_Accessor.IsLabyrinthSolvable(target.labyrinthMap, playerInitialPosition);
     Assert.IsTrue(isLabirinthSolvable);
 }
Esempio n. 4
0
 public void TestInitializeLabyrinthMap_PlayerPositionColumnInvalid_ArgumnetExceptionThrown()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, -1);
     target.InitializeLabyrinthMap();
 }
Esempio n. 5
0
 public void TestInitializeLabyrinthMap_CreateGameInvalidRowsCount_ArgumnetExceptionThrown()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(-1, 7, 3, 3);
     target.InitializeLabyrinthMap();
 }
Esempio n. 6
0
        public void TestPrintLabyrinth_CreateGame7x7_DisplayLabyrinthMap()
        {
            Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
            target.labyrinthMap = new int[7, 7]
            {
                { 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 0, 0, 0 },
                { 1, 1, 1, 1, 0, 1, 1 },
                { 1, 1, 1, 2, 0, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1 },
                { 1, 1, 1, 1, 1, 1, 1 },
            };

            string consoleInput = string.Empty;
            StringWriter consoleWriter;
            TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
            target.PrintLabyrinth();
            string actual = TestUtilities.GetConsoleOutput(consoleWriter);
            string expected =
                             "X X X X X X X \r\n" +
                             "X X X X - - - \r\n" +
                             "X X X X - X X \r\n" +
                             "X X X * - X X \r\n" +
                             "X X X X X X X \r\n" +
                             "X X X X X X X \r\n" +
                             "X X X X X X X \r\n";
            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
 public void TestPlay_SolveTheGameOneMove_ScoreRecordedScoreboeadPrinted()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 1, 5);
     target.labyrinthMap = new int[7, 7]
     {
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 0, 0, 0 },
         { 1, 1, 0, 0, 0, 1, 1 },
         { 1, 1, 0, 0, 0, 1, 1 },
         { 1, 1, 1, 0, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
     };
     string consoleInput =
                          "R\r\n" +
                          "Player 1\n" +
                          "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Congratulations! You escaped in 1 moves.\r\n" +
                      "Please enter your name for the top scoreboard: " +
                      "Scoreboard:\r\n" +
                      "1. Player 1 --> 1 moves";
     bool isMessageDisplayed = actual.Contains(expected);
     Assert.IsTrue(isMessageDisplayed);
 }
Esempio n. 8
0
 public void TestPlay_MoveUpToBlockedCell_InvalidMoveMEssagePrinted()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     target.labyrinthMap = new int[7, 7]
     {
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 0, 0, 0 },
         { 1, 1, 0, 1, 0, 1, 1 },
         { 1, 1, 1, 2, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
     };
     string consoleInput = "U\r\n" + "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Invalid move!\r\n" +
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Good Bye!\r\n";
     Assert.AreEqual(expected, actual);
 }
Esempio n. 9
0
 public void TestPlay_MoveUpSmallLetter_PayerPositionMoved()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     target.labyrinthMap = new int[7, 7]
     {
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 0, 0, 0 },
         { 1, 1, 0, 0, 0, 1, 1 },
         { 1, 1, 0, 0, 0, 1, 1 },
         { 1, 1, 1, 0, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
         { 1, 1, 1, 1, 1, 1, 1 },
     };
     string consoleInput = "u\r\n" + "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "X X X X X X X \r\n" +
                      "X X X X - - - \r\n" +
                      "X X - * - X X \r\n" +
                      "X X - - - X X \r\n" +
                      "X X X - X X X \r\n" +
                      "X X X X X X X \r\n" +
                      "X X X X X X X \r\n";
     bool isMessageDisplayed = actual.Contains(expected);
     Assert.IsTrue(isMessageDisplayed);
 }
Esempio n. 10
0
 public void TestInitializeLabyrinthMap_CreateGame0x7_ArgumnetExceptionThrown()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(0, 7, 3, 3);
     target.InitializeLabyrinthMap();
 }
Esempio n. 11
0
 public void TestPlay_EnterShowScoreboadCommand_MessageScoreBoardIsEmpty()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     string consoleInput = "top\n" + "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "The scoreboard is empty.\r\n" +
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Good Bye!\r\n";
     Assert.AreEqual(expected, actual);
 }
Esempio n. 12
0
 public void TestPlay_EnterInvalidCommand_InvalidMoveMessagePrinted()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     string consoleInput = "invalid\n" + "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Invalid move!\r\n" +
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Good Bye!\r\n";
     Assert.AreEqual(expected, actual);
 }
Esempio n. 13
0
 public void TestPlay_EnterExitCommand_ExitMessagePrinted()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 3, 3);
     string consoleInput = "exit\n";
     StringWriter consoleWriter;
     TestUtilities.RedirectConsoleStram(consoleInput, out consoleWriter);
     target.Play();
     string actual = TestUtilities.GetConsoleOutput(consoleWriter);
     string expected =
                      "Enter your move (L=left, R=right, U=up, D=down): " +
                      "Good Bye!\r\n";
     bool isMessageDisplayed = actual.Contains(expected);
     Assert.IsTrue(isMessageDisplayed);
 }
Esempio n. 14
0
 public void TestInitializeLabyrinthMap_PlayerPositionRowOutOfRange_ArgumnetExceptionThrown()
 {
     Labyrinth_Accessor target = new Labyrinth_Accessor(7, 7, 7, 3);
     target.InitializeLabyrinthMap();
 }