public void RetrieveCell_Existing_CorrectCellIsReturned() { var universe = new Universe(); var position = Point.Empty; var cell = new Cell(position, true); universe.AddCell(cell); Assert.AreEqual(cell, universe.GetCellAtPosition(position)); }
public void AddOneCell_CellIsAlive_CellKilledOnUpdate() { var universe = new Universe(); var universeRules = new UniverseRules(universe); var cell = new Cell(Point.Empty, true); universe.AddCell(cell); universeRules.UpdateUniverse(); Assert.AreEqual(false, cell.Alive); }
/// <summary> /// Adds a cell to the cell list. If a cell already exists at that position, /// it will be reaplaced by the new one. /// </summary> public void AddCell(Cell cell) { var alreadyExists = _cells.ContainsKey(cell.Position); if (alreadyExists) { _cells[cell.Position] = cell; } else { _cells.Add(cell.Position, cell); } }
public void AddCell_Existing_AddsNewCell() { var universe = new Universe(); var position = Point.Empty; var firstCell = new Cell(position, true); var secondCell = new Cell(position, true); universe.AddCell(firstCell); universe.AddCell(secondCell); Assert.AreEqual(secondCell, universe.GetCellAtPosition(position)); }
public void GetNextCell_Existing_RetrievesAllCells() { var universe = new Universe(); var position0 = Point.Empty; var position1 = new Point(1, 0); var position2 = new Point(2, 0); var cell0 = new Cell(position0, true); var cell1 = new Cell(position1, true); var cell2 = new Cell(position2, true); universe.AddCell(cell0); universe.AddCell(cell1); universe.AddCell(cell2); var retreivedCount = universe.NextCell().Count(); Assert.AreEqual(3, retreivedCount); }