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 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 LegendTitlesWhenIndependentValueBindingUnset() { Chart chart = new Chart(); PieSeries series = DefaultControlToTest as PieSeries; series.ItemsSource = new int[] { 10, 11, 12 }; chart.Series.Add(series); TestAsync( chart, () => { int i = 1; foreach (var legendItem in ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>()) { Assert.AreEqual(i, legendItem.Content); i++; } }); }
public void VerifyLegendItemDataPointStyleApplied() { Chart chart = new Chart(); DataPointSeries series = DefaultSeriesToTest; chart.Series.Add(series); TestAsync( chart, () => Assert.IsNotNull(ChartTestUtilities.GetLegend(chart)), () => { foreach (var legendItem in ChartTestUtilities.GetLegend(chart).Items.OfType <LegendItem>()) { var dataPoint = legendItem.DataContext as DataPoint; if (null != dataPoint) { Assert.AreNotEqual(typeof(SolidColorBrush), dataPoint.Background.GetType()); } } }); }