Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WP7: Getting started with UnitTest Framework: XamlParseException

I want to add Unit Tests to my WP7 project. I followed the tutrials on http://smartypantscoding.com/a-cheat-sheet-for-unit-testing-silverlight-apps-on-windows-phone-7 to get started with unit tests. But I cannot manage to get it running.

I followed all the steps from the tutorial and created the basictests.

But as soon as I want to start the project, Visual Studio throws an error:

XamlParseException occured Cannot find a Resource with the Name/Key typeNameConverter [Line: 47 Position: 24]

Line 47 refers to the initial CreateTestPage:

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{ 
            SystemTray.IsVisible = false; 
Line47:     var testPage = UnitTestSystem.CreateTestPage() as IMobileTestPage; 
            BackKeyPress += (x, xe) => xe.Cancel = testPage.NavigateBack(); 
            (Application.Current.RootVisual as PhoneApplicationFrame).Content = testPage; 
} 

Hope you can help me out! thank you!

like image 974
faiko Avatar asked Dec 21 '22 07:12

faiko


2 Answers

You are probably using Jeff Willcox's toolkit for Windows Phone 7. If you want to run it under new Windows Phone try to use new version of toolkit as I did. Try to use Jeff Willcox's toolkit for Windows Phone 7.5 (Mango) Get it here: http://www.jeff.wilcox.name/2011/06/updated-ut-mango-bits/ Good luck.

like image 85
Bartosz Węgielewski Avatar answered Feb 08 '23 20:02

Bartosz Węgielewski


I encountered this yesterday and found that App.xaml was misconfigured. Using guesswork (i.e. what interfaces implement IValueConverter?), I found this solution, which seems to work very well.

First, add this namespace to your <Application> namespace:

xmlns:Client="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing">

Then add this to <Application>:

<Application.Resources>
  <Client:TypeNameVisibilityConverter x:Name="typeNameConverter" />
  <Client:FontWeightConverter x:Name="fontWeightConverter" />
</Application.Resources>

I hope this is useful to someone.

I can confirm that Michael Dumont's solution does work as well, but you can't view test run details which is annoying when attempting to view information for broken tests when you don't have the debugger attached for whatever reason.

like image 42
Steve Rukuts Avatar answered Feb 08 '23 21:02

Steve Rukuts