Testing 对部分Mock-NullReference异常的期望
我对使用Rhino Mock进行部分模拟有一个问题:Testing 对部分Mock-NullReference异常的期望,testing,rhino-mocks,partial-mocks,Testing,Rhino Mocks,Partial Mocks,我对使用Rhino Mock进行部分模拟有一个问题: var authentication = (FormsAuthenticationService)_mocks.PartialMock( typeof(FormsAuthenticationService)); Expect.Call( delegate{ authentication.SetAuthCookie(null, null); }).IgnoreArguments(); …我在“Expect.”行上得到NullReferen
var authentication = (FormsAuthenticationService)_mocks.PartialMock(
typeof(FormsAuthenticationService));
Expect.Call( delegate{ authentication.SetAuthCookie(null, null); }).IgnoreArguments();
…我在“Expect.”行上得到NullReferenceException
我将只添加
FormsAuthenticationService
实现IAAuthentication
您是否有充分的理由试图模拟物理类而不是接口?我这样问是因为模仿FormsAuthenticationService存在两个潜在问题:
var authentication = _mocks.DynamicMock<IAuthentication>();
Expect.Call(() => authentication.SetAuthCookie(null, null)).IgnoreArguments();
var身份验证=_mocks.DynamicMock();
Expect.Call(()=>authentication.SetAuthCookie(null,null)).IgnoreArguments();