Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Foq Verify methodsmatch fails on interface with type parameter
    text
    copied!<p>I have an interface like this</p> <pre><code>type IAppDatabase = abstract Get&lt;'T&gt; : seq&lt;Guid&gt; -&gt; Task&lt;seq&lt;'T&gt;&gt; abstract Set&lt;'T&gt; : seq&lt;'T&gt; -&gt; Task&lt;bool&gt; abstract GetIds&lt;'T&gt; : unit -&gt; Task&lt;seq&lt;Guid&gt;&gt; </code></pre> <p>I try to mock like this</p> <pre><code>let results = seq [DT.Result (); DT.Result (); DT.Result ()] let resultInfos = DT.Results results let guids = seq [Guid.NewGuid(); Guid.NewGuid(); Guid.NewGuid()] let taskGetIds = Task.Factory.StartNew&lt;seq&lt;Guid&gt;&gt;(fun () -&gt; guids) let taskSet = Task.Factory.StartNew&lt;bool&gt;(fun () -&gt; true ) let taskGet = Task.Factory.StartNew&lt;seq&lt;DT.Result&gt;&gt;(fun () -&gt; results) let db = Mock&lt;IAppDatabase&gt;.With(fun x -&gt; &lt;@ x.GetIds () --&gt; taskGetIds x.Get guids --&gt; taskGet x.Set results --&gt; taskSet @&gt;) </code></pre> <p>I have a test like this</p> <pre><code>let [&lt;Test&gt;] ``Set the resultInfos in de app database`` () = let app = App (db) :&gt; IApp let res = app.Create resultInfos |&gt; Async.RunSynchronously verify &lt;@db.Set results @&gt; once res |&gt; should be True </code></pre> <p>The <code>app.Create</code> function calls the <code>db.Set</code> with an <code>Async.AwaitTask</code>.</p> <p>This all works well and Foq is great. However the verify raises an system.exception. The <code>methodsMatch</code> function in Foq returns false, because he <code>expectedMethod</code> has a <code>ParameterInfo.ParameterType</code> of <code>System.Collections.Generic.IEnumerable``1[Result]</code> and the <code>actual.Method</code> has a <code>ParameterInfo.ParameterType</code> of <code>System.Collections.Generic.IEnumerable``1[T]</code>.</p> <p>I have tried adding and removing type parameters to no avail. I need the type paramenter (and the Task) in the interface, because it is implemented by someone else in C#.</p> <p>Is this an issue with the <code>generateAddInvocation</code> method or am I calling the verify wrong? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload