Exemple #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();
        }
Exemple #2
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();
        }