Stub property and save other behaviour
Is it possible to stub only one property and keep other's behaviour using Rhino Mocks?
Upd. Example: I have a class with two properties
public class ClassA
{
public string Property1
{
get
{
return "Property1";
}
}
public string Property2
{
get
{
return "Property2";
}
}
}
I would like to get an instance of this object with the stubbed only Property1 (and property2 should work as it does).
When I use the following code:
ClassA classA = MockRepository.GenerateStub<ClassA>();
classA.Stub(c => c.Pr开发者_C百科operty1).Return("stubbed property 1");
and then try to access classA.Property2 it returns null.
Take a look at Partial Mock
精彩评论