Silverlight first asynchronous test run twice
/I'm observing a pretty odd behaviour - the first test of my MVVM is running twice.
Exhibit Original code:
[TestMethod, Asynchronous]
public void VMConnectTest() { ViewModel clientVM = CreateVM(); #region connect clientVM.Connect.Execute(null); base.EnqueueConditional(delegate { return clientVM.IsConnected; }); #endregion base.EnqueueTestComplete(); }
I have a break point in CreateVM - and it's firing twice, off the same line.
Changing the code to:
[TestMethod, Asynchronous]
public void VMConnectTest() { ViewModel clientVM = null; #region connect base.EnqueueCallback(delegate { clientVM = CreateVM() clientVM.Connect.Execute(null); }); base.EnqueueConditional(delegate { return clientVM.IsConnected; }); #endregion base.EnqueueTestComplete(); }
And now the CreateVM only runs once.
I suspect the Asynchronous test has a bug regarding mixing which thread is suppose to be creating the VM. In this case, it's running twice. Throwing everything onto the test stack seems to have fixed this, but makes the code look more complex than usual.