2009-04-08 69 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一個輔助方法)

回答