title: c# how to test reference to interface
body: <p>I've asked a question before on how to <a href="https://stackoverflow.com/questions/13655557/set-value-of-interface-in-testing-a-method">set value of interface in testing a method</a>
  . I've successfully implemented the Moq framework into my project and the test runs fine. </p>
  
  <p>this is the sample code that I've featured:</p>
  
  <pre><code>public void PostEvent(
              eVtCompId inSenderComponentId, 
              eVtEvtId inEventId, 
              long inEventReference, 
              IF_SerializableData inEventData)
  {
      if(mEventMap.ContainsKey(inEventId))
      {
          mEventMap[inEventId](inSenderComponentId, inEventReference, inEventData);
      }
  }
  </code></pre>
  
  <p>Here I have 4 parameters: 1st: an enum, 2nd: another enum, 3rd: long, 4th: an interface. <strong><em>However</em></strong>, I was mistaken in that the 4th parameter (the interface), isn't supposed to be an interface, but rather a <code>reference</code> to the interface.</p>
  
  <p>so it should look like this:</p>
  
  <pre><code>public void PostEvent(
         eVtCompId inSenderComponentId, 
         eVtEvtId inEventId, 
         long inEventReference, 
         ref IF_SerializableData inEventData)
  </code></pre>
  
  <p>the sample Moq test code that was given to me (which is this)...</p>
  
  <pre><code>var serializable = new Mock&lt;IF_SerializableData&gt;();
  target.PostEvent(..., serializable.Object);
  </code></pre>
  
  <p>...doesn't work. I've tried <code>ref serializable.Object</code> but it still doesn't work because I get an error that says the ref parameter is expecting a reference to a variable, not an object.</p>
  
  <p>Any tips or examples on how to properly test this? </p>