views:

30

answers:

1

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.Property1).Return("stubbed property 1");

and then try to access classA.Property2 it returns null.

+3  A: 

Take a look at Partial Mock

gautema
Thank you! That's what I need.
Idsa