Ejemplo n.º 1
0
        public void clone_test()
        {
            string     puzzle = "140060800085010040907400250030070400209000307008900060000740010601305090700002600";
            SudokuGrid grid   = new SudokuGrid(puzzle);

            grid.set_possible_values_of_all_cells();

            SudokuGrid grid2 = (SudokuGrid)grid.Clone();

            // the cloned grid is equal to the first
            Assert.True(grid2.Equals(grid));

            grid2._grid_cells[2, 1]._possible_values.Add(4);
            Assert.False(grid2.Equals(grid), "changing a possible value in one grid should not also reflect on the other grid");

            grid2 = (SudokuGrid)grid.Clone();
            Assert.True(grid2.Equals(grid), "setting the grid back to a fresh clone should make them equal again");
        }
Ejemplo n.º 2
0
        public static IEnumerable <object[]> remove_value_from_permitted_values_in_cells_test_true_input()
        {
            string     puzzle  = "000000000|000000000|000000000||000000000|000000000|000000000||000000000|000000000|000000000";
            SudokuGrid grid_in = new SudokuGrid(puzzle);

            grid_in._grid_cells[1, 1]._possible_values = new List <int> {
                1, 2, 3
            };
            grid_in._grid_cells[2, 2]._possible_values = new List <int> {
                2
            };
            grid_in._grid_cells[3, 3]._possible_values = new List <int> {
                1, 3
            };
            grid_in._grid_cells[4, 4]._possible_values = new List <int> {
                1, 2, 3
            };

            SudokuGrid grid_out = (SudokuGrid)grid_in.Clone();

            grid_out._grid_cells[1, 1]._possible_values = new List <int> {
                1, 3
            };
            grid_out._grid_cells[2, 2]._possible_values = new List <int> ();
            grid_out._grid_cells[3, 3]._possible_values = new List <int> {
                1, 3
            };

            yield return(new object[] {
                grid_in,
                2,
                new CoordinateList(new int[] { 1, 1, 2, 2, 3, 3 }),
                grid_out,
                "1"
            });
        }