Beispiel #1
0
        private async void LoadSudokuFromFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _model.CurrentSudoku = await SudokuAdapter.ReadFromFileAsync(LoadSudokuFromFile.FileName);

            UpdateLabelsUi();

            _model.IsSolveAvailable = true;
        }
Beispiel #2
0
        public async Task SolveTest(string path, int solutionsCount)
        {
            var absPath = Path.Combine(TestContext.CurrentContext.TestDirectory, path);

            var sudoku = await SudokuAdapter.ReadFromFileAsync(absPath);

            var solver = new SimpleSolver();

            var actualSolutionsCount = solver.CountSolutions(sudoku);

            Assert.AreEqual(solutionsCount, actualSolutionsCount);
        }
Beispiel #3
0
        public async Task TestTopNSolutions(string path, int solutionsLimit, Enums.TopType type, int expectedDifficulty)
        {
            var absPath = Path.Combine(TestContext.CurrentContext.TestDirectory, path);

            var sudoku = await SudokuAdapter.ReadFromFileAsync(absPath);

            var solver = new SimpleSolver();

            var solutions = solver.GetTopNSolutions(sudoku, solutionsLimit, type);

            Assert.AreEqual(solutionsLimit, solutions.Count);
            Assert.AreEqual(expectedDifficulty, solutions.First().DifficultyPoints);
        }
Beispiel #4
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                _model.CurrentSudoku = await SudokuAdapter.LoadSavedSudoku();

                if (_model.CurrentSudoku == null)
                {
                    return;
                }

                UpdateLabelsUi();
                _model.IsSolveAvailable = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show($@"Unable to load saved Sudoku! {Environment.NewLine} {exception}");
            }
        }
Beispiel #5
0
 private async void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     await SudokuAdapter.SaveSudokuAsync(_model.CurrentSudoku);
 }