public void OnDrop_ChartDataMovedToPositionOutsideRange_ThrowsException(int position) { // Setup var observer = mocks.StrictMock <IObserver>(); mocks.ReplayAll(); var chartData1 = new ChartLineData("line"); var chartData2 = new ChartAreaData("area"); var chartData3 = new ChartPointData("point"); var chartData4 = new ChartMultipleAreaData("multiple area"); var chartDataCollection = new ChartDataCollection("test data"); chartDataCollection.Add(chartData1); chartDataCollection.Add(chartData2); chartDataCollection.Add(chartData3); chartDataCollection.Add(chartData4); chartDataCollection.Attach(observer); chartLegendView.Data = chartDataCollection; ChartDataContext context1 = GetContext(chartData1); chartDataCollection.Attach(observer); using (var treeViewControl = new TreeViewControl()) { // Call void Call() => info.OnDrop(context1, chartDataCollection, chartDataCollection, position, treeViewControl); // Assert Assert.Throws <ArgumentOutOfRangeException>(Call); } }
/// <summary> /// Creates a new instance of <see cref="PipingInputView"/>. /// </summary> public PipingInputView() { InitializeComponent(); calculationObserver = new Observer(UpdateChartTitle); calculationInputObserver = new Observer(UpdateViewData); chartDataCollection = new ChartDataCollection(RiskeerCommonFormsResources.Calculation_Input); soilProfileChartData = RiskeerChartDataFactory.CreateSoilProfileChartData(); surfaceLineChartData = RiskeerChartDataFactory.CreateSurfaceLineChartData(); ditchPolderSideChartData = RiskeerChartDataFactory.CreateDitchPolderSideChartData(); bottomDitchPolderSideChartData = RiskeerChartDataFactory.CreateBottomDitchPolderSideChartData(); bottomDitchDikeSideChartData = RiskeerChartDataFactory.CreateBottomDitchDikeSideChartData(); ditchDikeSideChartData = RiskeerChartDataFactory.CreateDitchDikeSideChartData(); dikeToeAtPolderChartData = RiskeerChartDataFactory.CreateDikeToeAtPolderChartData(); dikeToeAtRiverChartData = RiskeerChartDataFactory.CreateDikeToeAtRiverChartData(); exitPointChartData = PipingChartDataFactory.CreateExitPointChartData(); entryPointChartData = PipingChartDataFactory.CreateEntryPointChartData(); chartDataCollection.Add(soilProfileChartData); chartDataCollection.Add(surfaceLineChartData); chartDataCollection.Add(ditchPolderSideChartData); chartDataCollection.Add(bottomDitchPolderSideChartData); chartDataCollection.Add(bottomDitchDikeSideChartData); chartDataCollection.Add(ditchDikeSideChartData); chartDataCollection.Add(dikeToeAtPolderChartData); chartDataCollection.Add(dikeToeAtRiverChartData); chartDataCollection.Add(exitPointChartData); chartDataCollection.Add(entryPointChartData); soilLayerChartDataLookup = new List <ChartMultipleAreaData>(); // Use lookup because the ordering in the chart data collection might change }
public void ContextMenuStrip_MapDataWithoutFeatures_ZoomToAllItemDisabled() { // Setup var builder = new CustomItemsOnlyContextMenuBuilder(); contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder); mocks.ReplayAll(); var lineData = new ChartLineData("A") { IsVisible = true }; // Call using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(lineData), null, null)) { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex, "&Zoom naar alles", "Om het zoomniveau aan te passen moet de gegevensreeks elementen bevatten.", Resources.ZoomToAllIcon, false); } }
public void ConvertSeriesItems_ChartLineDataWithRandomPointData_ConvertsAllPointsToLineSeries() { // Setup var converter = new ChartLineDataConverter(); var lineSeries = new LineSeries(); var random = new Random(21); int randomCount = random.Next(5, 10); var points = new Collection <Point2D>(); for (var i = 0; i < randomCount; i++) { points.Add(new Point2D(random.NextDouble(), random.NextDouble())); } var lineData = new ChartLineData("test data") { Points = points.ToArray() }; // Call converter.ConvertSeriesData(lineData, lineSeries); // Assert CollectionAssert.AreEqual(points.Select(p => new DataPoint(p.X, p.Y)), lineSeries.ItemsSource); }
public void ContextMenuStrip_VisibleMapData_ZoomToAllItemEnabled() { // Setup var builder = new CustomItemsOnlyContextMenuBuilder(); contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder); mocks.ReplayAll(); var lineData = new ChartLineData("A") { IsVisible = true, Points = new[] { new Point2D(0, 1) } }; // Call using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(lineData), null, null)) { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuZoomToAllIndex, "&Zoom naar alles", "Zet het zoomniveau van de grafiek dusdanig dat deze gegevensreeks precies in het beeld past.", Resources.ZoomToAllIcon); } }
public void ContextMenuStrip_NoChartControlAndEnabledZoomToAllContextMenuItemClicked_DoesNotThrow() { // Setup var lineData = new ChartLineData("A") { IsVisible = true, Points = new[] { new Point2D(0, 1) } }; var builder = new CustomItemsOnlyContextMenuBuilder(); contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder); mocks.ReplayAll(); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(lineData), null, null)) { // Call void Call() => contextMenu.Items[contextMenuZoomToAllIndex].PerformClick(); // Assert Assert.DoesNotThrow(Call); } }
public void GivenChartControlWithData_WhenDataSetToOtherChartDataCollection_ThenChartControlUpdated() { // Given using (var chartControl = new ChartControl()) { LinearPlotView linearPlotView = GetLinearPlotView(chartControl); var chartPointData = new ChartPointData("Points"); var chartLineData = new ChartLineData("Lines"); var chartAreaData = new ChartAreaData("Areas"); var chartDataCollection1 = new ChartDataCollection("Collection 1"); var chartDataCollection2 = new ChartDataCollection("Collection 2"); chartDataCollection1.Add(chartPointData); chartDataCollection2.Add(chartLineData); chartDataCollection2.Add(chartAreaData); chartControl.Data = chartDataCollection1; // Precondition Assert.AreEqual(1, linearPlotView.Model.Series.Count); Assert.AreEqual("Points", linearPlotView.Model.Series[0].Title); // When chartControl.Data = chartDataCollection2; // Then Assert.AreEqual(2, linearPlotView.Model.Series.Count); Assert.AreEqual("Lines", linearPlotView.Model.Series[0].Title); Assert.AreEqual("Areas", linearPlotView.Model.Series[1].Title); } }
public void GivenChartControlWithoutData_WhenDataSetToChartDataCollection_ThenChartControlUpdated() { // Given using (var chartControl = new ChartControl()) { LinearPlotView linearPlotView = GetLinearPlotView(chartControl); var chartPointData = new ChartPointData("Points"); var chartLineData = new ChartLineData("Lines"); var chartAreaData = new ChartAreaData("Areas"); var chartDataCollection = new ChartDataCollection("Root collection"); var nestedChartDataCollection1 = new ChartDataCollection("Nested collection 1"); var nestedChartDataCollection2 = new ChartDataCollection("Nested collection 2"); chartDataCollection.Add(chartPointData); chartDataCollection.Add(nestedChartDataCollection1); nestedChartDataCollection1.Add(chartLineData); nestedChartDataCollection1.Add(nestedChartDataCollection2); nestedChartDataCollection2.Add(chartAreaData); // When chartControl.Data = chartDataCollection; // Then ElementCollection <Series> series = linearPlotView.Model.Series; Assert.AreEqual(3, series.Count); Assert.AreEqual("Points", series[0].Title); Assert.AreEqual("Lines", series[1].Title); Assert.AreEqual("Areas", series[2].Title); } }
public void GivenChartControlWithData_WhenChartDataNotifiesChange_ThenAllSeriesReused() { // Given using (var chartControl = new ChartControl()) { LinearPlotView linearPlotView = GetLinearPlotView(chartControl); var chartPointData = new ChartPointData("Points"); var chartLineData = new ChartLineData("Lines"); var chartAreaData = new ChartAreaData("Areas"); var chartDataCollection = new ChartDataCollection("Root collection"); var nestedChartDataCollection1 = new ChartDataCollection("Nested collection 1"); var nestedChartDataCollection2 = new ChartDataCollection("Nested collection 2"); chartDataCollection.Add(chartPointData); chartDataCollection.Add(nestedChartDataCollection1); nestedChartDataCollection1.Add(chartLineData); nestedChartDataCollection1.Add(nestedChartDataCollection2); nestedChartDataCollection2.Add(chartAreaData); chartControl.Data = chartDataCollection; List <Series> seriesBeforeUpdate = linearPlotView.Model.Series.ToList(); // When chartLineData.Points = new Point2D[0]; chartLineData.NotifyObservers(); // Then CollectionAssert.AreEqual(seriesBeforeUpdate, linearPlotView.Model.Series); } }
public void ContextMenuStrip_EnabledZoomToAllContextMenuItemClicked_DoZoomToVisibleData() { // Setup var lineData = new ChartLineData("A") { IsVisible = true, Points = new[] { new Point2D(0, 1) } }; var builder = new CustomItemsOnlyContextMenuBuilder(); contextMenuBuilderProvider.Expect(p => p.Get(null, null)).IgnoreArguments().Return(builder); var chartControl = mocks.StrictMock <IChartControl>(); chartControl.Expect(c => c.Data).Return(new ChartDataCollection("name")); chartControl.Expect(c => c.ZoomToVisibleSeries(lineData)); mocks.ReplayAll(); chartLegendView.ChartControl = chartControl; using (ContextMenuStrip contextMenu = info.ContextMenuStrip(GetContext(lineData), null, null)) { // Call contextMenu.Items[contextMenuZoomToAllIndex].PerformClick(); // Assert // Assert expectancies are called in TearDown() } }
public void GetFeatureBasedChartDataRecursively_CollectionWithNestedData_ReturnAllFeatureBasedChartData() { // Setup var line = new ChartLineData("line"); var polygon = new ChartAreaData("polygon"); var nestedCollection = new ChartDataCollection("nested"); nestedCollection.Add(line); nestedCollection.Add(polygon); var collection = new ChartDataCollection("test"); var point = new ChartPointData("point"); collection.Add(point); collection.Add(nestedCollection); // Call ChartData[] featureBasedChartDatas = collection.GetChartDataRecursively().ToArray(); // Assert Assert.AreEqual(3, featureBasedChartDatas.Length); Assert.IsInstanceOf <ChartPointData>(featureBasedChartDatas[0]); Assert.IsInstanceOf <ChartLineData>(featureBasedChartDatas[1]); Assert.IsInstanceOf <ChartAreaData>(featureBasedChartDatas[2]); }
/// <summary> /// Creates a new instance of <see cref="WaveConditionsInputView"/>. /// </summary> /// <param name="calculation">The calculation to show in the view.</param> /// <param name="getHydraulicBoundaryLocationCalculationFunc">The <see cref="Func{TResult}"/> for obtaining the <see cref="HydraulicBoundaryLocationCalculation"/>.</param> /// <param name="inputViewStyle">The style which should be applied to the <see cref="ChartLineData"/>.</param> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public WaveConditionsInputView(ICalculation <WaveConditionsInput> calculation, Func <HydraulicBoundaryLocationCalculation> getHydraulicBoundaryLocationCalculationFunc, IWaveConditionsInputViewStyle inputViewStyle) { if (calculation == null) { throw new ArgumentNullException(nameof(calculation)); } if (getHydraulicBoundaryLocationCalculationFunc == null) { throw new ArgumentNullException(nameof(getHydraulicBoundaryLocationCalculationFunc)); } if (inputViewStyle == null) { throw new ArgumentNullException(nameof(inputViewStyle)); } InitializeComponent(); this.getHydraulicBoundaryLocationCalculationFunc = getHydraulicBoundaryLocationCalculationFunc; calculationObserver = new Observer(UpdateChartTitle); calculationInputObserver = new Observer(UpdateCalculationInput); hydraulicBoundaryLocationCalculationObserver = new Observer(UpdateChartData); this.calculation = calculation; calculationObserver.Observable = calculation; calculationInputObserver.Observable = calculation.InputParameters; hydraulicBoundaryLocationCalculationObserver.Observable = getHydraulicBoundaryLocationCalculationFunc(); chartDataCollection = new ChartDataCollection(RiskeerCommonFormsResources.Calculation_Input); foreshoreChartData = RiskeerChartDataFactory.CreateForeshoreGeometryChartData(); lowerBoundaryRevetmentChartData = WaveConditionsChartDataFactory.CreateLowerRevetmentBoundaryChartData(inputViewStyle.RevetmentLineColor); upperBoundaryRevetmentChartData = WaveConditionsChartDataFactory.CreateUpperRevetmentBoundaryChartData(inputViewStyle.RevetmentLineColor); lowerBoundaryWaterLevelsChartData = WaveConditionsChartDataFactory.CreateLowerWaterLevelsBoundaryChartData(); upperBoundaryWaterLevelsChartData = WaveConditionsChartDataFactory.CreateUpperWaterLevelsBoundaryChartData(); assessmentLevelChartData = WaveConditionsChartDataFactory.CreateAssessmentLevelChartData(); waterLevelsChartData = WaveConditionsChartDataFactory.CreateWaterLevelsChartData(); revetmentBaseChartData = WaveConditionsChartDataFactory.CreateRevetmentBaseChartData(inputViewStyle.RevetmentLineColor); revetmentChartData = WaveConditionsChartDataFactory.CreateRevetmentChartData(inputViewStyle.RevetmentLineColor); chartDataCollection.Add(foreshoreChartData); chartDataCollection.Add(lowerBoundaryRevetmentChartData); chartDataCollection.Add(upperBoundaryRevetmentChartData); chartDataCollection.Add(lowerBoundaryWaterLevelsChartData); chartDataCollection.Add(upperBoundaryWaterLevelsChartData); chartDataCollection.Add(assessmentLevelChartData); chartDataCollection.Add(waterLevelsChartData); chartDataCollection.Add(revetmentBaseChartData); chartDataCollection.Add(revetmentChartData); SetChartData(); chartControl.Data = chartDataCollection; UpdateChartTitle(); }
/// <summary> /// Updates the name of <paramref name="chartData"/> based on <paramref name="input"/>. /// </summary> /// <param name="chartData">The <see cref="ChartLineData"/> to update the name for.</param> /// <param name="input">The <see cref="GrassCoverErosionInwardsInput"/> used for obtaining the name.</param> /// <remarks>A default name is set (the same as in <see cref="RiskeerChartDataFactory.CreateForeshoreGeometryChartData"/>) when: /// <list type="bullet"> /// <item><paramref name="input"/> is <c>null</c>;</item> /// <item>the dike profile in <paramref name="input"/> is <c>null</c>;</item> /// <item>the foreshore should not be used.</item> /// </list> /// </remarks> public static void UpdateForeshoreGeometryChartDataName(ChartLineData chartData, GrassCoverErosionInwardsInput input) { chartData.Name = input?.DikeProfile != null && input.UseForeshore ? string.Format(RiskeerCommonFormsResources.ChartDataFactory_Create_DataIdentifier_0_DataTypeDisplayName_1_, input.DikeProfile.Name, RiskeerCommonFormsResources.Foreshore_DisplayName) : RiskeerCommonFormsResources.Foreshore_DisplayName; }
/// <summary> /// Updates the name of <paramref name="chartData"/> based on <paramref name="dikeProfile"/>. /// </summary> /// <param name="chartData">The <see cref="ChartLineData"/> to update the name for.</param> /// <param name="dikeProfile">The <see cref="DikeProfile"/> used for obtaining the name.</param> /// <remarks>A default name is set (the same as in <see cref="CreateDikeGeometryChartData"/>) when <paramref name="dikeProfile"/> is <c>null</c>.</remarks> public static void UpdateDikeGeometryChartDataName(ChartLineData chartData, DikeProfile dikeProfile) { chartData.Name = dikeProfile != null ? string.Format(RiskeerCommonFormsResources.ChartDataFactory_Create_DataIdentifier_0_DataTypeDisplayName_1_, dikeProfile.Name, Resources.DikeProfile_DisplayName) : Resources.DikeProfile_DisplayName; }
public void CreateDikeGeometryChartData_ReturnsChartDataWithExpectedStyling() { // Call ChartLineData data = GrassCoverErosionInwardsChartDataFactory.CreateDikeGeometryChartData(); // Assert Assert.AreEqual("Dijkprofiel", data.Name); AssertEqualStyle(data.Style, Color.SaddleBrown, 2, ChartLineDashStyle.Solid); }
private static void SetChartLineDataTestProperties(ChartLineData chartLineData) { chartLineData.Name = "Another name"; chartLineData.IsVisible = false; chartLineData.Points = new[] { new Point2D(1.1, 2.2) }; }
public void CreateDikeHeightChartData_ReturnsChartDataWithExpectedStyling() { // Call ChartLineData data = GrassCoverErosionInwardsChartDataFactory.CreateDikeHeightChartData(); // Assert Assert.AreEqual("Dijkhoogte", data.Name); AssertEqualStyle(data.Style, Color.MediumSeaGreen, 2, ChartLineDashStyle.Dash); }
public void CreateAssessmentLevelChartData_ReturnsEmptyChartLineDataWithExpectedStyling() { // Call ChartLineData data = WaveConditionsChartDataFactory.CreateAssessmentLevelChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Waterstand bij doelkans", data.Name); AssertEqualStyle(data.Style, Color.LightCoral, 3, ChartLineDashStyle.Solid); }
public void CreatePassiveCircleRadiusChartData_ReturnsChartLineData() { // Call ChartLineData data = MacroStabilityInwardsChartDataFactory.CreatePassiveCircleRadiusChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Radius passieve cirkel", data.Name); AssertEqualStyle(data.Style, Color.Gray, 1, ChartLineDashStyle.Dash); }
public void CreateLowerWaterLevelsBoundaryChartData_ReturnsEmptyChartLineDataWithExpectedStyling() { // Call ChartLineData data = WaveConditionsChartDataFactory.CreateLowerWaterLevelsBoundaryChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Ondergrens waterstanden", data.Name); AssertEqualStyle(data.Style, Color.MediumBlue, 3, ChartLineDashStyle.Solid); }
public void CreateSurfaceLineChartData_ReturnsChartLineDataWithExpectedStyling() { // Call ChartLineData data = RiskeerChartDataFactory.CreateSurfaceLineChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Profielschematisatie", data.Name); AssertEqualStyle(data.Style, Color.Sienna, 2, ChartLineDashStyle.Solid); }
public void CreateForeshoreGeometryChartData_ReturnsChartDataWithExpectedStyling() { // Call ChartLineData data = RiskeerChartDataFactory.CreateForeshoreGeometryChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Voorlandprofiel", data.Name); AssertEqualStyle(data.Style, Color.DarkOrange, 2, ChartLineDashStyle.Solid); }
public void CreateSlipPlaneChartData_ReturnsChartLineData() { // Call ChartLineData data = MacroStabilityInwardsChartDataFactory.CreateSlipPlaneChartData(); // Assert CollectionAssert.IsEmpty(data.Points); Assert.AreEqual("Glijvlak", data.Name); AssertEqualStyle(data.Style, Color.SaddleBrown, 3, ChartLineDashStyle.Solid); }
/// <summary> /// Creates a new instance of <see cref="ChartLineDataSeries"/>. /// </summary> /// <param name="chartLineData">The <see cref="ChartLineData"/> which the chart line data series is based upon.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="chartLineData"/> is <c>null</c>.</exception> public ChartLineDataSeries(ChartLineData chartLineData) { if (chartLineData == null) { throw new ArgumentNullException(nameof(chartLineData)); } this.chartLineData = chartLineData; Update(); }
public void UpdateSurfaceLineChartDataName_SurfaceLineNull_NameSetToDefaultSurfaceLineName() { // Setup var chartData = new ChartLineData("test name"); // Call PipingChartDataFactory.UpdateSurfaceLineChartDataName(chartData, null); // Assert Assert.AreEqual("Profielschematisatie", chartData.Name); }
public void Constructor_Always_CreatesNewInstanceOfDefaultStyle() { // Setup var dataA = new ChartLineData("test data"); // Call var dataB = new ChartLineData("test data"); // Assert Assert.AreNotSame(dataA.Style, dataB.Style); }
public void UpdateForeshoreGeometryChartDataName_InputNull_NameSetToDefaultName() { // Setup var chartData = new ChartLineData("test name"); // Call GrassCoverErosionInwardsChartDataFactory.UpdateForeshoreGeometryChartDataName(chartData, null); // Assert Assert.AreEqual("Voorlandprofiel", chartData.Name); }
public void UpdateDikeGeometryChartDataName_DikeProfileNull_NameSetToDefaultName() { // Setup var chartData = new ChartLineData("test name"); // Call GrassCoverErosionInwardsChartDataFactory.UpdateDikeGeometryChartDataName(chartData, null); // Assert Assert.AreEqual("Dijkprofiel", chartData.Name); }
/// <summary> /// Asserts whether <paramref name="actual"/> corresponds to <paramref name="startingPoint"/> /// and <paramref name="slidingCircle"/>. /// </summary> /// <param name="startingPoint">The point to use for the start of the line</param> /// <param name="slidingCircle">The circle to use for the end of the line.</param> /// <param name="actual">The actual <see cref="ChartLineData"/>.</param> /// <exception cref="AssertionException">Thrown when <paramref name="actual"/> /// does not correspond to the specified start and end points.</exception> private static void AssertCircleRadiusChartData(Point2D startingPoint, MacroStabilityInwardsSlidingCircle slidingCircle, ChartLineData actual) { Point2D[] points = { slidingCircle.Center, startingPoint }; CollectionAssert.AreEqual(points, actual.Points); }
public void UpdateSurfaceLineChartDataName_SurfaceLine_NameSetToSurfaceLineName() { // Setup var chartData = new ChartLineData("test name"); var surfaceLine = new PipingSurfaceLine("surface line name"); // Call PipingChartDataFactory.UpdateSurfaceLineChartDataName(chartData, surfaceLine); // Assert Assert.AreEqual("surface line name", chartData.Name); }