private static void AssertReferenceLineMetaDataGridViewControl(ReferenceLineMetaSelectionDialog dialog) { var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", dialog).TheObject; Assert.IsFalse(grid.MultiSelect); Assert.AreEqual(DataGridViewSelectionMode.FullRowSelect, grid.SelectionMode); }
public void OnLoad_Always_SetMinimumSize() { // Setup using (var viewParent = new Form()) using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, Enumerable.Empty <ReferenceLineMeta>())) { // Call dialog.Show(); // Assert Assert.AreEqual(372, dialog.MinimumSize.Width); Assert.AreEqual(350, dialog.MinimumSize.Height); } }
public void Constructor_WithParentAndReferenceLineMetas_ShowsExpectedGrid( [Values("", "10")] string assessmentSectionId, [Values(null, int.MinValue, -1, 0, 1, int.MaxValue)] int?signalFloodingProbability, [Values(int.MinValue, -1, 0, 1, int.MaxValue)] int maximumAllowableFloodingProbability) { // Setup var referenceLineMetas = new[] { new ReferenceLineMeta { AssessmentSectionId = assessmentSectionId, SignalFloodingProbability = signalFloodingProbability, MaximumAllowableFloodingProbability = maximumAllowableFloodingProbability } }; using (var viewParent = new Form()) { // Call using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, referenceLineMetas)) { // Assert var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", dialog).TheObject; DataGridView dataGridView = grid.Controls.OfType <DataGridView>().First(); Assert.AreEqual(1, dataGridView.Rows.Count); object currentIdValue = dataGridView[assessmentSectionIdColumn, 0].FormattedValue; Assert.IsNotNull(currentIdValue); Assert.AreEqual(assessmentSectionId, currentIdValue.ToString()); object currentSignalFloodingProbability = dataGridView[signalFloodingProbabilityColumn, 0].FormattedValue; Assert.IsNotNull(currentSignalFloodingProbability); string expectedSignalFloodingProbability = signalFloodingProbability.HasValue && signalFloodingProbability.Value > 0 ? ProbabilityFormattingHelper.FormatFromReturnPeriod(signalFloodingProbability.Value) : string.Empty; Assert.AreEqual(expectedSignalFloodingProbability, currentSignalFloodingProbability.ToString()); object currentMaximumAllowableFloodingProbability = dataGridView[maximumAllowableFloodingProbabilityColumn, 0].FormattedValue; Assert.IsNotNull(currentMaximumAllowableFloodingProbability); string expectedMaximumAllowableFloodingProbability = maximumAllowableFloodingProbability > 0 ? ProbabilityFormattingHelper.FormatFromReturnPeriod(maximumAllowableFloodingProbability) : string.Empty; Assert.AreEqual(expectedMaximumAllowableFloodingProbability, currentMaximumAllowableFloodingProbability.ToString()); } } }
private AssessmentSection GetAssessmentSectionFromDialog() { using (ReferenceLineMetaSelectionDialog dialog = CreateReferenceLineMetaSelectionDialogWithItems()) { if (dialog.ShowDialog() != DialogResult.OK) { return(null); } ReferenceLineMeta selectedItem = dialog.SelectedReferenceLineMeta; return(selectedItem == null ? null : TryCreateAssessmentSection(selectedItem, dialog.SelectedMaximumAllowableFloodingProbability, dialog.SelectedSignalFloodingProbability, dialog.SelectedNormativeProbabilityType)); } }
public void Constructor_WithParentAndEmptyReferenceLineMeta_DefaultProperties() { // Setup using (var viewParent = new Form()) { // Call using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, Enumerable.Empty <ReferenceLineMeta>())) { // Assert Assert.IsInstanceOf <DialogBase>(dialog); Assert.IsNull(dialog.SelectedReferenceLineMeta); Assert.AreEqual(@"Stel een traject samen", dialog.Text); GroupBox groupBox = ControlTestHelper.GetControls <GroupBox>(dialog, "groupBox1").Single(); Assert.AreEqual("Kies de doelkans voor de semi-probabilistische toets (dijken):", groupBox.Text); AssertReferenceLineMetaDataGridViewControl(dialog); } } }
public void Constructor_WithParentAndUnorderedReferenceLineMetas_ShowsOrderedGrid() { // Setup var referenceLineMetas = new[] { new ReferenceLineMeta(), new ReferenceLineMeta { AssessmentSectionId = "101-10" }, new ReferenceLineMeta { AssessmentSectionId = "101b-1" }, new ReferenceLineMeta { AssessmentSectionId = "101-2" }, new ReferenceLineMeta { AssessmentSectionId = "101-1" }, new ReferenceLineMeta { AssessmentSectionId = "101a-1" }, new ReferenceLineMeta { AssessmentSectionId = "10" }, new ReferenceLineMeta { AssessmentSectionId = "102-1" } }; using (var viewParent = new Form()) { // Call using (var dialog = new ReferenceLineMetaSelectionDialog(viewParent, referenceLineMetas)) { // Assert var grid = (DataGridViewControl) new ControlTester("ReferenceLineMetaDataGridViewControl", dialog).TheObject; DataGridView dataGridView = grid.Controls.OfType <DataGridView>().First(); var assessmentIdValuesInGrid = new List <string>(); for (var i = 0; i < dataGridView.Rows.Count; i++) { object currentIdValue = dataGridView[assessmentSectionIdColumn, i].FormattedValue; if (currentIdValue != null) { assessmentIdValuesInGrid.Add(currentIdValue.ToString()); } } CollectionAssert.AreEqual(new[] { "", "10", "101-1", "101-2", "101-10", "101a-1", "101b-1", "102-1" }, assessmentIdValuesInGrid); } } }