Silverlight单元测试-如何检查UI基本类型?
简而言之:在Silverlight单元测试期间,我如何检查UI用户控件的类型 详细说明:我正在将子视图加载到父视图的ContentControl中。在测试期间,我想检查是否在正确的时间加载了正确的视图。我的视图位于不同的项目中,我不想将这些程序集的引用添加到父视图的测试项目中,因为父视图耦合得太紧密 这就是我被困的地方:Silverlight单元测试-如何检查UI基本类型?,silverlight,unit-testing,mvvm,silverlight-2.0,Silverlight,Unit Testing,Mvvm,Silverlight 2.0,简而言之:在Silverlight单元测试期间,我如何检查UI用户控件的类型 详细说明:我正在将子视图加载到父视图的ContentControl中。在测试期间,我想检查是否在正确的时间加载了正确的视图。我的视图位于不同的项目中,我不想将这些程序集的引用添加到父视图的测试项目中,因为父视图耦合得太紧密 这就是我被困的地方: [TestMethod] [Asynchronous] [Description("Test to confirm that upon initial class creati
[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是由提供的助手方法,使用GetType如何?然后,您可以对类型实例使用各种方法来检查它是类型的实例还是从类型继承的实例
Assert.IsInstanceOfType(viewModel.TaskRegionContent, typeof(Control))
其中,上面的控件是要检查的兴趣类型
另见: