private void cbCellList_SelectedIndexChanged(object sender, EventArgs e) { ICell _cell = null; ComboBox cb = (sender as ComboBox); ComboBoxEntry entry = (cb.SelectedItem as ComboBoxEntry); switch (entry.ID) { case -1: _cell = new AllDeadCell(GRID_SIZE); break; case 0: _cell = new SimpleCustomCell(GRID_SIZE); break; case 1: _cell = new GliderCell(GRID_SIZE); break; case 2: _cell = new SmallExploderCell(GRID_SIZE, 20); break; case 3: _cell = new ExploderCell(GRID_SIZE, 20); break; case 4: _cell = new TenCellRowCell(GRID_SIZE, 20); break; case 5: _cell = new TumblerCell(GRID_SIZE, 20); break; case 6: _cell = new GosperGliderGunCell(GRID_SIZE, 7); break; case 7: _cell = new RandomCell(GRID_SIZE); break; default: break; } if (_cell != null) { this.grid1.GridBits = _cell.ToGrid(); this.generation = 0; this.lblGenNum.Text = generation.ToString(); } }
public void ExploderCellTest_correctSizeReturned() { bool[,] _result = new ExploderCell(10).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 10); Assert.AreEqual(_result.GetLongLength(1), 10); //Odd (unusual) size _result = new ExploderCell(47).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 47); Assert.AreEqual(_result.GetLongLength(1), 47); _result = new ExploderCell(50).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 50); Assert.AreEqual(_result.GetLongLength(1), 50); }
public void ExploderCellTest_correctShape() { bool[,] expected = { { true, false, true, false, true }, { true, false, false, false, true }, { true, false, false, false, true }, { true, false, false, false, true }, { true, false, true, false, true } }; bool[,] testGrid = new ExploderCell(5, 0).ToGrid(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Assert.AreEqual(expected[i, j], testGrid[i, j]); } } }