title: Scalamock: Mocking a generic case class results in type mismatch
body: <p>I'm using Mongodb as persistence in my application and I'm currently writing test for my code. My CUT looks as following</p>
  
  <pre><code>implicit def storageHandler[M[_]: Monad](
      implicit mongoDatabase: MongoDatabase
  ) = new Storage.Handler[M] {
      override def store(order: Order): M[Unit] = Monad[M].pure {
        val collection: MongoCollection[Document] = mongoDatabase.getCollection("order")
  
        val document: Document = Document(order.asJson.toString)
  
        collection.insertOne(document).subscribe((x: Completed) =&gt; ())
     }
  }
  </code></pre>
  
  <p>My mock is getting properly injected by using implicits. I'm mocking the getCollection call which on it's own should result in another mock, this time of type</p>
  
  <pre><code>MongoCollection[org.mongodb.scala.bson.collection.immutable.Document]
  </code></pre>
  
  <p>So what I'm doing is the following</p>
  
  <pre><code>val mongoCollection: MongoCollection[Document] = mock[MongoCollection[Document]]
  
  (mongoDatabase.getCollection[Document] _).expects("order").once().returning(mongoCollection)
  </code></pre>
  
  <p>But this result in the following error</p>
  
  <pre><code>type mismatch;
  [error]  found   : com.mongodb.async.client.MongoCollection[TResult]
  [error]  required: com.mongodb.async.client.MongoCollection[org.mongodb.scala.bson.collection.immutable.Document]
  [error]  val mongoCollection: MongoCollection[Document] = mock[MongoCollection[Document]]
  </code></pre>
  
  <p>TResult is the generic parameter from the mongoCollection, which looks like this:</p>
  
  <pre><code>case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResult]) { 
  .... 
  }
  </code></pre>
  
  <p>It seems that the generic parameter is not properly "adjusted" (I'm not sure how to call it) to Document</p>