public void TestClone() { SudokuCell clone = (SudokuCell)this.Cell.Clone(); Assert.AreEqual(this.Cell.Number, clone.Number); Assert.AreEqual(this.Cell.Solution, clone.Solution); Assert.AreEqual(this.Cell.IsReadOnly, clone.IsReadOnly); Assert.IsTrue(SudokuCellTest.Equal(this.Cell.Possible, clone.Possible)); }
public void TestProperties() { int[] array = new int[] { 1, SudokuPuzzle.MaximumSupportedSize }; SudokuMove move = new SudokuMove(array, array, array, SudokuPattern.HiddenSingle, array); Assert.IsTrue(SudokuCellTest.Equal(array, move.Columns)); Assert.IsTrue(SudokuCellTest.Equal(array, move.Numbers)); Assert.IsTrue(SudokuCellTest.Equal(array, move.Possible)); Assert.IsTrue(SudokuCellTest.Equal(array, move.Rows)); }
public void TestConstructor() { Assert.IsNotNull(this.Sudoku); Assert.AreEqual(this.Sudoku.Size, SudokuPuzzleTest.Size); Assert.AreEqual(this.Sudoku.Difficulty, SudokuPuzzleTest.Difficulty); for (int i = 0; i < SudokuPuzzleTest.Size; i++) { for (int j = 0; j < SudokuPuzzleTest.Size; j++) { Assert.IsTrue(SudokuCellTest.Equal(this.Possible, this.Sudoku.GetPossible(i, j))); } } }
public void TestSetNumberFromNumberToNumber() { this.TestSetNumberFromZeroToNumber(out int row, out int column, out int oldNumber); int number; do { number = this.Generate(true); } while (number != oldNumber); List <int> affectedPossibleList = new List <int>(this.Possible); affectedPossibleList.Remove(number); int[] affectedPossible = affectedPossibleList.ToArray(); this.Sudoku.GetStartRowColumn(row, column, out int startRow, out int startColumn); this.Sudoku[row, column] = number; for (int i = 0; i < SudokuPuzzleTest.Size; i++) { for (int j = 0; j < SudokuPuzzleTest.Size; j++) { this.Sudoku.GetStartRowColumn(i, j, out int currentStartRow, out int currentStartColumn); if (i == row || j == column || currentStartRow == startRow && currentStartColumn == startColumn) { //Check against affectedPossible if (this.Sudoku[i, j] == 0) { Assert.IsTrue(SudokuCellTest.Equal(affectedPossible, this.Sudoku.GetPossible(i, j))); } else { Assert.IsNull(this.Sudoku.GetPossible(i, j)); } } else if (this.Sudoku[i, j] == 0) { Assert.IsTrue(SudokuCellTest.Equal(this.Possible, this.Sudoku.GetPossible(i, j))); } else { Assert.IsNull(this.Sudoku.GetPossible(i, j)); } } } }
public void TestAddPossible() { int[] possible = new int[SudokuPuzzle.MaximumSupportedSize]; for (int i = 0; i < SudokuPuzzle.MaximumSupportedSize; i++) { int number = i + 1; possible[i] = number; this.Cell.AddPossible(number); } Assert.IsTrue(SudokuCellTest.Equal(possible, this.Cell.Possible)); this.Cell.AddPossible(SudokuPuzzle.MaximumSupportedSize); Assert.IsTrue(SudokuCellTest.Equal(possible, this.Cell.Possible)); this.Cell.RemovePossible(SudokuPuzzle.MaximumSupportedSize); Assert.IsFalse(SudokuCellTest.Equal(possible, this.Cell.Possible)); this.Cell.AddPossible(SudokuPuzzle.MaximumSupportedSize); Assert.IsTrue(SudokuCellTest.Equal(possible, this.Cell.Possible)); }
public void TestSetNumberFromNumberToZero() { this.TestSetNumberFromZeroToNumber(out int row, out int column, out int number); this.Sudoku[row, column] = 0; for (int i = 0; i < SudokuPuzzleTest.Size; i++) { for (int j = 0; j < SudokuPuzzleTest.Size; j++) { if (this.Sudoku[i, j] == 0) { Assert.IsTrue(SudokuCellTest.Equal(this.Possible, this.Sudoku.GetPossible(i, j))); } else { Assert.IsNull(this.Sudoku.GetPossible(i, j)); } } } }