views:

31

answers:

1

I have a Silverlight application that is using a navigation frame. I am trying to write a unit-test for that application using the silverlight testing framework, however when I execute the test method I get the following error:

InvalidOperationException
No XAML was found at the location '/Pages/LoginPage.xaml'

The unit-test method looks like:

[TestMethod]
[Asynchronous]
public void TestMethod1()
{
    var mainPage = new MainPage();
    WaitFor(mainPage, "Loaded");
    TestPanel.Children.Add(mainPage);
    EnqueueCallback(() => Assert.IsTrue(mainPage != null));
    EnqueueTestComplete();
}

Here's the MainPage.xaml:

<UserControl x:Class="AccurateSilverlight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="577" d:DesignWidth="858" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" HorizontalContentAlignment="Center">

<Grid x:Name="LayoutRoot" Background="White">
    <Grid Height="36" Name="grid1" VerticalAlignment="Top" Background="#FF9A9A9A">
        <ComboBox Height="23" HorizontalAlignment="Left" Margin="6,6,0,0" Name="ModuleComboBox" VerticalAlignment="Top" Width="250" IsEnabled="False" />
        <Button Content="Logout" Height="23" Margin="0,7,6,0" Name="LogoutButton" VerticalAlignment="Top" HorizontalAlignment="Right" Width="75" IsEnabled="False" Click="LogoutButton_Click" />
    </Grid>
    <sdk:Frame Margin="0,35,0,0" Name="NavigationFrame" Source="/Pages/LoginPage.xaml" Navigated="NavigationFrame_Navigated" />
</Grid>
</UserControl>

If I run the "main" xap the application works correctly. I just have that error while testing.

I suspect the error is due to the unit-test framework executing its xap and embedding my xap in it, but cannot figure out a way to get around that.

Any clues?

A: 

'/Pages/LoginPage.xaml' is relative to your current assembly. You will need to fully qualify your route using pack URIs.

The end result should be something like this: '/AccurateSilverlight;component/Pages/LoginPage.xaml'

Murven
Works great! Thank you!
iggymoran