Ejemplo n.º 1
0
        public void RetrieveCell_NonExisting_NullIsReturned()
        {
            var universe = new Universe();
            var position = Point.Empty;

            Assert.AreEqual(null, universe.GetCellAtPosition(position));
        }
Ejemplo n.º 2
0
        public void AddCell_NonExisting_AddsCell()
        {
            var universe = new Universe();

            var position = Point.Empty;
            universe.AddCell(new Cell(position, true));

            Assert.AreEqual(true, universe.ContainsCellAtPosition(position));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public UniverseRules(Universe universe)
 {
     _universe = universe;
     _currentCellLifeState = new Dictionary<Cell, bool>();
 }
Ejemplo n.º 8
0
        private readonly Universe _universe; // The universe for which the drawing will be performed

        #endregion Fields

        #region Constructors

        public UniverseView(Universe universe)
        {
            _universe = universe;
            _cellBrush = new SolidBrush(CellColor);
        }