private void btnLoad_Click(object sender, EventArgs e) { var arryEnum = Enum.GetValues(typeof(AlphabeticalEnum)); var valueStrings = new string[arryEnum.Length][]; foreach (var line in arryEnum) { valueStrings[line.GetHashCode()] = new string[arryEnum.Length]; for (int col = 0; col < arryEnum.Length; col++) { var coord = $"{line}{col + 1}"; var txt = this.Controls[coord]; var txtValue = (txt as TextBox)?.Text; valueStrings[line.GetHashCode()][col] = txtValue; } } SudokuValidator validator = new SudokuValidator(); var isValid = validator.IsValid(valueStrings); if (!isValid) { MessageBox.Show("Não é válido"); } else { MessageBox.Show("Válido"); } }
public void NrElemSudoku_Validator_ShouldReturn_False() { var sudoku = new SudokuValidator(new int[][] { new int[] { 4, 3, 5, 2, 6, 9, 7, 8, 1 }, new int[] { 6, 8, 2, 5, 7, 1, 4, 9, 3 }, new int[] { 1, 9, 7, 8, 3, 4, 5, 6, 2 }, new int[] { 8, 2, 6, 1, 9, 5, 3, 4, 7 }, new int[] { 3, 7, 4, 6, 8, 2, 9, 1, 5 }, new int[] { 9, 5, 1, 7, 4, 3, 6, 2, 8 }, new int[] { 5, 1, 9, 3, 2, 6, 8, 7, 4 }, new int[] { 2, 4, 8, 9, 5, 7, 1, 3, 100 }, new int[] { 7, 6, 3, 4, 1, 8, 2, 5, 9 } }); Assert.False(sudoku.IsValid()); }