我有以下一段测试代码,想要在封闭lambda表达式外访问变量结果。显然这不起作用,因为结果总是为空?我已经谷歌搜索了一下,但似乎让自己更加困惑。我有什么选择?访问封闭范围外的lambda表达式
RequestResult result = null;
RunSession(session =>
{
result = session.ProcessRequest("~/Services/GetToken");
});
result //is null outside the lambda
编辑 - 下面
的RunSession方法的详细信息具有以下特征
protected static void RunSession(Action<BrowsingSession> script)
将考虑背地面过程,我使用这个博客的代码: - http:// geekswithblogs.net/thomasweller/archive/2009/12/12/integration-testing-an-asp.net-mvc-application-without-web-server-or.aspx 反过来使用http://blog.codeville .net/2009/06/11/integration-testing-your-aspnet-mvc-application/ 所以它可能是后台线程! – Rippo 2009-12-21 16:46:12