7

我正在使用 ASP.NET MVC 3 构建一个 REST API。我正在使用带有 NUnit 作为测试运行器的SpecFlow进行 BDD 样式。

由于它是一个 REST API,因此测试 Url:s 显然非常重要,因此我希望能够在规范中进行真正的 HTTP 调用。

我现在正在寻找有关如何进行跨进程模拟的提示。简而言之,我想用我在 Specs 中生成的实体来模拟数据层。

在 Rails 应用程序中,我会为此使用 Webrat。.NET 中是否有与此等价的东西?

我已经尝试过Deleporter,但它似乎无法“发送”高级构造(在规范中创建一个简单的字符串并在 Deleporter 中使用它可以工作,但对于自定义类,所有属性都变为空)

有没有人有关于如何做到这一点的经验或提示?

编辑:我在 Deleporter 中尝试做的事情是这样的(我知道我可以在 Deleporter 代码中生成模型,但这是一个简化的示例,所以这对我不起作用):

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);
});
4

2 回答 2

1

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?

于 2011-03-02T15:05:54.203 回答
-1

我想你可能正在寻找WatiN

于 2011-02-28T16:55:12.217 回答