Example #1
0
        public void SetCandidatesTest()
        {
            int index = 0;
            Column target = new Column(index);
            for (int i = 0; i < 9; i++)
            {
                target.Cells[i] = new Cell();
                target.Cells[i].Column = target;
            }

            // Check that all digits are candidate :
            foreach (Cell cell in target.GetCells())
                for (int digit = 1; digit <= 9; digit++)
                    Assert.AreEqual(true, cell.HasACandidateFor(digit));

            target.SetCandidates();

            // Check that all digits are candidate :
            foreach (Cell cell in target.GetCells())
                for (int digit = 1; digit <= 9; digit++)
                    Assert.AreEqual(true, cell.HasACandidateFor(digit));

            target.Cells[0].Digit = 1;
            //target.SetCandidates();

            // Check that 1 is no more a candidate :
            foreach (Cell cell in target.GetCells())
                Assert.AreEqual(false, cell.HasACandidateFor(1));

            // Check that all other digits are candidate
            // (except for the first cell) :
            for (int i = 1; i < 9; i++)
            {
                for (int digit = 2; digit <= 9; digit++)
                    Assert.AreEqual(true, target.Cells[i].HasACandidateFor(digit), string.Format("({0} Candidate for {1})", target.Cells[i], digit));
            }
        }