2009-04-08 49 views
0

简而言之:如何在Silverlight单元测试期间检查UI用户控件的类型?Silverlight单元测试 - 如何检查UI基础类型?

详细信息:我在父视图中将子视图加载到ContentControl中。在测试过程中,我想检查是否在正确的时间加载了正确的视图。我的意见是在单独的项目中,我不想将这些程序集的引用添加到父视图的测试项目中(过于紧密)。

这是我坚持:

[TestMethod] 
[Asynchronous] 
[Description("Test to confirm that upon initial class creation, the login view is loaded as the default content for the TaskRegion.")] 
public void Shell_Initialisation_LoginViewIsLoadedByDefault() 
{ 
    Shell shell = new Shell(); 

    //helper method from Justin Angels example 
    WaitFor(shell, "Loaded"); 

    TestPanel.Children.Add(shell); 

    Shell_ViewModel viewModel = shell.DataContext as Shell_ViewModel; 

    EnqueueCallback(() => Assert.IsTrue(viewModel.TaskRegionContent is **How do I reference my control type**)); 

    EnqueueTestComplete(); 
} 

我应该使用嘲弄?

(该WaitFor的是由供给Justin Angel一个辅助方法)

回答