public void IsLegalSudoku_LegalSudokuBoard_ReturnLegal() { // Create Legal 16 on 16 Legal string Board string legalBoard = "6?;>00<:03425000" + "10@:02456000?0900" + "00006000:;0>@0007" + "020>800000<03000>" + "0000?000300000604" + "509@00?;0:2000000" + "000008000008<0301" + "0296=:;7>0005000=" + "0<100900093<0@010" + ">=00080?=02000000" + "0504070007003;0?2" + "0015000000040;000" + "506@720608=0>:000" + "30;005080@0900070" + "1=000=?6000;0902<00"; // build a board Board board = new Board(legalBoard, 16); // Act - Check if the sudoku is Legal by // Search duplicates numbers in each row,col and box LegalSudoku sudokuCheck = board.IsLegalSudoku(); // Assert // The function should return true, this is legal board Assert.AreEqual(sudokuCheck, LegalSudoku.Legal); }
public void IsLegalSudoku_IlegalSudokuBoard_ReturnIlegal() { // Arrange // Create Ilegal sudoku board // Notice: The duplicate of '5' in First box string ilegalBoard = "500080049" + "500500030" + "067300001" + "150000009" + "000208008" + "000000018" + "700004150" + "030002000" + "490050000"; // build a board Board board = new Board(ilegalBoard, 9); // Act - Check if the sudoku is Valid by // Search duplicates numbers in each row,col and box LegalSudoku sudokuCheck = board.IsLegalSudoku(); // Assert Assert.AreEqual(sudokuCheck, LegalSudoku.Ilegal); }