I'm testing an MVC controller which relies on a value returned from a read-only property on the base class.
The getter for this property throws an exception when it is called as it is relies on a HttpContext
(and other nasty stuff) which I would rather avoid mocking.
This is what I've tried so far:
controller = Substitute.ForPartsOf<MyController>(
Substitute.For<SomeDependency>(),
);
controller.UserInfo.Returns(new UserInfo());
Yet this throws an exception as soon as UserInfo is accessed.
Property on base class is:
public UserInfo UserInfo
{
get
{
// HttpContext dependent stuff
}
}
I've tried setting the base class property to virtual but then I get a Castle proxy exception.