c# - Writing Unit test to Launch WPF popup window using Caliburn -


I want to write a test for a WPF application (Calibern Micro and Oftfac). The purpose of this test is to display a popup window with the unit test case. I tried writing with the WPF window alone and it worked:

But when I tried to integrate it with existing solution which uses calibern micro and embedded; Autofac and there are some problems in it, in which I found dictionaries and styles:

  public MyViewModelTest () {this.repository = new MockRepository (); Var event ergator = this. Repository Stub & lt; Event Aggregator & gt; (); // See other dependency model = new MyViewModel (eventAggregator, other dependency); GenerateDummyData (); } [Test] Public Zero OpenMyViewModelTest () {var uiThread = New thread (Show); UiThread.SetApartmentState (ApartmentState.STA); UiThread.Start (); // Wait for UI thread to finish uiThread.Join (); } Private Zero Show () {// Testing and removing Todd create a new window. Var fg = new MyView {height = 500, width = 500, datacontax = view model}; // var fg = new main view {height = 500, width = 500, datacontax = view model}; Fg.ShowDialog (); }  

Now if I execute a test from a different test project solution (the UI is not in the project, where the view, view modules are available) I get an exception:

Setup: System.BadImageFormatException: File or Assembly 'ABC.UIAssemblyName, Version = 1.0.0.0, Culture = Neutral, PublicKeyToken = null' or one of its dependencies could not be loaded. Attempted to load a program with an incorrect format.

If I run tests and copies from the WPF UI project, then an empty window becomes lanushed.

So, I'm thinking that I do not forget anything. Do I need to explicitly provide style resources, dictionaries and images etc. in the examination with WPF window.

For WPF windows, there will be a plus for writing test cases with Calibern Micro.

Thanks


Comments