2
我有一個使用導航框架的Silverlight應用程序。在silverlight中測試導航
我試圖寫一個單元測試使用Silverlight的測試框架,應用程序,但是當我執行的測試方法我收到以下錯誤:
InvalidOperationException
No XAML was found at the location '/Pages/LoginPage.xaml'
的單元測試方法如下所示:
[TestMethod]
[Asynchronous]
public void TestMethod1()
{
var mainPage = new MainPage();
WaitFor(mainPage, "Loaded");
TestPanel.Children.Add(mainPage);
EnqueueCallback(() => Assert.IsTrue(mainPage != null));
EnqueueTestComplete();
}
這裏的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>
如果我跑了「米ain「xap應用程序正常工作。測試時我只是有這個錯誤。
我懷疑這個錯誤是由於單元測試框架執行它的xap並在其中嵌入了我的xap,但無法找到解決這個問題的方法。
任何線索?
很好用!謝謝! – iggymoran 2010-10-20 09:43:47