Hi,
I'm writing tests for the usual reason. I have a XamChart where I've added a drag feature for the user. The user can select a data point and move it up and down. The backing custom class is updated which cascades the update to a XamDataGrid. Everything works fine, but I'm running into problems during testing. Specifically, this line throws an exception:
var hitArgs = xamChart.HitTest(e);
Here is the exception:
System.NullReferenceException was unhandled by user code Message=Object reference not set to an instance of an object. Source=InfragisticsWPF3.Chart.v10.2 StackTrace: at Infragistics.Windows.Chart.XamChart.HitTest(MouseEventArgs e) at Intel.Wolf.UI.WPFMVApp.Helpers.XamChartHelper.MouseLeftButtonDownHandler(Object sender, MouseButtonEventArgs e) in C:\<...>\Helpers\XamChartHelper.cs:line 95 InnerException:
If I run the code in the Immediate Window I get this:
? xamChart == null
false
? e == null
xamChart.HitTest(e)
'xamChart.HitTest(e)' threw an exception of type 'System.NullReferenceException'
base {System.SystemException}: {"Object reference not set to an instance of an object."}
What 'Object'? Neither xamChart or e are null.
Complete method:
private static void MouseLeftButtonDownHandler(object sender, MouseButtonEventArgs e) { var xamChart = sender as XamChart; if (xamChart == null || e == null) return; var hitArgs = xamChart.HitTest(e); selectedDataPoint = hitArgs.SelectedObject as DataPoint; if (selectedDataPoint != null) { xamChart.Cursor = Cursors.SizeNS; started = true; } e.Handled = true; }
Here is my test:
[TestMethod] public void MouseLeftButtonDownHandlerTest() { var chart = new XamChart(); chart.Width = 300; // ??? Create a size to be selected ??? chart.Height = 300; XamChartHelper.SetChartDragging(chart, true); var e = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left); e.RoutedEvent = XamChart.MouseLeftButtonDownEvent; //chart.RaiseEvent(e); XamChartHelper_Accessor.MouseLeftButtonDownHandler(chart, e); // ToDo: Need more logic testing beyond "handled" Assert.IsTrue(e.Handled); }
VS 2010 Ultimate, Win7 x64, InfragisticsWPF3.Chart.v10.2
Can anyone point me in a direction?
We fixed one issue related to the chart hit test. Can you try applying the latest service release and tell us if your issue still exists?
I updated all of my dlls to the latest service release (downloaded today). No change in behavior. I'm still getting the same exception at the same place in my test execution.
dll version: 10.2.20102.2174