【发布时间】:2011-03-21 04:13:18
【问题描述】:
是否可以使用 Rhino Mocks 来模拟 WindowsImpersonationContext?
我明白了:
System.MissingMethodException:找不到具有匹配参数的构造函数 ----> System.MissingMethodException : 'WindowsImpersonationContextProxy04bee852de914d5b8a47d6776edc4cb3' 类型的构造函数
var windowsImpersonationContext = mockRepository.Stub<WindowsImpersonationContext>();
mockImpersonation.Stub(x => x.ImpersonateUser("username", "domain", "password")).Return(windowsImpersonationContext);
这是我需要模拟的代码
public interface IImpersonation
{
WindowsImpersonationContext ImpersonateUser(string sUsername, string sDomain, string sPassword);
}
【问题讨论】:
-
噗,那段代码只有 3 行,而且你的变量名拼错了。强大的犀牛不为所动。好的,我已经模拟了你的代码。
标签: c# security mocking rhino-mocks impersonation