Note that there are some explanatory texts on larger screens.

plurals
  1. POCross Process Mocking in ASP.NET
    text
    copied!<p>I'm building a REST API using ASP.NET MVC 3. I'm doing it BDD-style using <a href="http://www.specflow.org/" rel="nofollow">SpecFlow</a> with NUnit as test runner.</p> <p>Since it's a REST API, testing the Url:s are obviously very important so I want to be able to make real HTTP calls in the specs. </p> <p>I'm now looking for tips on how to get Cross Process Mocking going. In short I want to mock the data layer with entities that I generate in the Specs. </p> <p>In a Rails application I would use Webrat for this. Is there anything equivalent to that in .NET yet? </p> <p>I've already tried <a href="http://blog.stevensanderson.com/2010/03/09/deleporter-cross-process-code-injection-for-aspnet/" rel="nofollow">Deleporter</a> but it doesn't seem to be able to "send" advanced constructs (Creating a simple string in the specs and using it in Deleporter works, but doesn't for a custom class the properties all becomes null)</p> <p>Does anyone have experiences or tips on how to do this?</p> <p>Edit: What I was trying do to in Deleporter was something like this (I am aware that i could generate the models inside the Deleporter code but this is a simplified example, so that wouldn't work for me):</p> <pre><code>var models = Builder&lt;Foo&gt;.CreateListOfSize(300); Deleporter.Run(() =&gt; { var mockService = new Mock&lt;IFooService&gt;(); // Models will be a list of 300 Foos but the foos properties will all be null mockService.Setup(s =&gt; s.GetStuff()).Returns(models); ObjectFactory.Inject(mockService.Object); }); </code></pre>
 

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