public void CellShouldBeAliveGivenAlive() { Cell cell = new Cell(PopulationControl.Alive); bool isAlive = cell.IsAlive(); Assert.True(isAlive); }
public void CellShouldBeDeadGivenDead() { Cell cell = new Cell(PopulationControl.Dead); bool isAlive = cell.IsAlive(); Assert.False(isAlive); }
private void Drawing() { while (true) { board.NextBoard(); Bitmap bipmap = new Bitmap(500, 500); Graphics graphics = Graphics.FromImage(bipmap); graphics.FillRectangle(Brushes.White, 0, 0, 500, 500); for (int x = 0; x < 50; x++) { for (int y = 0; y < 50; y++) { Cell cell = board.GetCellAt(x, y); if (cell.IsAlive()) { graphics.FillRectangle(Brushes.Green, cell.GetX() * 10, cell.GetY() * 10, 10, 10); } else { graphics.FillRectangle(Brushes.Black, cell.GetX() * 10, cell.GetY() * 10, 10, 10); } } } pictureBox_LifeBoard.BeginInvoke((MethodInvoker) delegate { pictureBox_LifeBoard.Image = bipmap; pictureBox_LifeBoard.Refresh(); }); Thread.Sleep(100); } }
public void IsAliveTest2() { Cell target = new Cell("-"); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = target.IsAlive(); Assert.AreEqual(expected, actual); }
public void IsAliveShouldBeFalseAfterAliveCellUpdateGivenOverpopulationNeighbors() { Cell cell = AliveCell(); new PopulationControl().UpdateState(cell, OverpopulationNeighbors); cell.Update(); Assert.False(cell.IsAlive()); }
public void IsAliveShouldBeTrueAfterDeadCellUpdateGivenRegenerationNeighbors() { Cell cell = DeadCell(); new PopulationControl().UpdateState(cell, RegenerationNeighbors); cell.Update(); Assert.True(cell.IsAlive()); }
public void IsAliveShouldBeTrueAfterAliveCellUpdateGivenMinStaticNeighbors() { Cell cell = AliveCell(); new PopulationControl().UpdateState(cell, MinStaticNeighbors); cell.Update(); Assert.True(cell.IsAlive()); }
public void IsAliveTest() { Cell target = new Cell("X"); // TODO: Initialize to an appropriate value bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = target.IsAlive(); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public void CellAssureCellIsAlive() { /* arrange */ Cell my_cell = new Cell(); int cell_neighbor = 3; /* end arrange */ /* act */ /* end act */ /* assert */ Assert.IsTrue(my_cell.IsAlive(cell_neighbor)); /* end assert */ }
public void NextBoard() { Cell[,] newBoard = new Cell[200, 200]; for (int x = 0; x < 200; x++) { for (int y = 0; y < 200; y++) { Cell cell = this.GetCellAt(x, y); int rule = 0; if (this.GetCellAt(cell.Top()[0], cell.Top()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.Bottom()[0], cell.Bottom()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.Left()[0], cell.Left()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.Right()[0], cell.Right()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.TopRight()[0], cell.TopRight()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.TopLeft()[0], cell.TopLeft()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.BottomRight()[0], cell.BottomRight()[1]).IsAlive()) { rule++; } if (this.GetCellAt(cell.BottomLeft()[0], cell.BottomLeft()[1]).IsAlive()) { rule++; } switch (rule) { case 0: case 1: { newBoard[x, y] = new Cell(x, y, false); break; } case 2: { if (cell.IsAlive()) { newBoard[x, y] = new Cell(x, y, true); } else { newBoard[x, y] = new Cell(x, y, false); } break; } case 3: { newBoard[x, y] = new Cell(x, y, true); break; } default: { newBoard[x, y] = new Cell(x, y, false); break; } } } } board = newBoard; }
public void TestThatCellIsAlive() { World genesis = new World(); Cell cell = new Cell(); Assert.AreEqual(true, cell.IsAlive()); }
public void UpdateState(Cell cell, int neighbors) => cell.SetUpdateState(cell.IsAlive() ? LivingCell(neighbors) : DeadCell(neighbors));
private static Color GetCellColor(Cell cell) { return(cell.IsAlive() ? Color.FromRgb(255, 0, 0) : Color.FromRgb(255, 255, 255)); }
public void CellAssureCellIsDeadFromTooMany() { /* arrange */ Cell my_cell = new Cell(); int cell_neighbor = 5; /* end arrange */ /* act */ /* end act */ /* assert */ Assert.IsFalse(my_cell.IsAlive(cell_neighbor)); /* end assert */ }