Example #1
0
        public void FieldIsSolvedTest()
        {
            Field gameField = new Field(4);
            bool isSolved = gameField.IsSolved();

            Assert.IsFalse(isSolved);
        }
Example #2
0
        public void FieldNumbersCountTest()
        {
            Field gameField = new Field(4);
            int numbersCount = gameField.NumberCoords.Count;

            Assert.AreEqual(16, numbersCount);
        }
Example #3
0
        public void FieldsEqualLength()
        {
            Field firstGameField = new Field(4);
            Field secondGameField = new Field(4);

            int firstGameFieldLength = firstGameField.ToString().Length;
            int secondGameFieldLength = secondGameField.ToString().Length;

            Assert.AreEqual(firstGameFieldLength, secondGameFieldLength);
        }
Example #4
0
        public void FieldGetNumberTest()
        {
            Field gameField = new Field(4);

            var number = gameField[0, 0];

            bool isValidNumber = number >= 0 && number < 16;

            Assert.IsTrue(isValidNumber);
        }
Example #5
0
        public void GetRandomFieldTest()
        {
            Field gameField = new Field(4);
            var numbersBefore = gameField.NumberCoords;

            gameField = new Field(4);
            gameField.GetRandomField();

            var numbersAfter = gameField.NumberCoords;

            Assert.IsFalse(numbersBefore.Equals(numbersAfter));
        }
Example #6
0
        /// <summary>
        /// Method that starts the new game, when it was just loaded or restarted. 
        /// </summary>
        private void StartNewGame(IRenderable renderer, bool running = false)
        {
            this.gameField = new Field(Dimentions);
            renderer.StartupMessage();

            if (!running)
            {
                this.BeginGame(renderer);
            }

            do
            {
                this.gameField.GetRandomField();
            }
            while (this.gameField.IsSolved());
        }
Example #7
0
        public void NumberCoordsTest()
        {
            Field gameField = new Field(4);
            var numbers = gameField.NumberCoords;

            Assert.AreEqual(16, numbers.Count);
        }
Example #8
0
 public void FieldInvalidDimentionsTest()
 {
     Field gameField = new Field(-23);
 }
Example #9
0
        public void FieldGetNumberTooBigDimentionsTest()
        {
            Field gameField = new Field(4);

            var number = gameField[10, 10];
        }
Example #10
0
        public void FieldGetNumberNegativeDimentionsTest()
        {
            Field gameField = new Field(4);

            var number = gameField[-10, 0];
        }
Example #11
0
        public void SolvedFieldTest()
        {
            Field gameField = new Field(4);
            int number = 1;

            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 4; col++)
                {
                    gameField[row, col] = number;
                    number++;
                }
            }

            gameField[3, 3] = 0;

            Assert.IsTrue(gameField.IsSolved());
        }