instantiating a MEF ViewModel in UnitTest

Topics: Bootstrappers & IoC
Apr 4, 2012 at 7:15 PM

What is the preferred method of instantiating new ViewModels that use IoC.Get<>() to function inside a MSTest unit test?  If the answer is to write your own bootstrapper for the unit tests how can I swap in new eventAggregatore or windowmanagers per test (for mocking)?  It seems there are some problems removing or changing exported values (http://mef.codeplex.com/discussions/78785).

Are there any examples of creating a ViewModel in a unit test that use IoC.Get<>()?

 

Thanks

 

Apr 9, 2012 at 5:56 PM

Did I ask one of those questions that are so simple no one could be bothered to answer?  Is it a RTFM thing?  I'd really appreciate some insight here.  Thanks!

Apr 11, 2012 at 5:19 PM

There's some good info here that helped me when setting up unit testing when using MEF. Perhaps it will be of some help. 

http://blogs.microsoft.co.il/blogs/bnaya/search.aspx?q=Testing+and+Debugging+MEF