public void IfNoEmptyTilesArePresent_ResultShallBeEmptyListOfGroups() { var map = new CityBuilder.MapModel.Map(4, 7); var emptyAreas = _cut.Get(map); Assert.AreEqual(0, emptyAreas.Count); }
public void SingleEmptyGroup_ShallBeSurroundedWithStreetTiles() { var map = new CityBuilder.MapModel.Map(5, 7); var emptyGroup = new EmptyAreaGroup { Tiles = new List <ITile> { map[1, 1], map[1, 2], map[2, 1], map[2, 2], } }; foreach (var tile in emptyGroup.Tiles) { tile.TileState = TileState.Empty; } _cut.AppendStreets(map, new List <EmptyAreaGroup> { emptyGroup }); Assert.AreEqual(4, emptyGroup.Tiles.Count(a => a.TileState == TileState.Empty)); Assert.AreEqual(12, map.AllTiles.Count(a => a.TileState == TileState.Street)); }
public void IfNoEmptyTilesArePresent_ResultShallBeEmptyListOfGroups() { var map = new CityBuilder.MapModel.Map(4, 7); var streetTiles = _cut.AppendStreets(map, new List <EmptyAreaGroup>()); Assert.AreEqual(0, streetTiles.Count()); }
public void IfTwoGroupsTouchByCorners_OneCornerShallBeRemoved_ToCreatePassage() { var map = new CityBuilder.MapModel.Map(6, 6); var firstEmptyGroup = new EmptyAreaGroup { Tiles = new List <ITile> { map[1, 1], map[1, 2], map[2, 1], map[2, 2], } }; foreach (var tile in firstEmptyGroup.Tiles) { tile.TileState = TileState.Empty; } var secondEmptyGroup = new EmptyAreaGroup { Tiles = new List <ITile> { map[3, 3], map[3, 4], map[4, 3], map[4, 4], } }; foreach (var tile in secondEmptyGroup.Tiles) { tile.TileState = TileState.Empty; } _cut.AppendStreets(map, new List <EmptyAreaGroup> { firstEmptyGroup, secondEmptyGroup }); Assert.AreEqual(4, firstEmptyGroup.Tiles.Count(a => a.TileState == TileState.Empty)); Assert.AreEqual(3, secondEmptyGroup.Tiles.Count(a => a.TileState == TileState.Empty)); Assert.AreEqual(21, map.AllTiles.Count(a => a.TileState == TileState.Street)); }
public void IfMapContainsTwoGroupsOfTiles_TheyShallBeFound() { var map = new CityBuilder.MapModel.Map(4, 7); var firstExcpectedGroup = new List <ITile> { map[1, 0], map[2, 0], map[3, 0], map[0, 1], map[1, 1], map[2, 1], map[3, 1], map[0, 2], map[1, 2], map[2, 2], map[3, 2], map[1, 3], map[2, 3], }; foreach (var tile in firstExcpectedGroup) { tile.TileState = TileState.Empty; } var secondExpectedGroup = new List <ITile> { map[5, 0], map[6, 0], map[5, 1], map[6, 1], map[5, 2], map[6, 2], map[6, 3], }; foreach (var tile in secondExpectedGroup) { tile.TileState = TileState.Empty; } var emptyAreas = _cut.Get(map); Assert.AreEqual(2, emptyAreas.Count); foreach (var expectedTile in firstExcpectedGroup) { Assert.True(emptyAreas[0].Contains(expectedTile)); } foreach (var expectedTile in secondExpectedGroup) { Assert.True(emptyAreas[1].Contains(expectedTile)); } }