title: How to Mock QueryAsync using Dapper for unit testing an Oracle stored procedure call which returns a RefCursor
body: <p>I am writing a unit test case using MOQ framework for testing an Oracle stored procedure returning a RefCursor.</p>
  <p>My project is in c# and we are using Dapper to connect to Oracle DB.</p>
  <p>This is the code am using to Mock response of QueryAsync in my test case.</p>
  <pre class="lang-cs prettyprint-override"><code>IEnumerable&lt;dynamic&gt; responseData = new List&lt;dynamic&gt;() { responseResult };
  var query = @&quot;TestProcedure&quot;;
  _connectionFactory.Setup(x =&gt; 
      x.GetOpenConnection()).Returns(_dbConnection.Object);
  _dbConnection.SetupDapperAsync(c =&gt; c.QueryAsync(query, It.IsAny&lt;OracleDynamicParameters&gt;(), It.IsAny&lt;DbTransaction&gt;(), It.IsAny&lt;int&gt;(), 
  It.IsAny&lt;CommandType&gt;())).ReturnsAsync(responseData);
  </code></pre>
  <p>This is the piece of code am hoping to test.</p>
  <pre class="lang-cs prettyprint-override"><code>var param = new OracleDynamicParameters();
  param.Add(&quot;p1&quot;, ProductLineCode, OracleMappingType.Varchar2, ParameterDirection.Input, size: 2000);
  param.Add(&quot;p2&quot;, dbType: OracleMappingType.RefCursor, direction: ParameterDirection.Output);
  
  var result = await connection.QueryAsync(&quot;TestProcedure&quot;, param, commandType: CommandType.StoredProcedure); 
  </code></pre>
  <p>While debugging the test case I encounter the below error.</p>
  <blockquote>
  <p>System.NotSupportedException: 'Whoopsies! This library will only work with Oracle types, you are attempting to use type Castle.Proxies.DbParameterProxy.'</p>
  </blockquote>
  <p>Need help in resolving the above issue</p>