I'm building a REST API using ASP.NET MVC 3. I'm doing it BDD-style using SpecFlow with NUnit as test runner.
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.
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.
In a Rails application I would use Webrat for this. Is there anything equivalent to that in .NET yet?
I've already tried Deleporter 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)
Does anyone have experiences or tips on how to do this?
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):
var models = Builder<Foo>.CreateListOfSize(300);
Deleporter.Run(() =>
{
var mockService = new Mock<IFooService>();
// Models will be a list of 300 Foos but the foos properties will all be null
mockService.Setup(s => s.GetStuff()).Returns(models);
ObjectFactory.Inject(mockService.Object);
});
I'm just investigating this myself. Looking at some of the example code in the GuestBookDemo it seems possible to use Deleporter for this.
Do you have an example of exactly what you'd like to be able to do?
I think you're probably looking for WatiN
精彩评论