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 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 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 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); } }