所以我试图用RavenDB和ServiceStack构建一个End To End集成测试套件,但是我遇到了一个非常奇怪的问题,即验证不能在某些请求上运行.这真的很奇怪,我不确定我做错了什么.我正在使用NCrunch.有时测试通过,有时它会失败.
希望这是一个简单的解决方案,我正在做的事情.
您可以在http://github.com/khalidabuhakmeh/endtoend上下载整个项目
除了VS2012和NuGet Package Restore之外,您不需要任何其他功能.
更新:我决定在NCrunch和Resharper Test Runner中运行它,两者都给出相同的结果[见下图].
更新更新:我认为它可能是XUnit,所以我尝试使用NUnit.不,还是同样的问题.

**另一个更新:根据user1901853的请求输入控制台写入.这就是结果."

最新更新:RequestFilters正在逐渐消失,我不知道为什么.看起来它可能是一个线程问题,但我看不到在哪里.
我的AppHost正在使用AppHostListenerBase.
using EndToEnd.Core;
using Funq;
using Raven.Client;
using ServiceStack.ServiceInterface.Validation;
using ServiceStack.WebHost.Endpoints;
namespace EndToEnd
{
public class TestAppHost
: AppHostHttpListenerBase
{
private readonly IDocumentStore _documentStore;
public TestAppHost(IDocumentStore documentStore)
: base("Test AppHost Api", typeof(TestAppHost).Assembly)
{
_documentStore = documentStore;
}
public override void Configure(Container container)
{
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
// Register RavenDB things
container.Register(_documentStore);
container.Register(c =>
{
var db = c.Resolve<IDocumentStore>();
return db.OpenSession();
}).ReusedWithin(ReuseScope.Request);
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(CreateWidgetValidator).Assembly); …Run Code Online (Sandbox Code Playgroud)