コード例 #1
0
        public void CheckCellCollectionForCellTest()
        {
            LifeCycle lifeCycle = new LifeCycle();

            List<Cell> shouldBeTrueCells = new List<Cell>();
            shouldBeTrueCells.Add(new Cell(1, 2));
            shouldBeTrueCells.Add(new Cell(111, 55));
            shouldBeTrueCells.Add(new Cell(3, 2));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(new List<Cell>(), new Cell(0, 0)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(shouldBeTrueCells, new Cell(111, 55)));
        }
コード例 #2
0
        public void LifeCycleCycleTestBlinker()
        {
            List<Cell> blinkerTextCellsVertical = new List<Cell>();
            blinkerTextCellsVertical.Add(new Cell(2, 1));
            blinkerTextCellsVertical.Add(new Cell(2, 2));
            blinkerTextCellsVertical.Add(new Cell(2, 3));

            LifeCycle lifeCycle = new LifeCycle(blinkerTextCellsVertical);

            lifeCycle.Cycle();

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(3, 2)));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3)));
            Assert.IsTrue(lifeCycle.Cells.Count == 3);

            lifeCycle.Cycle();

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 1)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3)));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(1, 2)));
            Assert.IsTrue(lifeCycle.Cells.Count == 3);
        }
コード例 #3
0
        public void LifeCycleCycleTestBlock()
        {
            List<Cell> blockTestCells = new List<Cell>();
            blockTestCells.Add(new Cell(7, 5));
            blockTestCells.Add(new Cell(8, 5));
            blockTestCells.Add(new Cell(7, 6));
            blockTestCells.Add(new Cell(8, 6));

            LifeCycle lifeCycle = new LifeCycle(blockTestCells);

            for (var counter = 0; counter < 4; counter++)
            {
                lifeCycle.Cycle();

                Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(7, 5)));
                Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(8, 5)));
                Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(7, 6)));
                Assert.IsTrue(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(8, 6)));

                Assert.IsFalse(lifeCycle.checkCellCollectionForCell(lifeCycle.Cells, new Cell(2, 3)));
                Assert.IsTrue(lifeCycle.Cells.Count == 4);
            }
        }
コード例 #4
0
        public void LifeCycleGetNeighborCellTest()
        {
            List<Cell> getNeighborCellCountCells = new List<Cell>();
            getNeighborCellCountCells.Add(new Cell(2, 1));
            getNeighborCellCountCells.Add(new Cell(2, 2));
            getNeighborCellCountCells.Add(new Cell(2, 3));

            LifeCycle lifeCycle = new LifeCycle(getNeighborCellCountCells);
            List<Cell> getNeighborCellsTestCells = lifeCycle.getNeighborCells(new Cell(1, 1));

            Assert.IsTrue(getNeighborCellsTestCells.Count == 8);

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(2, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(2, 1)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(2, 0)));

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(1, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(1, 2)));

            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(0, 2)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(0, 1)));
            Assert.IsTrue(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(0, 0)));

            Assert.IsFalse(lifeCycle.checkCellCollectionForCell(getNeighborCellsTestCells, new Cell(1, 1)));
        }