title: Use moq to mock a type with generic parameter
body: <p>I have the following interfaces. I'm not sure how I can use Moq to mock up an IRepository due to the fact that T is generic. I'm sure there's a way, but I haven't found anything through searching through here or google. Does anybody know how I can achieve this? </p>
  
  <p>I'm fairly new to Moq, but can see the benefit of taking the time to learn it.</p>
  
  <pre><code>    /// &lt;summary&gt;
      /// This is a marker interface that indicates that an 
      /// Entity is an Aggregate Root.
      /// &lt;/summary&gt;
      public interface IAggregateRoot
      {
      } 
  
  
  /// &lt;summary&gt;
      /// Contract for Repositories. Entities that have repositories
      /// must be of type IAggregateRoot as only aggregate roots
      /// should have a repository in DDD.
      /// &lt;/summary&gt;
      /// &lt;typeparam name="T"&gt;&lt;/typeparam&gt;
      public interface IRepository&lt;T&gt; where T : IAggregateRoot
      {
          T FindBy(int id);
          IList&lt;T&gt; FindAll();
          void Add(T item);
          void Remove(T item);
          void Remove(int id);
          void Update(T item);
          void Commit();
          void RollbackAllChanges();
      }
  </code></pre>