views:

203

answers:

1

I am currently writing unit tests for a ViewModel in my project that uses Prism and the MVVM pattern.

My view mainly consists of an ItemsControl that reacts to different mouse events (LeftMouseButtonDown, LeftMouseButtonUp etc.). When such a mouse event happens the EventArgs and some other glue info is handed to the ViewModel and an appropriate method is called (MouseMove event --> OnMouseMove method).

This way I implemented a way to drag items that were formerly added to the ItemsControl around. That happens through setting two member variables "movingObject" and "gripPoint" in the OnMouseLeftButtonDown method and setting the variables to null in the OnMouseLeftButtonUp method.

The question that now arises is if I should unit test these functions (LeftButtonUp, LeftButtonDown). In theory they are accessed by the "outer" world (--> not by the ViewModel itself) and therefore deserve a test but how should I test the change of an private variable that (in my opinion) doesn't deserve a public accessor (for the low level purpose it exists)?

Thanks in advance!

related questions