Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I mock or similarly inject a replacement for the query extension method applied to an NHibernate Session
    primarykey
    data
    text
    <p>I am trying to mock out or similar the Query extension method applied to an nhibernate-3 session. Similar to the following...</p> <pre><code>public IQueryable&lt;Entity&gt; GetEntities { return entities = Session.Query&lt;Entity&gt;(); } </code></pre> <p>Where the Query extension method returns an IQueryable collection. </p> <p>I can clearly mock out the Session object by using Moq or Rhinos. But as of yet not found a suitable way to fake out or replace the extension method. In fact reading answers to several questions on stack overflow, it may not be possible. </p> <p>see questions <a href="https://stackoverflow.com/questions/3988243/how-to-mock-extension-methods-with-rhino-mock">How to mock extension methods with Rhino Mock?</a> <a href="https://stackoverflow.com/questions/2295960/mocking-extension-methods-with-moq">Mocking Extension Methods with Moq</a> and links within..</p> <p>I came across the <a href="http://research.microsoft.com/en-us/projects/moles/" rel="nofollow noreferrer">microsoft moles</a> project and thought maybe I could use that to create a subsitute assembly by which I could test this one particular method. Using Pex its relatively quite easy to generate such an assembly however when I try to work a way of using this Assembly its not immediately clear of a way to factor this out.</p> <p>Ideally I would like to just check to make sure that the query extension method is called by this method and a pre-empted result is returned..</p> <p>Has anyone done anything similar, would like to hear peoples thoughts..</p> <p>Ps. there is type mock but I don't have the funds to buy it :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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