开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜