title: Unit Testing How can I mock `DbContext.Database.SqlQuery<TElement>(sql, params);` call?
body: <p>How can I mock <code>DbContext.Database.SqlQuery&lt;TElement&gt;(sql, params);</code> call where it returns an instance of <code>DbRawSqlQuery&lt;TElement&gt;</code>?</p>
  
  <p>I have gone through the following article and created my own context.</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/dn314431(v=vs.113).aspx" rel="nofollow noreferrer">Entity Framework Testing with Your Own Test Doubles (EF6 onwards)</a></p>
  
  <p>In the product code, there is a call to <code>DbContext.Database.SqlQuery&lt;TElement&gt;(sql, params);</code> method and the code is consuming <code>ToListAsync</code> method of <code>DbRawSqlQuery&lt;TElement&gt;</code>. </p>
  
  <p>I am stuck here to mock this call.</p>