Pack Urls and Unit Testing. Problem with my environment?

后端 未结 4 1048
陌清茗
陌清茗 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条回答
  •  故里飘歌
    2021-02-07 05:12

    I got bitten by this problem once too...

    Referencing the assemblies isn't enough. WPF needs to call System.UriParser.Register() with its own URI parser so that System.Uri can interpret pack URLs.

    Reflecting tells us that this is done by the static constructor of System.IO.Packaging.PackUriHelper. Call any method of this class in your test, like PackUriHelper.Create() to ensure the URI parser is well registered. Kind of ugly, but should work.

提交回复
热议问题