title: Stubbing a Property get using Rhino Mocks
body: <p>Using RhinoMocks, I am trying to Stub the getter value of a property. The property is defined as part of a Interface with only getter access.</p>
  
  <p>However I get the error "Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method)." I understand this may mean that the property I am stubbing is not virtual; However it is part of the Interface and I am not sure if that is the reason why I get this error..</p>
  
  <p>Below is the code skeleton. If I uncomment the line which says "stubRepository.Stub(x => x.StoreDeviceID).PropertyBehavior();", then I get a new error "Property must be read/write". I searched on SO and found <a href="https://stackoverflow.com/questions/1301116/rhino-mocks-error-invalid-call-the-last-call-has-been-used-or-no-call-has-bee">this</a> page. But the proposed solution doesn't help me. Any thoughts?</p>
  
  <pre><code>public interface IStore {
          string StoreDeviceID {get;}
          //other methods
      }
  
      public static class Store {
          private IStore Repository;
  
          public void SetRepository(IStore rep){
              Repository = rep;
          }
  
          public StoredeviceID {
              get{
                  return Repository.StoreDeviceID;
              }
          }
  
          //other methods
      }
  
      public class TestClass {
          [Test]
          public void TestDeviceID() {
              var stubRepository =
                  MockRepository.GenerateStub&lt;IStore&gt;();
              Store.SetRepository(stubRepository);
  
              //stubRepository.Stub(x =&gt; x.StoreDeviceID).PropertyBehavior();
              SetupResult.For(stubRepository.StoreDeviceID).Return("test");
  
              Assert.AreSame(Store.StoreDeviceID, "test");
          }
      }
  </code></pre>