我刚刚开始测试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;
我错过了什么?你能解释我的问题吗?
不要假设你忘了继承SilverlightTest类吗? – 2012-01-31 11:21:18
我知道我错过了一些显而易见的事情,但我没有想到我有这么糟糕的一天。感谢您指出了这一点。一切正常。 – anetafr 2012-02-01 20:44:20