作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 RavenTestDriver
进行 .net 核心单元测试。这是我在单元测试解决方案中对 RavenTestDriver
的配置:
public class TestHostBuilder : RavenTestDriver, IAsyncLifetime
{
public async Task InitializeAsync()
{
ConfigureServer(new TestServerOptions
{
CommandLineArgs = new System.Collections.Generic.List<string> { "--RunInMemory=true", },
FrameworkVersion = null,
});
var hostBuilder = easy.api.Program.CreateHostBuilder(new string[0])
.ConfigureWebHost(webHostBuilder =>
{
webHostBuilder.UseTestServer();
})
.ConfigureServices(services =>
{
services.AddScoped<ICurrentUserService, InitRequest>();
services.AddRavenDbAsyncSession(GetDocumentStore());
services.AddScoped<IAsyncDocumentSession>((c) =>
{
return GetDocumentStore().OpenAsyncSession(new SessionOptions()
{
Database="test-server"
});
});
});
var host = hostBuilder.Start();
}
}
但是当我调用我的存储库来获取对象时,我得到了这个错误:
Database 'test-server' does not exist.'
at Raven.Client.Exceptions.Database.DatabaseDoesNotExistException.Throw(String databaseName) in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Exceptions\Database\DatabaseDoesNotExistException.cs:line 35
at Raven.Client.Http.RequestExecutor.<ExecuteAsync>d__114`1.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 883
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Raven.Client.Http.RequestExecutor.<ExecuteAsync>d__114`1.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 900
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Http.RequestExecutor.<UpdateTopologyAsync>d__101.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 455
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Raven.Client.Http.RequestExecutor.<FirstTopologyUpdate>d__109.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 678
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Http.RequestExecutor.<WaitForTopologyUpdate>d__107.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 613
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Http.RequestExecutor.<UnlikelyExecuteAsync>d__106`1.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Http\RequestExecutor.cs:line 583
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Documents.Session.AsyncDocumentSession.<LoadAsync>d__51`1.MoveNext() in C:\Builds\RavenDB-Stable-5.3\53009\src\Raven.Client\Documents\Session\AsyncDocumentSession.Load.cs:line 30
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at infrastructure.Persistence.RavenDb.RavenRepository`1.<GetByIdAsync>d__6.MoveNext() in D:\gitProjects\Orbis\infrastructure\Persistence\RavenDb\RavenRepository.cs:line 83
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at infrastructure.ApplicationCache.CacheableRepository`1.<GetAsync>d__8.MoveNext() in D:\gitProjects\Orbis\infrastructure\ApplicationCache\CacheableRepository.cs:line 48
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at easy.api.Application.Setting.Queries.GetClientAppSettingQueryHandler.<Handle>d__4.MoveNext() in D:\gitProjects\**\***\Application\Setting\Queries\GetClientAppSettingQuery.cs:line 35
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at api.common.Behaviors.UnhandledExceptionBehaviour`2.<Handle>d__2.MoveNext() in D:\gitProjects\**\api.common\Behaviors\UnhandledExceptionBehaviour.cs:line 22
最佳答案
调用OpenAsyncSession
前需要创建数据库 https://ravendb.net/docs/article-page/5.3/csharp/client-api/operations/server-wide/create-database#example
关于c# - 乌鸦.Client.Exceptions.Database.DatabaseDoesNotExistException : 'Database ' *****' does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71746610/
如何配置 Django logging 以支持不同 loggers 的不同 DSN? 像这样: settings.py LOGGING = { .. 'handlers': {
我正在使用 RavenTestDriver 进行 .net 核心单元测试。这是我在单元测试解决方案中对 RavenTestDriver 的配置: public class TestHostBuilde
我是一名优秀的程序员,十分优秀!