public void TheSetOfDeadCellsMustBeUnique() { var adjacentDeadCell = new FakeCellLocation(); var liveCell1 = new FakeCellLocation(adjacentDeadCell); var liveCell2 = new FakeCellLocation(adjacentDeadCell); var universe = new Universe(new[] { liveCell1, liveCell2 }); Assert.That(universe.DeadCellLocations, Is.Unique); }
public void TheSetOfDeadCellsCannotContainLiveCells() { var liveCell1 = new FakeCellLocation(fakeNeighbours: new ICellLocation[0]); var liveCell2 = new FakeCellLocation(liveCell1); var universe = new Universe(new[] { liveCell1, liveCell2 }); Assert.That(universe.DeadCellLocations, Has.No.Member(liveCell1)); Assert.That(universe.DeadCellLocations, Has.No.Member(liveCell2)); }
public void GivenAUniverseWithOneLiveCellAndLessThanTwoLiveNeighbours_WhenEvolved_TheCellDies(int liveNeighbourCount) { var liveNeighbours = CreateCells(liveNeighbourCount); var liveCell = new FakeCellLocation(liveNeighbours); var allLiveCells = liveNeighbours.Concat(new[] { liveCell }); var initialUniverse = new Universe(allLiveCells); var evolvedUniverse = EvolveUniverse(initialUniverse); Assert.That(evolvedUniverse.LiveCellLocations, Has.No.Member(liveCell)); }
public void GivenAUniverseWithALiveCellWithBetweenTwoAndThreeLiveNeighbours_WhenEvolved_TheCellIsStillAlive(int liveNeighbourCount) { var liveNeighbours = CreateCells(liveNeighbourCount); var liveCell = new FakeCellLocation(liveNeighbours); var allLiveCells = liveNeighbours.Concat(new[] { liveCell }); var initialUniverse = new Universe(allLiveCells); var evolvedUniverse = EvolveUniverse(initialUniverse); Assert.That(evolvedUniverse.LiveCellLocations, Contains.Item(liveCell)); }
public void GivenAUniverseWithADeadCellWithThreeLiveNeighbours_WhenEvolved_TheCellComesAlive() { var deadCell = new FakeCellLocation(); var liveCell1 = new FakeCellLocation(deadCell); var liveCell2 = new FakeCellLocation(deadCell); var liveCell3 = new FakeCellLocation(deadCell); deadCell.SetFakeNeighbours(new[] { liveCell1, liveCell2, liveCell3 }); var initialUniverse = new Universe(new[] { liveCell1, liveCell2, liveCell3 }); var evolvedUniverse = EvolveUniverse(initialUniverse); Assert.That(evolvedUniverse.LiveCellLocations, Has.Member(deadCell)); }
public void DeadCellsAreTheSetOfAllDeadCellsNeighbouringAnyLiveCells() { var adjacentDeadCell1 = new FakeCellLocation(); var adjacentDeadCell2 = new FakeCellLocation(); var liveCell1 = new FakeCellLocation(adjacentDeadCell1, adjacentDeadCell2); var adjacentDeadCell3 = new FakeCellLocation(); var adjacentDeadCell4 = new FakeCellLocation(); var liveCell2 = new FakeCellLocation(adjacentDeadCell3, adjacentDeadCell4); var universe = new Universe(new[] { liveCell1, liveCell2 }); Assert.That(universe.DeadCellLocations, Is.SubsetOf(new[] { adjacentDeadCell1, adjacentDeadCell2, adjacentDeadCell3, adjacentDeadCell4 })); }