public void TestReadFile()
        {
            var fileLoader = Container.Resolve <ISudokuFileLoader>();

            var testFilesPaths = new List <string>()
            {
                FileNameResolver.ResolveFileName(FileNames.Easy),
                FileNameResolver.ResolveFileName(FileNames.Medium),
                FileNameResolver.ResolveFileName(FileNames.Hard),
                FileNameResolver.ResolveFileName(FileNames.Samurai),
            };

            foreach (var testFilesPath in testFilesPaths)
            {
                var sudoku = fileLoader.LoadSudoku(testFilesPath);
                Assert.IsNotNull(sudoku);
            }
        }
Example #2
0
        public void SolveTest()
        {
            var fileLoader = Container.Resolve <ISudokuFileLoader>();

            var testFilesPaths = new List <string>()
            {
                FileNameResolver.ResolveFileName(FileNames.Easy),
                FileNameResolver.ResolveFileName(FileNames.Medium),
                FileNameResolver.ResolveFileName(FileNames.Hard),
                FileNameResolver.ResolveFileName(FileNames.Samurai),
            };

            foreach (var testFilesPath in testFilesPaths)
            {
                var sudoku = fileLoader.LoadSudoku(testFilesPath);
                sudoku.Solve();
                Assert.IsTrue(sudoku.Cells.Any(c => !c.Value.HasValue));
            }
        }
Example #3
0
        public void FetchAllSolutionsTest()
        {
            var fileLoader   = Container.Resolve <ISudokuFileLoader>();
            var sudokuSolver = Container.Resolve <ISudokuSolver>();

            var testFilesPaths = new List <string>()
            {
                FileNameResolver.ResolveFileName(FileNames.Easy),
                FileNameResolver.ResolveFileName(FileNames.Medium),
                //FileNameResolver.ResolveFileName(FileNames.Hard),
                //FileNameResolver.ResolveFileName(FileNames.Samurai),
            };

            foreach (var testFilesPath in testFilesPaths)
            {
                var sudoku       = fileLoader.LoadSudoku(testFilesPath);
                var allSolutions = sudokuSolver.FindAllSolutions(sudoku.Cells);
                Assert.IsTrue(allSolutions.Count() == 1);
            }
        }