xunit中的ravenTestDriver返回Unable to start the RavenDB Server



我试图在.net6中用RavenTestDriver测试一个简单的代码,这是我的代码:

public class RavenDBTestDriver : RavenTestDriver
{
//This allows us to modify the conventions of the store we get from 'GetDocumentStore'
protected override void PreInitialize(IDocumentStore documentStore)
{
documentStore.Conventions.MaxNumberOfRequestsPerSession = 50;

}
[Fact]
public void MyFirstTest()
{
ConfigureServer(new TestServerOptions
{
//DataDirectory = "C:\RavenDBTestDir",
CommandLineArgs = new System.Collections.Generic.List<string> { "--RunInMemory=true", },
FrameworkVersion = null,
});
using (var store = GetDocumentStore())
{
store.ExecuteIndex(new TestDocumentByName());
using (var session = store.OpenSession())
{
session.Store(new TestDocument { Name = "Hello world!" });
session.Store(new TestDocument { Name = "Goodbye..." });
session.SaveChanges();
}
WaitForIndexing(store); //If we want to query documents sometime we need to wait for the indexes to catch up
WaitForUserToContinueTheTest(store);//Sometimes we want to debug the test itself, this redirect us to the studio
using (var session = store.OpenSession())
{
var query = session.Query<TestDocument, TestDocumentByName>().Where(x => x.Name == "hello").ToList();
Assert.Single(query);
}
}
}
public class TestDocumentByName : AbstractIndexCreationTask<TestDocument>
{
public TestDocumentByName()
{
Map = docs => from doc in docs select new { doc.Name };
Indexes.Add(x => x.Name, FieldIndexing.Search);
}
}
public class TestDocument
{
public string Name { get; set; }
}
}

但是当我运行测试时,我得到了这个错误:

System.InvalidOperationException : Unable to start the RavenDB Server
Error:
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '6.0.1' (x64) was not found.
- The following frameworks were found:
5.0.7 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
6.0.0-preview.6.21352.12 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
6.0.0 at [C:Program FilesdotnetsharedMicrosoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.1&arch=x64&rid=win10-x64


Stack Trace: 
EmbeddedServer.RunServer() line 299
EmbeddedServer.GetServerUriAsync(CancellationToken token) line 185
<<RunSync>b__0>d.MoveNext() line 106
--- End of stack trace from previous location ---
AsyncHelpers.RunSync[T](Func`1 task) line 125
RavenTestDriver.RunServer() line 274
Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
Lazy`1.CreateValue()
Lazy`1.get_Value()
RavenTestDriver.GetDocumentStore(GetDocumentStoreOptions options, String database) line 78
RavenDBTestDriver.MyFirstTest() line 34

最后,因为我不想更改我的.net版本,我安装了

"RavenDB.TestDriver" Version="5.2.0"

相关内容

  • 没有找到相关文章

最新更新