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 SmallExploderCellTest_correctSizeReturned() { bool[,] _result = new SmallExploderCell(25).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 25); Assert.AreEqual(_result.GetLongLength(1), 25); //Odd (unusual) size _result = new SmallExploderCell(37).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 37); Assert.AreEqual(_result.GetLongLength(1), 37); _result = new SmallExploderCell(50).ToGrid(); Assert.AreEqual(_result.GetLongLength(0), 50); Assert.AreEqual(_result.GetLongLength(1), 50); }
public void SmallExploderCellTest_correctShape() { bool[,] expected = { { false, true, false }, { true, true, true }, { true, false, true }, { false, true, false }, }; bool[,] testGrid = new SmallExploderCell(4, 0).ToGrid(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Assert.AreEqual(expected[i, j], testGrid[i, j]); } } }