title: Test with Moq if a method of external library is called
body: <p>For a project I'm using the CompositeContainer class of the MEF framework. Now I'd like to make a unit test (with moq) that verifies if the ComposeParts (which is an extension method in AttributedModelServices) method is called. </p>
  
  <p>Just mocking it with moq doesn't work because the method is not virtual. I found some ways to do this but all of them makes me change the CompositeContainer class, which I cannot do. </p>
  
  <p>Is there a way in moq to test if a non virtual method of an external 3rd party library is called? </p>
  
  <p>Thanks in advance for your reply.</p>
  
  <p>example code:</p>
  
  <pre><code>public void Load(string path, CompositionContainer container)
  {           
      container.ComposeParts(this);           
  }
  </code></pre>
  
  <p>Here container is from the MEF library and ComposeParts an extension method in the  System.ComponentModel.Composition namespace:</p>
  
  <pre><code>//
  // Summary:
  //     Creates composable parts from an array of attributed objects and composes
  //     them in the specified composition container.
  //
  // Parameters:
  //   container:
  //     The composition container to perform composition in.
  //
  //   attributedParts:
  //     An array of attributed objects to compose.
  public static void ComposeParts(this CompositionContainer container, params object[] attributedParts);
  </code></pre>