示例#1
0
        public void Solve_GivenValidPuzzleAsInputWithMultipleCell_ShouldHaveValidSolveRun()
        {
            var sut = new PuzzleItems.Puzzle(@$ "_,2,_,_,_,4,3,_,_| 
                                                9,_,_,_,2,_,_,_,8|
                                                _,_,_,6,_,9,_,5,_|
                                                _,_,_,_,_,_,_,_,1|
                                                _,7,2,5,_,3,6,8,_|
                                                6,_,_,_,7,_,4,3,5|
                                                _,8,_,2,_,5,_,_,_|
                                                1,_,_,_,9,_,_,_,3|
                                                _,_,9,8,_,_,_,6,_");

            sut.Solve();
            Assert.IsTrue(sut.IsValid());
        }
示例#2
0
        public void Solve_GivenValidDifferentPuzzleAsInputWithMultipleCell_ShouldHaveValidSolveRun()
        {
            var sut = new PuzzleItems.Puzzle(@$ "2,_,_,3,_,_,_,_,_| 
                                                8,_,4,_,6,2,_,_,3|
                                                _,1,3,8,_,_,2,_,_|
                                                _,_,_,_,2,_,3,9,_|
                                                5,_,7,_,_,_,6,2,1|
                                                _,3,2,_,_,6,_,_,_|
                                                _,2,_,_,_,9,1,4,_|
                                                6,_,1,2,5,_,8,_,9|
                                                _,_,_,_,_,1,_,_,2");

            sut.Solve();
            Assert.IsTrue(sut.IsValid());
        }
示例#3
0
        public void Solve_GivenValidPuzzleAsInputWithTwoMissingCell_ShouldHaveValidSolveRun()
        {
            var sut = new PuzzleItems.Puzzle(@$ "_,2,7,1,5,4,3,9,6| 
                                                9,6,5,3,2,7,1,4,8|
                                                3,4,1,6,8,9,7,5,2|
                                                5,9,3,4,6,8,2,7,1|
                                                4,7,2,5,1,3,6,8,9|
                                                6,1,8,9,7,2,4,3,5|
                                                7,8,6,2,3,5,9,1,4|
                                                1,5,4,7,9,6,8,2,3|
                                                2,3,9,8,4,1,5,6,_");

            sut.Solve();
            Assert.IsTrue(sut.IsValid());
        }
示例#4
0
        public void InsertGuesses_GivenPuzzleWithBlanks_ShouldHaveIsInitialValueFalseForBlankCells()
        {
            var sut = new PuzzleItems.Puzzle(@$ "1,2,3,4,5,6,7,8,9| 
                                                1,2,3,4,5,6,7,8,_|
                                                1,2,3,4,5,6,7,8,9|
                                                1,2,3,4,5,6,7,8,9|
                                                1,2,3,4,5,6,7,8,9|
                                                1,2,3,4,5,6,7,8,9|
                                                1,2,3,4,5,6,7,8,9|
                                                1,2,3,_,5,6,_,8,9|
                                                1,2,3,4,_,6,7,8,9");

            Assert.IsFalse(sut.Columns[3].Cells[7].IsInitialCell);
            Assert.IsFalse(sut.Columns[6].Cells[7].IsInitialCell);
            Assert.IsFalse(sut.Columns[4].Cells[8].IsInitialCell);
            Assert.IsFalse(sut.Columns[8].Cells[1].IsInitialCell);
        }
示例#5
0
        public void Constructor_GivenInputString_ShouldPopulateColumnCellsCorrectly()
        {
            var puzzle = new PuzzleItems.Puzzle(@$ "1,2,3,4,5,6,7,8,9| 
                                                   1,2,3,4,5,6,7,8,5|
                                                   1,2,3,4,5,6,7,8,9|
                                                   1,2,3,4,5,6,7,8,9|
                                                   1,2,3,4,5,6,7,8,9|
                                                   1,2,3,4,5,6,7,8,9|
                                                   1,2,3,4,5,6,7,8,9|
                                                   1,2,3,7,5,6,4,8,9|
                                                   1,2,3,4,9,6,7,8,9");

            Assert.AreEqual(7, puzzle.Columns[3].Cells[7].Value);
            Assert.AreEqual(4, puzzle.Columns[6].Cells[7].Value);
            Assert.AreEqual(9, puzzle.Columns[4].Cells[8].Value);
            Assert.AreEqual(5, puzzle.Columns[8].Cells[1].Value);
        }