运行 RavenDB 测试驱动程序 5.0+ 时出现异常,提示需要 ASP.NET Core 5.0.0。
Sstem.InvalidOperationException: Unable to start the RavenDB Server
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.
- The following frameworks were found:
2.1.23 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
3.1.9 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
如何在不将我的项目迁移到 .NET 5.0 的情况下使用它?
最佳答案
是的,可以在没有 ASP.NET/.NET 5 的情况下使用 RavenDB 5。
需要在配置时显式指定版本,或者干脆设置为null:
var ravenServerOptions = new TestServerOptions()
{
FrameworkVersion = null
};
ConfigureServer(ravenServerOptions);
例如使用 NUnit:
[TestFixture]
public class FooTest : RavenTestDriver
{
private IDocumentStore store;
[OneTimeSetUp]
public void OneTimeSetUp()
{
var ravenServerOptions = new TestServerOptions()
{
FrameworkVersion = null
};
ConfigureServer(ravenServerOptions);
store = GetDocumentStore();
}
[OneTimeTearDown]
public void OneTimeTearDown()
{
store.Dispose();
}
[Test]
public void Test()
{
}
}
关于c# - 如何在我的单元测试项目中使用没有 .NET 5 的 RavenDB.RavenTestDriver 5+?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65375728/