Пример #1
0
        public void TestVerifyBoard()
        {
            GameInstance currGame = Sudoku.GetSudokuService().CreateNewGame(new GameConfig
            {
                Difficulty = 1,
                Player1Id  = "1234"
            });

            Assert.AreEqual(currGame.Config.InitBoard, currGame.Status.CurrentBoard.Board);
            int[,] currBoard =
            {
                { 5, 3, 0, 0, 7, 0, 0, 0, 0 },
                { 6, 0, 0, 1, 9, 5, 0, 0, 0 },
                { 0, 9, 8, 0, 0, 0, 0, 6, 0 },
                { 8, 0, 0, 0, 6, 0, 0, 0, 3 },
                { 4, 0, 0, 8, 0, 3, 0, 0, 1 },
                { 7, 0, 0, 0, 2, 0, 0, 0, 6 },
                { 0, 6, 0, 0, 0, 0, 2, 8, 0 },
                { 0, 0, 0, 4, 1, 9, 0, 0, 5 },
                { 0, 0, 0, 0, 8, 0, 0, 7, 9 }
            };
            currGame.Config.InitBoard          = currBoard;
            currGame.Status.CurrentBoard.Board = currBoard;
            int[,] completeBoard =
            {
                { 5, 3, 4, 6, 7, 8, 9, 1, 2 },
                { 6, 7, 2, 1, 9, 5, 3, 4, 8 },
                { 1, 9, 8, 3, 4, 2, 5, 6, 7 },
                { 8, 5, 9, 7, 6, 1, 4, 2, 3 },
                { 4, 2, 6, 8, 5, 3, 7, 9, 1 },
                { 7, 1, 3, 9, 2, 4, 8, 5, 6 },
                { 9, 6, 1, 5, 3, 7, 2, 8, 4 },
                { 2, 8, 7, 4, 1, 9, 6, 3, 5 },
                { 3, 4, 5, 2, 8, 6, 1, 7, 9 }
            };
            GameBoard solvedBoard = Sudoku.GetSudokuService().ShowFinishedBoard(currGame.GameId);

            Assert.AreEqual(solvedBoard.Board, completeBoard);
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    BoardMove move = new BoardMove
                    {
                        Row    = i,
                        Column = j,
                        Value  = solvedBoard.Board[i, j]
                    };
                    Sudoku.GetSudokuService().SetBoardValue(currGame.GameId, move);
                }
            }
            Assert.AreEqual(currGame.Status.CurrentBoard.Board, completeBoard);

            int[,] badBoard =
            {
                { 6, 3, 4, 6, 7, 8, 9, 1, 2 },
                { 6, 7, 2, 1, 9, 5, 3, 4, 8 },
                { 1, 9, 8, 3, 4, 2, 5, 6, 7 },
                { 8, 5, 9, 7, 6, 1, 4, 2, 3 },
                { 4, 2, 6, 8, 5, 3, 7, 9, 1 },
                { 7, 1, 3, 9, 2, 4, 8, 5, 6 },
                { 9, 6, 1, 5, 3, 7, 2, 8, 4 },
                { 2, 8, 7, 4, 1, 9, 6, 3, 5 },
                { 3, 4, 5, 2, 8, 6, 1, 7, 9 }
            };

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    BoardMove move = new BoardMove
                    {
                        Row    = i,
                        Column = j,
                        Value  = badBoard[i, j]
                    };
                    Sudoku.GetSudokuService().SetBoardValue(currGame.GameId, move);
                }
            }

            Assert.AreNotEqual(currGame.Status.CurrentBoard, badBoard);

            BoardMove move1 = new BoardMove
            {
                Row    = 0,
                Column = 2
            };

            int[,] currBoard1 =
            {
                { 5, 3, 0, 0, 7, 0, 0, 0, 0 },
                { 6, 0, 0, 1, 9, 5, 0, 0, 0 },
                { 0, 9, 8, 0, 0, 0, 0, 6, 0 },
                { 8, 0, 0, 0, 6, 0, 0, 0, 3 },
                { 4, 0, 0, 8, 0, 3, 0, 0, 1 },
                { 7, 0, 0, 0, 2, 0, 0, 0, 6 },
                { 0, 6, 0, 0, 0, 0, 2, 8, 0 },
                { 0, 0, 0, 4, 1, 9, 0, 0, 5 },
                { 0, 0, 0, 0, 8, 0, 0, 7, 9 },
            };
            currGame.Status.CurrentBoard.Board = currBoard1;
            List <int> correctList1 = new List <int>()
            {
                1, 2, 4
            };
            List <int> testList1 = Sudoku.GetSudokuService().GetPossibleBoardValues(currGame.GameId, move1).PossibleValues;

            Assert.AreEqual(correctList1, testList1);
        }
        public void WinnerShouldReturnXO_EnumEmptyWhenThereIsNoWinner()
        {
            var board = new GameBoard(3);

            Assert.AreEqual(XO_Enum.Empty, board.Winner());
        }
Пример #3
0
 public void GetTradedCardSetsMethodTest()
 {
     Assert.Zero(GameBoard.GetBoard().GetTradedCardSets());
 }
Пример #4
0
 public void GetPlayerListMethodTest()
 {
     Assert.IsNotNull(GameBoard.GetBoard().GetPlayerList());
 }
Пример #5
0
 public void GetCardMethodTest()
 {
     Assert.IsNotNull(GameBoard.GetBoard().GetGameCard());
 }
Пример #6
0
 public void GetEarthMethodTest()
 {
     Assert.IsNotNull(GameBoard.GetBoard().GetEarth());
 }
Пример #7
0
 public void GetRandomMethodTest()
 {
     Assert.IsNotNull(GameBoard.GetBoard().GetRandom());
 }
Пример #8
0
 public void GetBoardMethodTest()
 {
     Assert.IsInstanceOf <GameBoard>(GameBoard.GetBoard());
 }
Пример #9
0
 public void TestGameBoardConstructor()
 {
     Assert.IsNotNull(GameBoard.GetBoard());
 }