Pack Urls and Unit Testing. Problem with my environment?

后端 未结 4 1047
陌清茗
陌清茗 2021-02-07 04:45

So I\'ve got this nice little MVVM solution, and things work great. I\'ve got a view model for a header bar that adjusts the icon based on the state of the application, etc. I\'

4条回答
  •  Happy的楠姐
    2021-02-07 04:52

    Building on other answers, here's the (NUnit) code that made my tests go green:

    In AssemblyInfo.cs:

    [assembly: RequiresSTA]
    

    In its own file:

    [SetUpFixture]
    public class PreTestSetup
    {
        [SetUp]
        public void Setup()
        {
            PackUriHelper.Create(new Uri("reliable://0"));
            new FrameworkElement();
            System.Windows.Application.ResourceAssembly = typeof (App).Assembly;
        }
    }
    

    App is my main application class. Any class in the relevant assembly will do, presumably.

提交回复
热议问题