Fixed tests

This commit is contained in:
Yair Morgenstern
2021-05-05 18:45:48 +03:00
parent fb93e3f7ee
commit 738bc6caac
3 changed files with 28 additions and 9 deletions

View File

@ -30,6 +30,7 @@ class UnitMovementAlgorithmsTests {
RulesetCache.loadRulesets()
ruleSet = RulesetCache.getBaseRuleset()
tile.ruleset = ruleSet
tile.baseTerrain = Constants.grassland
civInfo.tech.techsResearched.addAll(ruleSet.technologies.keys)
civInfo.tech.embarkedUnitsCanEnterOcean = true
civInfo.tech.unitsCanEmbark = true
@ -38,6 +39,13 @@ class UnitMovementAlgorithmsTests {
cities = arrayListOf("The Capital")
}
unit.civInfo = civInfo
// Needed for convertHillToTerrainFeature to not crash
val tileMap = TileMap()
tileMap.tileMatrix.add(ArrayList<TileInfo?>().apply { add(tile) })
tile.tileMap = tileMap
tile.setTransients()
}
@Test
@ -55,27 +63,32 @@ class UnitMovementAlgorithmsTests {
@Test
fun unitCanEnterTheCity() {
val map = TileMap()
tile.baseTerrain = Constants.hill
tile.tileMap = map
tile.setTransients()
val cityTile = tile.clone() // reset, so that the isCoastalTile won't be carried over from previous tests
cityTile.baseTerrain = Constants.grassland
cityTile.tileMap = map
cityTile.ruleset = ruleSet
cityTile.setTransients()
map.tileMatrix.add(arrayListOf(cityTile)) // needed for tile.setTransients()
val otherTile = tile.clone()
otherTile.baseTerrain = Constants.coast
otherTile.position.y = 1f
map.tileMatrix.add(arrayListOf(tile, otherTile))
map.tileMatrix[0].add(otherTile)
val city = CityInfo()
city.location = tile.position
city.location = cityTile.position
city.civInfo = civInfo
tile.owningCity = city
cityTile.owningCity = city
for (type in UnitType.values())
{
unit.owner = civInfo.civName
unit.baseUnit = BaseUnit().apply { unitType = type }
Assert.assertTrue(type.name, unit.movement.canPassThrough(tile))
if(!unit.movement.canPassThrough(cityTile))
unit.movement.canPassThrough(cityTile)
Assert.assertTrue(type.name, unit.movement.canPassThrough(cityTile))
}
}