public void PieSeriesWithTwoDoubles()
        {
            KeyValuePair <string, double>[] objects = new KeyValuePair <string, double>[]
            {
                new KeyValuePair <string, double>("A", 90000.0),
                new KeyValuePair <string, double>("B", 80000.0),
            };
            Chart           chart     = new Chart();
            DataPointSeries pieSeries = DefaultSeriesToTest;

            chart.Series.Add(pieSeries);
            pieSeries.IndependentValueBinding = new Binding("Key");
            pieSeries.DependentValueBinding   = new Binding("Value");
            TestAsync(
                chart,
                () => pieSeries.ItemsSource = objects,
                () => Assert.AreEqual(2, chart.LegendItems.Cast <object>().Count()),
                () =>
            {
                IList <PieDataPoint> pieDataPoints = ChartTestUtilities.GetDataPointsForSeries(pieSeries).Cast <PieDataPoint>().ToList();
                Assert.AreEqual(2, pieDataPoints.Count);
                foreach (PieDataPoint pieDataPoint in pieDataPoints)
                {
                    Assert.IsNotNull(pieDataPoint.Geometry);
                    Assert.AreSame(typeof(PathGeometry), pieDataPoint.Geometry.GetType());
                    Assert.IsNotNull(pieDataPoint.GeometryHighlight);
                    Assert.AreSame(typeof(PathGeometry), pieDataPoint.GeometryHighlight.GetType());
                    Assert.IsNotNull(pieDataPoint.GeometrySelection);
                    Assert.AreSame(typeof(PathGeometry), pieDataPoint.GeometrySelection.GetType());
                }
            });
        }
        public void DateTimeAxisWorksAsIndependentAxis()
        {
            Chart           chart  = new Chart();
            DataPointSeries series = DefaultSeriesToTest;

            series.DependentValueBinding   = new Binding("Value");
            series.IndependentValueBinding = new Binding("Key");
            series.ItemsSource             = new KeyValuePair <DateTime, int>[]
            {
                new KeyValuePair <DateTime, int>(new DateTime(2009, 1, 1), 1),
                new KeyValuePair <DateTime, int>(new DateTime(2009, 1, 2), 3),
                new KeyValuePair <DateTime, int>(new DateTime(2009, 1, 3), 4),
            };
            var axis = new DateTimeAxis();

            axis.Interval     = 1;
            axis.IntervalType = DateTimeIntervalType.Days;
            if (series is BarSeries)
            {
                axis.Orientation = AxisOrientation.Y;
                ((BarSeries)series).IndependentAxis = axis;
            }
            else
            {
                axis.Orientation = AxisOrientation.X;
                ((ColumnSeries)series).IndependentAxis = axis;
            }
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void SimpleChartOneIntegerValueZero()
        {
            DataPointSeries series = DefaultSeriesToTest;

            series.ItemsSource = new int[] { 0 };
            Chart chart = new Chart();

            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void SimpleChartTwoIntegers()
        {
            DataPointSeries series = DefaultSeriesToTest;

            series.ItemsSource = new List <int>(new int[] { 1, -1 });
            Chart chart = new Chart();

            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(2, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void UsingValuePathsWorks()
        {
            Chart           chart  = new Chart();
            DataPointSeries series = DefaultDataPointSeriesToTest;

            series.DependentValuePath   = "Value";
            series.IndependentValuePath = "Key";
            series.ItemsSource          = new KeyValuePair <int, int>[] { new KeyValuePair <int, int>(1, 2), new KeyValuePair <int, int>(3, 4), new KeyValuePair <int, int>(5, 6) };
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count()));
        }
        public void LineChartNoValues()
        {
            DataPointSeries series = DefaultSeriesToTest;

            series.ItemsSource             = new int[0];
            series.IndependentValueBinding = new Binding();
            Chart chart = new Chart();

            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(0, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void ScatterChartTwoIntegers()
        {
            DataPointSeries series = DefaultSeriesToTest;

            series.ItemsSource             = new int[] { 1, 2 };
            series.IndependentValueBinding = new Binding();
            Chart chart = new Chart();

            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(2, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void SimpleChartWithBindings()
        {
            DataPointSeries series = DefaultSeriesToTest;

            series.ItemsSource             = new[] { new KeyValuePair <string, double>("A", 2) };
            series.IndependentValueBinding = new Binding("Key");
            series.DependentValueBinding   = new Binding("Value");
            Chart chart = new Chart();

            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(1, chart.Series.Count),
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
        public void PieSeriesWithOneDoubleChangesValueToZero()
        {
            ObservableCollection <int> objects = new ObservableCollection <int>();

            objects.Add(5);
            Chart           chart     = new Chart();
            DataPointSeries pieSeries = DefaultSeriesToTest;

            pieSeries.ItemsSource = objects;
            chart.Series.Add(pieSeries);
            TestAsync(
                chart,
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(pieSeries).Count()),
                () => objects[0] = 0,
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(pieSeries).Count()));
        }
        public void ChangeStateOfDataPointsWithoutVsmStates()
        {
            Chart           chart  = new Chart();
            DataPointSeries series = DefaultDataPointSeriesToTest;

            series.IndependentValueBinding = new Binding();
            ObservableCollection <int> itemsSource = new ObservableCollection <int> {
                1, 2, 3
            };

            series.ItemsSource    = itemsSource;
            series.DataPointStyle = (Style)XamlReader.Load(SimpleDataPointStyle);
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count),
                () => itemsSource.Clear(),
                () => Assert.AreEqual(0, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
Exemplo n.º 11
0
        public void PieSeriesWithThreeIntegers()
        {
            KeyValuePair <string, int>[] objects = new KeyValuePair <string, int>[]
            {
                new KeyValuePair <string, int>("A", 700),
                new KeyValuePair <string, int>("B", 800),
                new KeyValuePair <string, int>("C", 900),
            };
            Chart           chart     = new Chart();
            DataPointSeries pieSeries = DefaultSeriesToTest;

            chart.Series.Add(pieSeries);
            pieSeries.IndependentValueBinding = new Binding("Key");
            pieSeries.DependentValueBinding   = new Binding("Value");
            TestAsync(
                chart,
                () => pieSeries.ItemsSource = objects,
                () => Assert.AreEqual(3, chart.LegendItems.Cast <object>().Count()),
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(pieSeries).Count));
        }
Exemplo n.º 12
0
        public void ChangeIndependentDateTimeValue()
        {
            Chart      chart  = new Chart();
            AreaSeries series = (AreaSeries)DefaultControlToTest;

            series.DependentValueBinding   = new Binding("Value.Day");
            series.IndependentValueBinding = new Binding("Value");
            var dataObject = new NotifyingDataObject <DateTime> {
                Value = new DateTime(2009, 1, 10)
            };

            NotifyingDataObject <DateTime>[] itemsSource = new NotifyingDataObject <DateTime>[] { dataObject };
            series.ItemsSource = itemsSource;
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(series).Count),
                () => dataObject.Value = dataObject.Value.AddDays(1),
                () => Assert.AreEqual(1, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
Exemplo n.º 13
0
        public void AbleToSetMinimumMaximumOnDependentAxis()
        {
            Chart        chart  = new Chart();
            ColumnSeries series = new ColumnSeries();

            series.ItemsSource = new int[] { 1, 2, 3 };
            LinearAxis dependentAxis = new LinearAxis {
                Orientation = AxisOrientation.Y
            };

            series.DependentRangeAxis = dependentAxis;
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count()),
                () => dependentAxis.Maximum = 5,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count()),
                () => dependentAxis.Minimum = 0.5,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count()));
        }
Exemplo n.º 14
0
        public void PathFillIsNotDefaultBrush()
        {
            Chart      chart  = new Chart();
            AreaSeries series = (AreaSeries)DefaultControlToTest;

            series.IndependentValueBinding = new Binding();
            ObservableCollection <int> itemsSource = new ObservableCollection <int> {
                1, 2, 3
            };

            series.ItemsSource = itemsSource;
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count()),
                () =>
            {
                Path area = chart.GetVisualDescendents().OfType <Path>().FirstOrDefault();
                Assert.AreNotEqual(typeof(SolidColorBrush), area.Fill.GetType());
            });
        }
        public void SelectWithHashCollision()
        {
            Chart           chart  = new Chart();
            DataPointSeries series = DefaultDataPointSeriesToTest;

            series.DependentValueBinding   = new Binding("X");
            series.IndependentValueBinding = new Binding("Y");
            Point[] items = new Point[] { new Point(1, 2), new Point(2, 1) };
            series.ItemsSource        = items;
            series.IsSelectionEnabled = true;
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => series.SelectedItem = items[0],
                () => ChartTestUtilities.GetDataPointsForSeries(series).Where(dp => items[0] == (Point)dp.DataContext).Single().IsSelectionEnabled = false,
                () => Assert.AreEqual(null, series.SelectedItem),
                () => series.SelectedItem = null,
                () => series.SelectedItem = items[1],
                () => ChartTestUtilities.GetDataPointsForSeries(series).Where(dp => items[1] == (Point)dp.DataContext).Single().IsSelectionEnabled = false,
                () => Assert.AreEqual(null, series.SelectedItem));
        }
        public void RemoveAndUpdateCollectionValues()
        {
            Chart           chart  = new Chart();
            DataPointSeries series = DefaultDataPointSeriesToTest;

            series.IndependentValueBinding = new Binding();
            ObservableCollection <int> itemsSource = new ObservableCollection <int> {
                1, 2, 3, 4
            };

            series.ItemsSource    = itemsSource;
            series.DataPointStyle = (Style)XamlReader.Load(SimpleDataPointStyle);
            chart.Series.Add(series);
            TestAsync(
                chart,
                () => Assert.AreEqual(4, ChartTestUtilities.GetDataPointsForSeries(series).Count),
                () => itemsSource.RemoveAt(3),
                () => Assert.AreEqual(3, ChartTestUtilities.GetDataPointsForSeries(series).Count),
                () => itemsSource[2] = 4,
                () => itemsSource.RemoveAt(2),
                () => Assert.AreEqual(2, ChartTestUtilities.GetDataPointsForSeries(series).Count));
        }
Exemplo n.º 17
0
        public void PieSeriesWithOneDoubleValueNan()
        {
            KeyValuePair <string, double>[] objects = new KeyValuePair <string, double>[]
            {
                new KeyValuePair <string, double>("A", double.NaN)
            };
            Chart           chart     = new Chart();
            DataPointSeries pieSeries = DefaultSeriesToTest;

            chart.Series.Add(pieSeries);
            pieSeries.IndependentValueBinding = new Binding("Key");
            pieSeries.DependentValueBinding   = new Binding("Value");
            TestAsync(
                chart,
                () => pieSeries.ItemsSource = objects,
                () => Assert.AreEqual(1, chart.LegendItems.Cast <object>().Count()),
                () =>
            {
                IList <PieDataPoint> pieDataPoints = ChartTestUtilities.GetDataPointsForSeries(pieSeries).Cast <PieDataPoint>().ToList();
                Assert.AreEqual(1, pieDataPoints.Count);
                Assert.IsNull(pieDataPoints[0].Geometry);
            });
        }