2012-01-30 83 views
0

我刚刚开始测试WP7应用程序,并且在WP7中测试异步方法时遇到问题。Enqueue ...在WP7中单元测试异步方法时未被识别的方法

下面的帖子在:http://www.codeproject.com/Articles/158531/The-Unit-Test-of-Silverlight-Applications-with-Asy 我写的测试类和实施测试方法:

[TestMethod] 
    [Asynchronous] 
    public void AsynchronousWCFCallWithGetStudentWCFCommand() 
    { 
     MainPageViewModel vm = new MainPageViewModel(); 
     bool done = false; 
     vm.AsyncCallbackCompleted += (() => done = true); 

     EnqueueCallback(() => vm.GetStudentWCFCommand.Execute(null)); 
     EnqueueConditional(() => done); 
     EnqueueCallback(() => Assert.IsNotNull(vm.StudentList, 
      "No student retrieved from the WCF service")); 
     EnqueueCallback(() => Assert.IsTrue(vm.StudentList.Count == 10, 
      "The number of the students should be 10.")); 

     EnqueueTestComplete(); 
    } 

然而,当我生成项目,VS2010不承认任何的排队方法给我喜欢的错误:“该名称'EnqueueTestComplete'在当前上下文中不存在“

我在Jeff Wilcox的网站上添加了二进制文件:http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/到我的测试项目。在测试班中,我有这2条使用语句:

using Microsoft.Silverlight.Testing; 
    using Microsoft.VisualStudio.TestTools.UnitTesting; 

我错过了什么?你能解释我的问题吗?

+1

不要假设你忘了继承SilverlightTest类吗? – 2012-01-31 11:21:18

+0

我知道我错过了一些显而易见的事情,但我没有想到我有这么糟糕的一天。感谢您指出了这一点。一切正常。 – anetafr 2012-02-01 20:44:20

回答

0

您正在开发Windows Phone 7.1(芒果)应用程序吗?如果是这样,那么你正在使用错误的程序集,你想在这里找到更新的那些jeff.wilcox/2011/06/updated-ut-mango-bits。在替换项目中的程序集后,您需要重新启动Visual Studio。

+0

对不起,我忘了添加在帖子中。我正在开发Windows Phone 7.0。 – anetafr 2012-01-30 20:45:45