Пример #1
0
        public void FillingPartOfALineThatHasStateOutsideThatPartWithStateAndFlagFillsTheSectionWithThatStateAndFlagAndReturnsFalse()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l[0].State = Cell.CellState.Blank;

            Assert.IsTrue(l.Fill(1, 2, Cell.CellState.Filled, 42));

            var expectedStates = new Cell.CellState[5] {
                Cell.CellState.Blank,
                Cell.CellState.Filled,
                Cell.CellState.Filled,
                Cell.CellState.Unknown,
                Cell.CellState.Unknown
            };

            var expectedFlags = new int[5] {
                0,
                42,
                42,
                0,
                0
            };

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(expectedStates[i], l[i].State);
                Assert.AreEqual(expectedFlags[i], l[i].Flag);
            }
        }
Пример #2
0
        public void IsValidReturnsTrueWhenHintMatchesContents_Hint0_Contents0()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(Cell.CellState.Blank);

            Assert.AreEqual(true, l.IsValid());
        }
Пример #3
0
        public void DistinctGroupsReturnsOneWithAllFilled()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(Cell.CellState.Filled);

            Assert.AreEqual(1, l.DistinctGroups());
        }
Пример #4
0
        public void DistinctGroupsReturnsZeroWithAllBlank()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(Cell.CellState.Blank);

            Assert.AreEqual(0, l.DistinctGroups());
        }
Пример #5
0
        public void IsValidReturnsFalseWhenHintsExistButAllBlank()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(Cell.CellState.Blank);
            l.Hints.AddRange(new int[] { 1 });

            Assert.AreEqual(false, l.IsValid());
        }
Пример #6
0
        public void DistinctGroupsReturnsActualNumberOfGroupsWithTwoGroupsOfTwo()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(Cell.CellState.Filled);
            l[2].State = Cell.CellState.Blank;

            Assert.AreEqual(2, l.DistinctGroups());
        }
Пример #7
0
        public void IsValidReturnsTrueWhenPossibleSolutionsExist()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(0, 3, Cell.CellState.Blank);
            l[4].State = Cell.CellState.Blank;
            l.Hints.AddRange(new int[] { 1 });

            Assert.AreEqual(true, l.IsValid());
        }
Пример #8
0
        public void IsValidReturnsFalseWhenNoPossibleSolutionsExist()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l.Fill(0, 3, Cell.CellState.Filled);
            l[4].State = Cell.CellState.Filled;
            l.Hints.AddRange(new int[] { 3 });

            Assert.AreEqual(false, l.IsValid());
        }
Пример #9
0
        public void IsValidReturnsFalseWhenGroupIsTooLarge_Hint3_Contents4_right()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            l[0].State = Cell.CellState.Blank;
            l.Fill(1, 4, Cell.CellState.Filled);
            l.Hints.AddRange(new int[] { 3 });

            Assert.AreEqual(false, l.IsValid());
        }
Пример #10
0
        public void FillingALineWithStateFillsTheEntireLineWithThatStateAndReturnsTrue()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            Assert.IsTrue(l.Fill(Cell.CellState.Filled));

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(Cell.CellState.Filled, l[i].State);
            }
        }
Пример #11
0
        public void FillingPartOfALineWithStateFillsTheSectionWithThatStateAndReturnsTrue()
        {
            Nonogram n = new Nonogram(5, 1);
            CellLine l = n.Row(0);

            Assert.IsTrue(l.Fill(1, 2, Cell.CellState.Filled));

            var expectedStates = new Cell.CellState[5] {
                Cell.CellState.Unknown,
                Cell.CellState.Filled,
                Cell.CellState.Filled,
                Cell.CellState.Unknown,
                Cell.CellState.Unknown
            };

            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(expectedStates[i], l[i].State);
            }
        }