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

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

            Assert.AreEqual(16, numbersCount);
        }
Esempio n. 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);
        }
Esempio n. 4
0
        public void FieldGetNumberTest()
        {
            Field gameField = new Field(4);

            var number = gameField[0, 0];

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

            Assert.IsTrue(isValidNumber);
        }
Esempio n. 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));
        }
Esempio n. 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());
        }
Esempio n. 7
0
        public void NumberCoordsTest()
        {
            Field gameField = new Field(4);
            var numbers = gameField.NumberCoords;

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

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

            var number = gameField[-10, 0];
        }
Esempio n. 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());
        }