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); } }
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)); } }
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); } }