private void SetDataSource(RedTable table) { dataGridView1.ReadOnly = false; dataGridView1.AutoGenerateColumns = false; dataGridView1.Columns.Clear(); foreach (DataColumn col in table.Columns) { if (table.ComboBoxes.ContainsKey(col.ColumnName)) { var combox = table.ComboBoxes[col.ColumnName]; DataTable comboTable = combox.GetValues(context); dataGridView1.Columns.Add(new DataGridViewComboBoxColumn() { Name = col.ColumnName, HeaderText = table.GetColumnAliase(col.ColumnName), DataSource = comboTable, ValueMember = comboTable.Columns[0].ColumnName, DisplayMember = (comboTable.Columns.Count > 1) ?comboTable.Columns[1].ColumnName :comboTable.Columns[0].ColumnName, DataPropertyName = col.ColumnName }); } else { dataGridView1.Columns.Add(new DataGridViewTextBoxColumn() { Name = col.ColumnName, DataPropertyName = col.ColumnName, HeaderText = table.GetColumnAliase(col.ColumnName) }); } } dataGridView1.DataSource = table; dataGridView1.Refresh(); }
public void MakeBetsTest() { Table table = new RedTable(PayOut.ThreeTwo); Console.WriteLine("Table minimum bet: " + table.MinimumBet); var cash = randGen.Next(0, (int)Chip.Purple + 1); Console.WriteLine("Player cash: " + cash); var numPlayers = randGen.Next(1, 11); Console.WriteLine("Number of players: " + numPlayers); Dictionary<int,Player> players = new Dictionary<int, Player>(); for (var i = 0; i < numPlayers; i++) { players.Add(i, new Player(i, cash, table)); } BlackJackGame.MakeBets(table, players); var leftOver = cash - table.MinimumBet; Console.WriteLine("Calculated leftover cash: " + leftOver); for (var i = 0; i < numPlayers; i++) { var actual = table.GetBetAmount(i); Console.WriteLine("Player {0} bet amount: {1}", i, actual); Assert.AreEqual(table.MinimumBet, actual); var rem = players[i].Chips.GetTotal(); Console.WriteLine("Remaining player cash: " + rem); Assert.AreEqual(leftOver, rem); } }