Ejemplo n.º 1
0
        public void OneSearchStepCausesDigitsToBeAdded()
        {
            _mockBoardControl.Reset();

            var internalRow1 = new InternalRow(new Coords(0, 0), 1, false);
            var internalRow2 = new InternalRow(new Coords(2, 3), 5, false);
            var internalRows = ImmutableList.Create(internalRow1, internalRow2);
            _mockPuzzleSolverTask.AddSearchStepCall(1, internalRows);

            Assert.That(_vm.SolveCommand.CanExecute(null), Is.True);
            _vm.SolveCommand.Execute(null);

            _mockTimer.FlushTicks(1);

            _mockBoardControl.Verify(m => m.AddDigit(internalRow1.Coords, internalRow1.Value), Times.Once);
            _mockBoardControl.Verify(m => m.AddDigit(internalRow2.Coords, internalRow2.Value), Times.Once);
        }
Ejemplo n.º 2
0
        public void TwoSearchStepsInvolvingOnlyInitialValuesCausesNoBoardChanges()
        {
            _mockBoardControl.Reset();

            var internalRow1 = new InternalRow(new Coords(0, 0), 1, true);
            var internalRow2 = new InternalRow(new Coords(2, 3), 5, true);
            var internalRows1 = ImmutableList.Create(internalRow1, internalRow2);
            _mockPuzzleSolverTask.AddSearchStepCall(1, internalRows1);

            var internalRow3 = new InternalRow(new Coords(4, 3), 6, true);
            var internalRows2 = ImmutableList.Create(internalRow3);
            _mockPuzzleSolverTask.AddSearchStepCall(2, internalRows2);

            Assert.That(_vm.SolveCommand.CanExecute(null), Is.True);
            _vm.SolveCommand.Execute(null);

            _mockTimer.FlushTicks(2);

            _mockBoardControl.Verify(m => m.AddDigit(It.IsAny<Coords>(), It.IsAny<int>()), Times.Never);
            _mockBoardControl.Verify(m => m.RemoveDigit(It.IsAny<Coords>()), Times.Never);
        }
Ejemplo n.º 3
0
        private static IImmutableList<int> BuildDlxRow(InternalRow internalRow)
        {
            var row = internalRow.Coords.Row;
            var col = internalRow.Coords.Col;
            var value = internalRow.Value;
            var box = RowColToBox(row, col);

            var posVals = Encode(row, col);
            var rowVals = Encode(row, value - 1);
            var colVals = Encode(col, value - 1);
            var boxVals = Encode(box, value - 1);

            return posVals.Concat(rowVals).Concat(colVals).Concat(boxVals).ToImmutableList();
        }