Пример #1
0
    private void SpawnTerrain()
    {
        var terrainModel = terrainStructure.GetTerrain();

        if (terrainModel.Type == TerrainType.Road && terrainModel.Type == previousTerrainType)
        {
            ObjectPool.Spawn(lanes, Vector3.forward * (zPosition - 1));
        }

        ObjectPool.Spawn(terrainModel.Prefab, Vector3.forward * zPosition);
        previousTerrainType = terrainModel.Type;
    }
    public void Get_Terrain_Test()
    {
        //Arrange
        var terrainStructure = new TerrainStructure();

        var terrainModels = new List <TerrainModel>()
        {
            new TerrainModel()
            {
                Type = TerrainType.Grass
            },
            new TerrainModel()
            {
                Type = TerrainType.Road
            },
            new TerrainModel()
            {
                Type = TerrainType.Rail
            },
            new TerrainModel()
            {
                Type = TerrainType.Water
            }
        };

        terrainStructure.Construct(terrainModels);
        //Act
        var actual = new List <TerrainType>();

        for (int i = 0; i < 100000; i++)
        {
            actual.Add(terrainStructure.GetTerrain().Type);
        }

        //Assert
        CheckMaxRepetition(actual);
    }