Esempio n. 1
0
        public void IsValidSudokuCase4()
        {
            var board = new [] {
                new [] { '4', '3', '.', '.', '7', '.', '.', '.', '.' },
                new [] { '6', '.', '.', '1', '9', '5', '.', '.', '.' },
                new [] { '.', '9', '8', '.', '.', '.', '.', '6', '.' },

                new [] { '8', '.', '.', '.', '6', '.', '.', '.', '3' },
                new [] { '4', '.', '.', '8', '.', '3', '.', '.', '1' },
                new [] { '7', '.', '.', '.', '2', '.', '.', '.', '6' },

                new [] { '.', '6', '.', '.', '.', '.', '2', '8', '.' },
                new [] { '.', '.', '.', '4', '1', '9', '.', '.', '5' },
                new [] { '.', '.', '.', '.', '8', '.', '.', '7', '9' }
            };

            ValidSudoku.IsValidSudoku(board).Should().BeFalse();
        }
 public void validSudokuTest()
 {
     foreach (ValidSudokuTestData testData in TestDataList)
     {
         Console.WriteLine("Test input matrix: ");
         char[,] matrix = testData.InputArray;
         for (int i = 0; i <= matrix.GetUpperBound(0); i++)
         {
             for (int j = 0; j <= matrix.GetUpperBound(1); j++)
             {
                 Console.Write(matrix[i, j] + ", ");
             }
             Console.WriteLine();
         }
         bool result = ValidSudoku.IsValidSudoku(testData.InputArray);
         Console.WriteLine("Expected output: " + testData.OutputBool);
         Console.WriteLine("Actual output1: " + result);
         Assert.AreEqual(testData.OutputBool, result);
     }
 }
        public void Test_When_The_Input_Is_A_Valid_Sudoku_Board_Then_Return_True()
        {
            // arrange
            var input = new char[][]
            {
                new char[] { '5', '3', '.', '.', '7', '.', '.', '.', '.' },
                new char[] { '6', '.', '.', '1', '9', '5', '.', '.', '.' },
                new char[] { '.', '9', '8', '.', '.', '.', '.', '6', '.' },
                new char[] { '8', '.', '.', '.', '6', '.', '.', '.', '3' },
                new char[] { '4', '.', '.', '8', '.', '3', '.', '.', '1' },
                new char[] { '7', '.', '.', '.', '2', '.', '.', '.', '6' },
                new char[] { '.', '6', '.', '.', '.', '.', '2', '8', '.' },
                new char[] { '.', '.', '.', '4', '1', '9', '.', '.', '5' },
                new char[] { '.', '.', '.', '.', '8', '.', '.', '7', '9' }
            };

            // act
            var actual = ValidSudoku.IsValid(input);

            // assert
            Assert.True(actual);
        }
Esempio n. 4
0
        void InternalTest(char[][] board, bool expected)
        {
            bool actual = ValidSudoku.IsValidSudoku(board);

            Assert.Equal <bool>(expected, actual);
        }