0
我正在使用Rhino Mock 3.5 for .Net Framework 2.0,当我运行此代码时出现运行时错误。RhinoMock 3.5在运行时运行时错误.net
这是代码
IFile fileInterface = MockRepository.GenerateStub<IFile>();<br>
IUrlMapper urlMapper = MockRepository.GenerateStub<IUrlMapper>();
// this is the line causing the run-time error<br>
HttpContextBase mockHttpContext = MockRepository.GenerateMock<HttpContextBase>();
HttpRequestBase mockRequest = MockRepository.GenerateMock<HttpRequestBase>();
RhinoMocksExtensions.Stub<HttpContextBase,HttpRequestBase>(mockHttpContext, delegate(HttpContextBase ctx)
{
return ctx.Request;
}
).Return(mockRequest);
RhinoMocksExtensions.Stub(fileInterface, delegate(IFile f)
{
f.Exists(Arg<string>.Is.Anything);
}
).Return(true);
AspxReplacementResolver resolverToTest = new AspxReplacementResolver(mockHttpContext, fileInterface, urlMapper);
这是在错误:
TestCase 'TestMockingRhinoMock35.TestTestFixtures.Test1'
failed: System.TypeLoadException : Could not load type 'System.Web.RequestNotification' from assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'......
System.Web.RequestNotification是框架3.0的一部分,但我使用Framework 2.0和我引用了特定的Rhino Mocks 3.5 for Framework 2.0 dll。
谢谢
感谢您的回复。实际上,你可以添加一个对System.Web.Abstractions的引用,并在.Net 2.0中使用它;我一直在成功地使用它。 现在,我正在写这些测试,我得到这个错误,所以我想我将不得不针对.net 3.5进行测试,因为我有一个单独的程序集。 再次感谢 – 2009-07-20 16:38:00