コード例 #1
0
        public void FullGameDrawWinTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            int[,] turns = { { 0, 0 }, { 1, 1 }, { 1, 0 }, { 2, 0 }, { 0, 2 }, { 0, 1 }, { 2, 1 }, { 1, 2 }, { 2, 2 } };
            int numbersTurns = 9;

            //Act
            game.StartGame();
            for (int i = 0; i < numbersTurns; i++)
            {
                positionTurn.x = turns[i, 0];
                positionTurn.y = turns[i, 1];
                methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, game.Id.ToString());
                game.Player    = MovementGameTicTacToe.GetNextPlayer(game.Player);
            }

            //Assert
            Assert.IsTrue(methodReturn.StatusAction);
            Assert.AreEqual("Partida finalizada!", methodReturn.MessageAction);
            Assert.AreEqual("Draw", methodReturn.Winner);
        }
コード例 #2
0
        //подготовка к старту игры
        private void PreparationForTheStartOfTheGame()
        {
            this.Hide();

            LoginForm loginForm = UserUpload(path);

            if (loginForm.ShowDialog() == DialogResult.OK)
            {
                LevelSetting(loginForm);
                playerName = loginForm.comboBoxSelectUser.Text;
                buttons    = new Button[] { button0, button1, button2, button3,
                                            button4, button5, button6, button7, button8 };

                bool isZero = loginForm.radioButtonZero.Checked;
                DetermineWhoPlaysWhat(isZero);

                game = new GameTicTacToe(level);
                game.ComputerMadeMove += Game_ComputerMadeMove;
                game.GameOver         += Game_GameOver;
                LoadingSelectedData();

                loginForm.Close();
                this.Show();

                NewGame();
            }
            else
            {
                Application.Exit();
            }
        }
コード例 #3
0
        public void StartsGameWithFirstPlayer()
        {
            //Arrange
            GameTicTacToe   game = new GameTicTacToe();
            ActionResulting methodReturn;

            //Act
            methodReturn = game.StartGame();

            //Assert
            Assert.IsTrue(methodReturn.StatusAction);
        }
コード例 #4
0
        public void CheckCreatedFirstPlayer()
        {
            //Arrange
            GameTicTacToe   game = new GameTicTacToe();
            ActionResulting methodReturn;

            //Act
            methodReturn = game.StartGame();

            //Assert
            if (methodReturn.StatusAction)
            {
                Assert.IsNotNull(game.Player);
            }
        }
コード例 #5
0
        public void TestGameTurn()
        {
            //Arrange
            GameTicTacToe   game = new GameTicTacToe();
            ActionResulting methodReturn;


            //Act
            game.StartGame();
            methodReturn = MovementGameTicTacToe.MovimentGame(new Position {
                x = 0, y = 2
            }
                                                              , game.Player, game.Id.ToString());

            //Assert
            Assert.IsTrue(methodReturn.StatusAction);
        }
コード例 #6
0
        public void GameNumberErrorTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            //Act
            game.StartGame();
            positionTurn.x = 1;
            positionTurn.y = 0;
            methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, "guid-invalido-de-jogo");


            //Assert
            Assert.IsFalse(methodReturn.StatusAction);
            Assert.AreEqual("Partida não encontrada", methodReturn.MessageAction);
        }
コード例 #7
0
        public void TurnErrorTest()
        {
            //Arrange
            GameTicTacToe   game         = new GameTicTacToe();
            ActionResulting methodReturn = new ActionResulting();
            Position        positionTurn = new Position();

            int[,] turns = { { 0, 0 }, { 1, 0 } };
            int numbersTurns = 2;

            //Act
            game.StartGame();
            for (int i = 0; i < numbersTurns; i++)
            {
                positionTurn.x = turns[i, 0];
                positionTurn.y = turns[i, 1];
                methodReturn   = MovementGameTicTacToe.MovimentGame(positionTurn, game.Player, game.Id.ToString());
            }

            //Assert
            Assert.IsFalse(methodReturn.StatusAction);
            Assert.AreEqual("Não é turno do jogador", methodReturn.MessageAction);
        }