src/Kingdom.OrTools.Sat.Samples.Tests/SudokuSolverTests.cs
/// <summary>
/// Verifies the problem represented by <paramref name="theValues"/>.
/// </summary>
/// <param name="theValues"></param>
Verifies the problem represented by .
Verifies the problem represented by .
private void VerifyProblem(int[] theValues)
        {
            ISudokuPuzzle theSolution = null;
            var theProblem = theValues.ToSudokuPuzzle();
            void ReportTheValues()
            {
                string RenderTheValues()
                {
                    return string.Join(@", ", theValues.Select(x => $"{x}"));
                }
                OutputHelper.WriteLine($"The Values: {RenderTheValues()}");
            }
            ReportTheValues();
            theProblem.PrettyPrint(s => OutputHelper.WriteLine(s));
            using (var s = new SudokuProblemSolver(theProblem))
            {
                s.Solved += (sender, e) =>
                {
                    var problemSolver = Assert.IsAssignableFrom<SudokuProblemSolver>(sender);
                    Assert.NotNull(problemSolver.Solution);
                    theSolution = problemSolver.Solution;
                };
                Assert.True(s.TryResolve());
            }
            Assert.NotNull(theSolution);
            Assert.NotSame(theProblem, theSolution);
            Assert.True(theSolution.IsSolved);
            theSolution.PrettyPrint(s => OutputHelper.WriteLine(s));
        }
private void VerifyProblem ( int [ ] theValues ) { ISudokuPuzzle theSolution = null ; var theProblem = theValues . ToSudokuPuzzle ( ) ; void ReportTheValues ( ) { string RenderTheValues ( ) { return string . Join ( @", " , theValues . Select ( x => $" { x } " ) ) ; } OutputHelper . WriteLine ( $" The Values:  { RenderTheValues ( ) } " ) ; } ReportTheValues ( ) ; theProblem . PrettyPrint ( s => OutputHelper . WriteLine ( s ) ) ; using ( var s = new SudokuProblemSolver ( theProblem ) ) { s . Solved += ( sender , e ) => { var problemSolver = Assert . IsAssignableFrom < SudokuProblemSolver > ( sender ) ; Assert . NotNull ( problemSolver . Solution ) ; theSolution = problemSolver . Solution ; } ; Assert . True ( s . TryResolve ( ) ) ; } Assert . NotNull ( theSolution ) ; Assert . NotSame ( theProblem , theSolution ) ; Assert . True ( theSolution . IsSolved ) ; theSolution . PrettyPrint ( s => OutputHelper . WriteLine ( s ) ) ; }
Verifies the problem represented by .
Verifies the problem represented by .
//TODO: introduce time outs to the solver ... // Should solve and not time out...
theValues
int[]
None