Esempio n. 1
0
        public void TestAddjacentTiles()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var addajacentCells = matrixController.GetAdjacentCells(2, 2);

            Assert.IsNotNull(addajacentCells);
            Assert.IsTrue(addajacentCells.Count == 5);

            Assert.IsTrue(addajacentCells[0].Item1 == 2);
            Assert.IsTrue(addajacentCells[0].Item2 == 2);

            Assert.IsTrue(addajacentCells[1].Item1 == 3);
            Assert.IsTrue(addajacentCells[1].Item2 == 2);

            Assert.IsTrue(addajacentCells[2].Item1 == 1);
            Assert.IsTrue(addajacentCells[2].Item2 == 2);

            Assert.IsTrue(addajacentCells[3].Item1 == 2);
            Assert.IsTrue(addajacentCells[3].Item2 == 3);

            Assert.IsTrue(addajacentCells[4].Item1 == 2);
            Assert.IsTrue(addajacentCells[4].Item2 == 1);
        }
Esempio n. 2
0
        public void TestAddjacentTileLimitOutOfRange()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var addajacentCellsUpperLeft = matrixController.GetAdjacentCells(0, 0);
            var addajacentCellsUpperRight = matrixController.GetAdjacentCells(4, 0);
            var addajacentCellsLowerRight = matrixController.GetAdjacentCells(4, 4);
            var addajacentCellsLowerLeft = matrixController.GetAdjacentCells(0, 4);

            var addajacentCellsCenterUp = matrixController.GetAdjacentCells(2, 0);
            var addajacentCellsCenterDown = matrixController.GetAdjacentCells(0, 2);
            var addajacentCellsCenterRight = matrixController.GetAdjacentCells(4, 2);
            var addajacentCellsCenterLeft = matrixController.GetAdjacentCells(2, 4);

            Assert.IsTrue(addajacentCellsLowerLeft.Count == 3);
            Assert.IsTrue(addajacentCellsUpperRight.Count == 3);
            Assert.IsTrue(addajacentCellsLowerRight.Count == 3);
            Assert.IsTrue(addajacentCellsLowerLeft.Count == 3);

            Assert.IsTrue(addajacentCellsCenterUp.Count == 4);
            Assert.IsTrue(addajacentCellsCenterDown.Count == 4);
            Assert.IsTrue(addajacentCellsCenterRight.Count == 4);
            Assert.IsTrue(addajacentCellsCenterLeft.Count == 4);
        }
Esempio n. 3
0
        public void TestFinalClickCenter()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);
            matrixController.LightAll();

            matrixController.ToggleCell(2, 1);
            matrixController.ToggleCell(2, 2);
            matrixController.ToggleCell(2, 3);
            matrixController.ToggleCell(1, 2);
            matrixController.ToggleCell(3, 2);

            Assert.IsFalse(matrixController.ValidateBoard());

            matrixController.GetAdjacentCells(2, 2);

            Assert.IsTrue(matrixController.ValidateBoard());
        }
Esempio n. 4
0
 public void TestCheckMatrixLength()
 {
     LightMatrixController matrixController = new LightMatrixController();
     var matrix = matrixController.GenerateMatrix(5, 5);
     Assert.IsTrue(matrix.Length == 25);
 }
Esempio n. 5
0
        public void TestValidateNonCompleteBoard()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var valid = matrixController.ValidateBoard();

            Assert.IsFalse(valid);
        }
Esempio n. 6
0
        public void TestToggleCell()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var value1 = matrix[0, 0];
            var value2 = matrix[1, 2];
            var value3 = matrix[2, 3];
            var value4 = matrix[3, 1];
            var value5 = matrix[4, 4];

            var toggle1 = matrixController.ToggleCell(0, 0);
            var toggle2 = matrixController.ToggleCell(1, 2);
            var toggle3 = matrixController.ToggleCell(2, 3);
            var toggle4 = matrixController.ToggleCell(3, 1);
            var toggle5 = matrixController.ToggleCell(4, 4);

            Assert.AreNotEqual(value1, toggle1);
            Assert.AreNotEqual(value2, toggle2);
            Assert.AreNotEqual(value3, toggle3);
            Assert.AreNotEqual(value4, toggle4);
            Assert.AreNotEqual(value5, toggle5);
        }
Esempio n. 7
0
        public void TestSetAllTrue()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            matrixController.LightAll();

            var hasTrue = true;

            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    if (matrix[x, y] == false)
                        hasTrue = false;
                }
            }

            Assert.IsTrue(hasTrue);
        }
Esempio n. 8
0
        public void TestOutOfRangeToggle()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var range1 = matrixController.ToggleCell(-1, -1);
            var range2 = matrixController.ToggleCell(10, 1);

            Assert.IsFalse(range1);
            Assert.IsFalse(range2);
        }
Esempio n. 9
0
        public void TestGetCellValue()
        {
            LightMatrixController matrixController = new LightMatrixController();
            var matrix = matrixController.GenerateMatrix(5, 5);

            var value1 = matrix[0, 0];
            var value2 = matrix[1, 2];
            var value3 = matrix[2, 3];
            var value4 = matrix[3, 1];
            var value5 = matrix[4, 4];

            var currentValue1 = matrixController.GetCellValue(0, 0);
            var currentValue2 = matrixController.GetCellValue(1, 2);
            var currentValue3 = matrixController.GetCellValue(2, 3);
            var currentValue4 = matrixController.GetCellValue(3, 1);
            var currentValue5 = matrixController.GetCellValue(4, 4);

            Assert.AreEqual(value1, currentValue1);
            Assert.AreEqual(value2, currentValue2);
            Assert.AreEqual(value3, currentValue3);
            Assert.AreEqual(value4, currentValue4);
            Assert.AreEqual(value5, currentValue5);
        }
Esempio n. 10
0
        /// <summary>
        /// The Setup method which is called on every completion or restart of the game
        /// Sets up array structure and UI
        /// Starts Timer
        /// </summary>
        /// <param name="dimension">This parameter will determine how big the form is setup</param>
        private void SetupGrid()
        {
            //Start/Restart Setup of UI & Matrix
            matrixController = new LightMatrixController();
            tlpGrid = new TableLayoutPanel();
            tlpGrid.AutoSize = true;
            tlpGrid.Visible = false;
            grpBoxGrid.Controls.Clear();
            grpBoxGrid.Controls.Add(tlpGrid);

            //Generate Matrix, use matrix supplied to generate UI
            var grid = matrixController.GenerateMatrix(dimension, dimension);

            for (int x = 0; x < dimension; x++)
            {
                for (int y = 0; y < dimension; y++)
                {
                    var isOn = grid[x, y];
                    var btnTile = SetupButton(x, y, isOn);
                    tlpGrid.Controls.Add(btnTile, x, y);
                }
            }

            //Force Resize in case dimension is reduced
            tlpGrid.Visible = true;
            this.Size = new Size(0, 0);
            startTime = DateTime.Now;
        }