示例#1
0
        public void ShouldNotOverrunWest()
        {
            // arrange
            RelationshipsBuilder relationshipsBuilder = new RelationshipsBuilder();
            List <Cell>          cells = new FakeCellsBuilder().SetupCartesianGrid(3, 3);

            // act
            Relationships relationships = relationshipsBuilder.GetCellRelationships(cells, 3, 3);

            // assert
            int indexToCheck = 0;

            relationships.GetNeighbors(cells[indexToCheck]).Should().HaveCount(3);
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[1])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[3])).Should().BeTrue();
        }
示例#2
0
        public God(CellsBuilder cellsBuilder, RelationshipsBuilder relationshipsBuilder, IRule rule)
        {
            List <Cell> cells = cellsBuilder.SetupCartesianGrid(3, 3);

            Relationships relationships = relationshipsBuilder.GetCellRelationships(cells, 3, 3);

            List <Cell> nextTurnCells = new List <Cell>();

            foreach (Cell cell in cells)
            {
                relationships.GetNeighbors(cell);
                Cell nextTurnCell = cell.GenerateNextTurnStatus(rule, cells);

                nextTurnCells.Add(nextTurnCell);
                // update relationship?
            }
        }
示例#3
0
        public void ShouldPopulateSouthEastNeighbor()
        {
            // arrange
            RelationshipsBuilder relationshipsBuilder = new RelationshipsBuilder();
            List <Cell>          cells = new FakeCellsBuilder().SetupCartesianGrid(3, 3);

            // act
            Relationships relationships = relationshipsBuilder.GetCellRelationships(cells, 3, 3);

            // assert
            int indexToCheck = 4;

            relationships.GetNeighbors(cells[indexToCheck]).Should().HaveCount(8);
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[5])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[3])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[7])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[1])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[2])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[0])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[8])).Should().BeTrue();
            relationships.GetNeighbors(cells[indexToCheck]).Any(x => x.IsNeighborOf(cells[6])).Should().BeTrue();
        }