public void HideEmptyColumnsTest() { using (var filteredDataGridView = new FilteredDataGridView()) { var dt = UnitTestStatic.GetDataTable(100); filteredDataGridView.DataSource = dt; using (var frm = new Form()) { frm.Controls.Add(filteredDataGridView); frm.Show(); var numCol = 0; foreach (DataGridViewColumn col in filteredDataGridView.Columns) { if (col.Visible) { numCol++; } } Assert.AreEqual(numCol, dt.Columns.Count); filteredDataGridView.HideEmptyColumns(); numCol = 0; foreach (DataGridViewColumn col in filteredDataGridView.Columns) { if (col.Visible) { numCol++; } } Assert.AreEqual(numCol + 1, dt.Columns.Count); } } }
public void HideEmptyColumnsTest() { using (var filteredDataGridView = new FilteredDataGridView()) { var dt = UnitTestStatic.GetDataTable(); filteredDataGridView.DataSource = dt; using (var frm = new Form()) { frm.Controls.Add(filteredDataGridView); frm.Show(); var numCol = filteredDataGridView.Columns.Cast <DataGridViewColumn>().Count(col => col.Visible); Assert.AreEqual(numCol, dt.Columns.Count); filteredDataGridView.HideEmptyColumns(); numCol = filteredDataGridView.Columns.Cast <DataGridViewColumn>().Count(col => col.Visible); Assert.AreEqual(numCol + 1, dt.Columns.Count); } } }