5

I am writing acceptance tests that start my WPF application as follows:

    [TestCase("279")]
    [TestCase("281")]
    [TestCase("289")]
    public void StartAndInitializeSystemControl(string machineNumber)
    {
        application = new App();
        systemControl = new SystemControl(application, machineNumber);
        application.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => ApplicationOnActivated(null, null)));
        application.Run();
        Assert.Pass();
    }

I left out irrelevant parts. What I do in the code above is start the WPF App, start the App with Application.Run() execute something and verify something. All good, works fine. Things start to go south when I start to add test cases. When I add test cases, I am starting more than one WPF App per AppDomain, which is not allowed.

System.InvalidOperationException : Cannot create more than one System.Windows.Application instance in the same AppDomain.

How can I solve this? Can I "clear" the started application from the AppDomain? Can I start a different AppDomain for every test I start?

bas
  • 13,550
  • 20
  • 69
  • 146
  • possible duplicate of [Run unit tests in different appdomain with NUnit](http://stackoverflow.com/questions/9634438/run-unit-tests-in-different-appdomain-with-nunit) – ClickRick May 03 '14 at 20:59
  • I tried to create a AppDomain per test, but no luck there. Would you have a few pointers how to do this? – bas May 03 '14 at 21:10

0 Answers0