Esempio n. 1
0
        public void GivenChartControlWithData_WhenChartDataRemoved_ThenCorrespondingSeriesRemovedAndOtherSeriesReused()
        {
            // 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();

                // Precondition
                Assert.AreEqual(3, seriesBeforeUpdate.Count);

                // When
                nestedChartDataCollection1.Remove(chartLineData);
                nestedChartDataCollection1.NotifyObservers();

                // Then
                ElementCollection <Series> series = linearPlotView.Model.Series;
                Assert.AreEqual(2, series.Count);
                Assert.AreEqual("Points", series[0].Title);
                Assert.AreEqual("Areas", series[1].Title);
                Assert.AreEqual(0, series.Except(seriesBeforeUpdate).Count());
            }
        }