my problem is following:
I have ms unit test which uses stubbed http context for mvc routing tests. But one part of code (which uses rhino mock) is problematic:
var httpContextMock = MockRepository.GenerateStub<HttpContextBase>();
httpContextMock.Stub(c => c.Request.AppRelativeCurrentExecutionFilePath)
.Return(url);
In debug mode, second line throws an exception:
Why such an error occurs ? While tests are fired without debugger, everything works fine.
Regards
This is really weird. What's strange to me is that your code works in non-debug mode. The Request
property is not stubbed, so you can't really know what it would return. You may try the following:
var httpContextMock = MockRepository.GenerateStub<HttpContextBase>();
var httpRequestMock = MockRepository.GenerateStub<HttpContextBase>();
httpContextMock.Stub(c => c.Request).Return(httpRequestMock);
httpRequestMock.Stub(c => c.AppRelativeCurrentExecutionFilePath).Return(url);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With