Пример #1
0
        public void InequalityTest()
        {
            C4Move moveA = CreateMove(0);
            C4Move moveB = CreateMove(1);

            Assert.IsFalse(moveA.Equals(moveB));
        }
Пример #2
0
        public void EqualityTest()
        {
            C4Move moveA = CreateMove(3);
            C4Move moveB = CreateMove(3);

            Assert.IsTrue(moveA.Equals(moveB));
        }
Пример #3
0
        public void CreateValidMoveTest()
        {
            C4Move move = CreateMove(4);

            Assert.AreEqual(4, move.X);
            Assert.AreEqual(0, move.Y);
        }
Пример #4
0
        /// <summary>
        /// Convienence method used for creating moves with y positions for <see cref="C4TestingBoard"/>
        /// </summary>
        /// <param name="x">The x position of the move</param>
        /// <param name="y">The y position of the move</param>
        /// <returns>A <see cref="C4Move"/> with the x and y positions set to the passed in values</returns>
        private C4Move CreateMove(int x, int y)
        {
            C4Move result = new C4Move(x);

            result.SetY(y);
            return(result);
        }
Пример #5
0
        public void SetInvalidYPositionTest()
        {
            //Attempt to set a y position of 100 to a move, which should not work
            //This should throw an InvalidMoveException
            C4Move move = new C4Move(0);

            Assert.Throws <InvalidMoveException>(() => move.SetY(100));
        }
Пример #6
0
        public void SetValidYPositionTest()
        {
            //Attempt to assign a y position of 5 to a move, which should be valid
            C4Move move = new C4Move(2);

            move.SetY(5);
            Assert.AreEqual(5, move.Y);
        }
        /// <summary>
        /// Makes a move on this Connect 4 board at the specified move position
        /// </summary>
        /// <param name="move">The move to make</param>
        /// <returns>A reference to this testing Connect 4 board</returns>
        public override Board MakeMove(Move move)
        {
            C4Move m = (C4Move)move;

            //Make the move on this board
            boardContents[m.X, m.Y] = 1;

            //Determine if there is a winner
            DetermineWinner(m);

            return(this);
        }
        /// <summary>
        /// Called when a user is playing the game using the provided on-screen buttons
        /// </summary>
        /// <param name="xPos">The x position to make the move in</param>
        public void MakeMoveOnBoard(int xPos)
        {
            Move toMake = new C4Move(xPos);

            MakeMoveOnBoard(toMake);

            //If in client mode, pass the move to the client so that it can be serialized and sent to the server
            if (playMode == PlayMode.CLIENT && client.Connected)
            {
                client.ClientMove       = toMake;
                aiTurnProgressText.text = "Server is thinking...";
            }
        }
Пример #9
0
        public void ToStringTest()
        {
            C4Move move = CreateMove(2);

            Assert.AreEqual("(2)", move.ToString());
        }
Пример #10
0
        public void ValidHashCodeTest()
        {
            C4Move move = CreateMove(6);

            Assert.AreEqual(6, move.GetHashCode());
        }