/// <summary> /// Verifies the problem repesented by <paramref name="theValues"/>. /// </summary> /// <param name="theValues"></param> private static void VerifyProblem(int[] theValues) { ISudokuPuzzle theSolution = null; var theProblem = theValues.ToSudokuPuzzle(); ((ISudokuPuzzle) theProblem).PrettyPrint(Console.Out); //TODO: introduce time outs to the solver ... // Should solve and not time out... using (var sps = new SudokuProblemSolver(theProblem)) { sps.Solved += (sender, e) => { var problemSolver = ((SudokuProblemSolver)sender); Assert.That(problemSolver.Solution, Is.Not.Null); theSolution = problemSolver.Solution; }; Assert.That(sps.TryResolve()); } Assert.That(theSolution, Is.Not.Null); Assert.That(theSolution, Is.Not.SameAs(theProblem)); Assert.That(theSolution.IsSolved); theSolution.PrettyPrint(Console.Out); }
/// <summary> /// Verifies the problem repesented by <paramref name="theValues"/>. /// </summary> /// <param name="theValues"></param> private static void VerifyProblem(int[] theValues) { ISudokuPuzzle theSolution = null; var theProblem = theValues.ToSudokuPuzzle(); ((ISudokuPuzzle)theProblem).PrettyPrint(Console.Out); //TODO: introduce time outs to the solver ... // Should solve and not time out... using (var s = new SudokuProblemSolver(theProblem)) { s.Solved += (sender, e) => { Assert.That(sender, Is.InstanceOf <SudokuProblemSolver>()); var problemSolver = (SudokuProblemSolver)sender; Assert.That(problemSolver.Solution, Is.Not.Null); theSolution = problemSolver.Solution; }; Assert.That(s.TryResolve()); } Assert.That(theSolution, Is.Not.Null); Assert.That(theSolution, Is.Not.SameAs(theProblem)); Assert.That(theSolution.IsSolved); theSolution.PrettyPrint(Console.Out); }
/// <summary> /// Verifies the problem represented by <paramref name="theValues"/>. /// </summary> /// <param name="theValues"></param> 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)); //TODO: introduce time outs to the solver ... // Should solve and not time out... 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)); }