I have a Windows Phone 7 Silverlight application that I am trying to run a unit test. My tests fail with the following error:
System.DivideByZeroException: Attempted division by zero.
In the next line:
Deployment.Current.Dispatcher.BeginInvoke(() => RaisePropertyChanged("Lat"));
I assume this is because there is no user interface thread. Do I need to abstract the calls BeginInvokeso that they can mock my test?
Update:
I ended up abstracting, so I could make fun of in unit test. It works great. What do you think?
public class UiDispatcher : IUiDispatcher
{
public void InvokeOnUiThread(Action action)
{
Deployment.Current.Dispatcher.BeginInvoke(action);
}
}
source
share