コード例 #1
0
        public void TestBasics()
        {
            SodokuItem row = new SodokuItem();

            Assert.IsTrue(row.IsEmpty);
            Assert.AreEqual(9, row.EmptyCount);
            Assert.AreEqual(0, row.ContentCount);

            Assert.IsTrue(row.HasContent(new CellContent(0)));
            Assert.IsFalse(row.HasContent(new CellContent(1)));
            Assert.IsTrue(row.Validate());
        }
コード例 #2
0
        public void TestAddReplaceContent()
        {
            SodokuItem column = new SodokuItem();

            column[0] = new CellContent(9);
            Assert.IsFalse(column.IsEmpty);
            Assert.AreEqual(1, column.ContentCount);
            column[1] = new CellContent(8);

            Assert.ThrowsException <ArgumentException>(() => column[2] = new CellContent(9));
            Assert.AreEqual(2, column.ContentCount);

            column.ClearCell(1);
            Assert.AreEqual(1, column.ContentCount);
            column[1] = new CellContent(8);
            column[2] = new CellContent(7);

            Assert.ThrowsException <InvalidOperationException>(() => column.InsertItem(new CellContent(6), 2));
            List <int> ranks = column.AvailableRanks();

            Assert.AreEqual(6, ranks.Count);
            Assert.AreEqual(1, ranks[0]);
            Assert.AreEqual(2, ranks[1]);
            Assert.AreEqual(6, ranks[5]);

            column[3] = new CellContent(6);
            column[4] = new CellContent(5);
            column[5] = new CellContent(4);
            column[6] = new CellContent(3);
            column[7] = new CellContent(2);
            Assert.AreEqual(8, column.ContentCount);
            ranks = column.AvailableRanks();
            Assert.AreEqual(1, ranks.Count);
            Assert.AreEqual(1, ranks[0]);

            column[8] = new CellContent(1);
            Assert.IsTrue(column.IsFull);
            Assert.IsTrue(column.Validate());

            //Assert.ThrowsException<InvalidOperationException>(() => column.InsertItem(new CellContent(9), 5) );
        }