public void Selection_ValidRowSelected_SameAsTableControlSelection() { // Setup using (var form = new Form()) using (var control = new IllustrationPointsControl()) { form.Controls.Add(control); form.Show(); control.Data = GetIllustrationPointControlItems().ToArray(); IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls <IllustrationPointsTableControl>(form, "IllustrationPointsTableControl").Single(); DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(form, "illustrationPointsDataGridViewControl"); var initialControlSelection = control.Selection as IllustrationPointControlItem; // Precondition Assert.IsNotNull(initialControlSelection); // Call dataGridView.SetCurrentCell(dataGridView.Rows[1].Cells[0]); // Assert var expectedSelection = tableControl.Selection as IllustrationPointControlItem; var controlSelection = (IllustrationPointControlItem)control.Selection; Assert.IsNotNull(expectedSelection); Assert.AreSame(expectedSelection, controlSelection); Assert.AreNotSame(initialControlSelection, controlSelection); } }
public void WaveHeightCalculationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated() { // Setup IObservableEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations(); ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm); IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(2, 0)); // Precondition CollectionAssert.IsEmpty(illustrationPointsControl.Data); var topLevelIllustrationPoints = new[] { new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "Regular", new TestSubMechanismIllustrationPoint()) }; var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints); var output = new TestHydraulicBoundaryLocationCalculationOutput(generalResult); // Call HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculations.ElementAt(2); hydraulicBoundaryLocationCalculation.Output = output; hydraulicBoundaryLocationCalculation.NotifyObservers(); // Assert IEnumerable <IllustrationPointControlItem> expectedControlItems = CreateControlItems(generalResult); CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); }
public void GetSelectedMapData_WithSelectedData_ReturnsSelectedMapData() { // Setup mockRepository.ReplayAll(); using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (new UseCustomSettingsHelper(new TestSettingsHelper { ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(testPath, "noConfig") })) using (var form = new Form()) using (WmtsLocationControl control = ShowFullyConfiguredWmtsLocationControl(form, wmtsCapabilityFactory)) { DataGridViewControl dataGridViewControl = form.Controls.Find("dataGridViewControl", true).OfType<DataGridViewControl>().First(); dataGridViewControl.SetCurrentCell(dataGridViewControl.GetCell(1, 0)); // Call var selectedMapData = control.SelectedMapData as WmtsMapData; // Assert Assert.IsNotNull(selectedMapData); Assert.AreEqual("PDOK achtergrondkaart", selectedMapData.Name); Assert.AreEqual("brtachtergrondkaart(EPSG:28992)", selectedMapData.SelectedCapabilityIdentifier); Assert.AreEqual("https://geodata.nationaalgeoregister.nl/wmts/top10nlv2?VERSION=1.0.0&request=GetCapabilities", selectedMapData.SourceCapabilitiesUrl); Assert.AreEqual("image/png8", selectedMapData.PreferredFormat); } }
public void GivenValidDialog_WhenControlSwitched_ThenDoesNotListenToEventOfOldControl() { // Given WmtsMapData activeWmtsMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData(); var capabilities = new[] { new TestWmtsTileSource(WmtsMapDataTestHelper.CreateAlternativePdokMapData()), new TestWmtsTileSource(activeWmtsMapData) }; tileFactory.Expect(tf => tf.GetWmtsTileSources(activeWmtsMapData.SourceCapabilitiesUrl)).Return(capabilities); mockRepository.ReplayAll(); var wmtsLocationControlSelectedMapDataChanged = 0; string settingsDirectory = Path.Combine(testPath, "EmptyWmtsConnectionInfo"); using (new UseCustomSettingsHelper(new TestSettingsHelper { ApplicationLocalUserSettingsDirectory = settingsDirectory })) using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var dialogParent = new Form()) using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, activeWmtsMapData)) { dialog.Show(); var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; var wellKnownMapDataControl = GetComboBoxItem <WellKnownMapDataControl>(comboBox); var wmtsLocationControl = GetComboBoxItem <WmtsLocationControl>(comboBox); comboBox.SelectedItem = wmtsLocationControl; Button connectButton = dialog.Controls.Find("connectToButton", true).OfType <Button>().First(); connectButton.PerformClick(); DataGridViewControl wmtsDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First(); wmtsLocationControl.SelectedMapDataChanged += (sender, args) => wmtsLocationControlSelectedMapDataChanged++; comboBox.SelectedItem = wellKnownMapDataControl; DataGridViewControl wellKnownDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First(); wellKnownDataGridViewControl.ClearCurrentCell(); var button = (Button) new ButtonTester("selectButton", dialog).TheObject; Assert.IsFalse(button.Enabled); // When wmtsDataGridViewControl.SetCurrentCell(wmtsDataGridViewControl.GetCell(0, 0)); // Then Assert.IsFalse(button.Enabled); Assert.AreEqual(1, wmtsLocationControlSelectedMapDataChanged); } }
public void GivenFullyConfiguredView_WhenSelectingCalculationWithGeneralResult_ThenGeneralResultSetOnIllustrationPointsControlData() { // Given ShowFullyConfiguredCalculationsView(testForm); IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); // When calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(3, 0)); // Then Assert.AreEqual(2, illustrationPointsControl.Data.Count()); }
public void GivenFullyConfiguredView_WhenSelectingCalculationWithoutGeneralResult_ThenIllustrationPointsControlDataSetToEmptyEnumeration() { // Given ShowFullyConfiguredCalculationsView(testForm); IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); DataGridViewControl calculationsDataGridViewControl = GetCalculationsDataGridViewControl(); // When calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(1, 0)); // Then CollectionAssert.IsEmpty(illustrationPointsControl.Data); }
public void GivenFullyConfiguredControl_WhenSelectingCellInSecondRow_ThenSelectionChangedFired() { // Given using (var form = new Form()) using (var control = new IllustrationPointsControl()) { form.Controls.Add(control); form.Show(); control.Data = GetIllustrationPointControlItems().ToArray(); var selectionChangedCount = 0; control.SelectionChanged += (sender, args) => selectionChangedCount++; DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(form, "illustrationPointsDataGridViewControl"); // When dataGridView.SetCurrentCell(dataGridView.Rows[1].Cells[0]); // Then Assert.AreEqual(1, selectionChangedCount); } }
public void GivenControlWithIllustrationPoints_WhenSelectingSecondRow_ThenSelectionReturnsIllustrationPointControlItem() { // Given IllustrationPointsTableControl control = ShowControl(); control.Data = GetControlItems(); DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "illustrationPointsDataGridViewControl"); // When DataGridViewRow selectedRow = dataGridView.Rows[1]; dataGridView.SetCurrentCell(selectedRow.Cells[0]); // Then var selection = control.Selection as IllustrationPointControlItem; var dataBoundItem = selectedRow.DataBoundItem as IllustrationPointRow; Assert.NotNull(selection); Assert.NotNull(dataBoundItem); Assert.AreSame(dataBoundItem.IllustrationPointControlItem, selection); }
public void GivenValidDialog_WhenControlSwitched_ThenListenToEventOfNewControl() { // Given WmtsMapData activeWmtsMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData(); mockRepository.ReplayAll(); var wellKnownSelectedMapDataChanged = 0; string settingsDirectory = Path.Combine(testPath, "EmptyWmtsConnectionInfo"); using (new UseCustomSettingsHelper(new TestSettingsHelper { ApplicationLocalUserSettingsDirectory = settingsDirectory })) using (new UseCustomTileSourceFactoryConfig(tileFactory)) using (var dialogParent = new Form()) using (var dialog = new BackgroundMapDataSelectionDialog(dialogParent, activeWmtsMapData)) { dialog.Show(); var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; var wellKnownControl = GetComboBoxItem <WellKnownMapDataControl>(comboBox); comboBox.SelectedItem = wellKnownControl; DataGridViewControl wellKnownDataGridViewControl = dialog.Controls.Find("dataGridViewControl", true).OfType <DataGridViewControl>().First(); wellKnownControl.SelectedMapDataChanged += (sender, args) => wellKnownSelectedMapDataChanged++; // When wellKnownDataGridViewControl.SetCurrentCell(wellKnownDataGridViewControl.GetCell(4, 0)); var button = new ButtonTester("selectButton", dialog); button.Click(); // Then Assert.IsInstanceOf <WellKnownTileSourceMapData>(dialog.SelectedMapData); Assert.AreEqual(1, wellKnownSelectedMapDataChanged); } }