I have a virtual property, FirstName
, on an abstract class, Foo
. I need to test the virtual property's behavior. The method never fires when this test executes (and so the test always fails, no matter what's in the method's body). How can I make this method my system under test? How can I test this method?
[Subject(typeof(Foo))]
public class When_whatever
{
Establish context = () =>
{
_fooSut = _mockRepository.PartialMock<Foo>(argumentOne, argumentTwo);
};
Because of = () => _result = _fooSut.FirstName;
It should_return_not_null = () => _result.ShouldNotBeNull();
private static string _result;
private static Foo _fooSut;
}
I'm using Rhino Mocks 3.5 and mspec.
Are you tried PartialMock
feature? See here