public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call using (var viewParent = new Form()) using (var dialog = new HydraulicBoundaryLocationSelectionDialog(viewParent, Enumerable.Empty <HydraulicBoundaryLocation>())) { dialog.Show(); // Assert CollectionAssert.IsEmpty(dialog.SelectedItems); var dataGridViewControl = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; DataGridView dataGridView = dataGridViewControl.Controls.OfType <DataGridView>().First(); Assert.AreEqual(2, dataGridView.ColumnCount); var locationCalculateColumn = (DataGridViewCheckBoxColumn)dataGridView.Columns[locationSelectionColumnIndex]; Assert.AreEqual("Gebruik", locationCalculateColumn.HeaderText); Assert.AreEqual("Selected", locationCalculateColumn.DataPropertyName); Assert.IsFalse(locationCalculateColumn.ReadOnly); var nameColumn = (DataGridViewTextBoxColumn)dataGridView.Columns[locationColumnIndex]; Assert.AreEqual("Hydraulische belastingenlocatie", nameColumn.HeaderText); Assert.AreEqual("Name", nameColumn.DataPropertyName); Assert.AreEqual(DataGridViewAutoSizeColumnMode.Fill, nameColumn.AutoSizeMode); Assert.IsTrue(nameColumn.ReadOnly); } }
public void Constructor_HydraulicBoundaryLocationOneEntry_OneRowInGrid() { // Setup const string testname = "testName"; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, testname, 0, 0); // Call using (var viewParent = new Form()) using (var dialog = new HydraulicBoundaryLocationSelectionDialog(viewParent, new[] { hydraulicBoundaryLocation })) { // Assert dialog.Show(); var dataGridViewControl = (DataGridViewControl) new ControlTester("DataGridViewControl").TheObject; Assert.AreEqual(1, dataGridViewControl.Rows.Count); Assert.IsFalse((bool)dataGridViewControl.Rows[0].Cells[locationSelectionColumnIndex].Value); Assert.AreEqual(testname, (string)dataGridViewControl.Rows[0].Cells[locationColumnIndex].Value); } }