public void LegendItemDataPointHasDataContextSet() { Chart chart = new Chart(); PieSeries series = DefaultControlToTest as PieSeries; series.DependentValueBinding = new Binding("Value"); series.IndependentValueBinding = new Binding("Value"); NotifyingDataObject <int> notifyingDataObjectA = new NotifyingDataObject <int> { Value = 5 }; NotifyingDataObject <int> notifyingDataObjectB = new NotifyingDataObject <int> { Value = 7 }; NotifyingDataObject <int>[] notifyingDataObjects = new NotifyingDataObject <int>[] { notifyingDataObjectA, notifyingDataObjectB }; series.ItemsSource = notifyingDataObjects; chart.Series.Add(series); TestAsync( chart, () => { LegendItem[] legendItems = ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>().ToArray(); Assert.AreEqual(notifyingDataObjects.Length, legendItems.Length); for (int i = 0; i < notifyingDataObjects.Length; i++) { PieDataPoint legendItemDataPoint = legendItems[i].DataContext as PieDataPoint; Assert.IsNotNull(legendItemDataPoint); Assert.AreEqual(notifyingDataObjects[i], legendItemDataPoint.DataContext); } }); }
public void LegendContentUpdatesImmediately() { Chart chart = new Chart(); PieSeries series = DefaultControlToTest as PieSeries; series.DependentValueBinding = new Binding("Value"); series.IndependentValueBinding = new Binding("Value"); NotifyingDataObject <int> notifyingDataObject = new NotifyingDataObject <int> { Value = 5 }; series.ItemsSource = new NotifyingDataObject <int>[] { notifyingDataObject }; chart.Series.Add(series); TestAsync( chart, () => { LegendItem legendItem = ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>().First(); Assert.AreEqual(5, legendItem.Content); }, () => notifyingDataObject.Value = 10, () => { LegendItem legendItem = ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>().First(); Assert.AreEqual(10, legendItem.Content); }); }
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)); }
public void ItemsSourceWithCustomObjects() { Chart chart = new Chart(); DataPointSeries series = DefaultSeriesToTest; ObservableCollection <DataObject <int> > itemsSource = new ObservableCollection <DataObject <int> >(); NotifyingDataObject <int> notifyingDataObject = new NotifyingDataObject <int> { Value = 5 }; itemsSource.Add(notifyingDataObject); itemsSource.Add(new DataObject <int> { Value = 3 }); series.ItemsSource = itemsSource; series.DependentValueBinding = new Binding("Value"); series.IndependentValueBinding = new Binding("Value"); TestAsync( chart, () => chart.Series.Add(series), () => notifyingDataObject.Value++, () => itemsSource.RemoveAt(0)); }