Ejemplo n.º 1
0
        public void Solve_4_Sudoku()
        {
            // arrange
            var solver = new SudokuSolver();
            var actual = GetSolved4Sudoku();
            actual[0, 0] = 0;
            actual[0, 3] = 0;
            actual[1, 1] = 0;
            actual[1, 2] = 0;
            actual[2, 1] = 0;
            actual[2, 2] = 0;
            actual[3, 0] = 0;
            actual[3, 3] = 0;
            //|  3|4  |
            //|4  |  3|
            //|1  |  2|
            //|  2|1  |

            // act
            solver.Solve(actual);

            // assert
            var expected = GetSolved4Sudoku();
            Assert.True(expected.Cast<int>().SequenceEqual(actual.Cast<int>()));
        }
Ejemplo n.º 2
0
        public void SolveByColumn()
        {
            // arrange
            var solver = new SudokuSolver();
            var actual = GetSolved4Sudoku();
            actual[0, 0] = 0;
            actual[0, 1] = 0;
            actual[0, 2] = 0;
            actual[0, 3] = 0;
            //|0 0|0 0|
            //|4 1|2 3|
            //|1 4|3 2|
            //|3 2|1 4|

            // act
            solver.Solve(actual);

            // assert
            var expected = GetSolved4Sudoku();
            Assert.True(expected.Cast<int>().SequenceEqual(actual.Cast<int>()));
        }
Ejemplo n.º 3
0
        public void SolveByRow()
        {
            // arrange
            var solver = new SudokuSolver();
            var actual = GetSolved4Sudoku();
            actual[0, 3] = 0;
            actual[1, 3] = 0;
            actual[2, 3] = 0;
            actual[3, 3] = 0;
            //|2 3|4 0|
            //|4 1|2 0|
            //|1 4|3 0|
            //|3 2|1 0|

            // act
            solver.Solve(actual);

            // assert
            var expected = GetSolved4Sudoku();
            Assert.True(expected.Cast<int>().SequenceEqual(actual.Cast<int>()));
        }
Ejemplo n.º 4
0
        public void Solve_9_Sudoku()
        {
            // arrange
            var solver = new SudokuSolver();
            var actual = GetUnSolved9Sudoku();

            // act
            solver.Solve(actual);

            // assert
            var expected = GetSolved9Sudoku();
            Assert.True(expected.Cast<int>().SequenceEqual(actual.Cast<int>()));
        }
Ejemplo n.º 5
0
        public void Unsolvable()
        {
            // arrange
            var solver = new SudokuSolver();
            var actual = GetEmpty4Sudoku();

            // act
            solver.Solve(actual);

            // assert
            var expected = GetEmpty4Sudoku();
            Assert.True(expected.Cast<int>().SequenceEqual(actual.Cast<int>()));
        }