title: Mock a property of an object to return a value that is coming from the object itself
body: <p>I want to create a mock with an object returning for one property a value that comes from another property of the same mock instance, but I don't find how to setup this with Moq.</p>
  
  <p>All signatures I find for Setup/SetupGet are allowing to return constant values only and not values coming from the same object.</p>
  
  <p>Example :</p>
  
  <pre><code>void Main()
  {
      var obj = GetMock().Object;
  
      obj.PropA = "test";
  
      Console.WriteLine(obj.Id); // Should return -354185609, as it's the result of "test".GetHashCode()
  
      obj.PropA = "test 2";
  
      Console.WriteLine(obj.Id); // Should return -1555281747, as it's the result of "test 2".GetHashCode()
  
  }
  
  public interface IMyObject
  {
      int Id { get;set;}
  
      string PropA {get; set;}
  }
  
  public Mock&lt;IMyObject&gt; GetMock()
  {
      var objectMock = new Mock&lt;IMyObject&gt;();
  
      objectMock.SetupAllProperties();
  
      objectMock
          .SetupGet((IMyObject s) =&gt; s.Id)
          //Here I would like to write something like : 
          .Returns(s =&gt; (a.PropA?.GetHashCode()).GetValueOrDefault()));
          // To have the Getter of Id initialized with the current value of PropA.GetHashCode()
  
      return objectMock;
  }
  </code></pre>
  
  <p>Thanks for your proposals</p>