Dr *_*izo 3 c# unit-testing nservicebus nservicebus5
我想知道在尝试单元测试NServiceBus时是否有人知道这个问题.
意识到我下面有两个初始化方法,但这是为了说明我想要做什么.根据请求堆栈跟踪.
(NServiceBus.LocalAddress)字典中不存在.(NServiceBus.LocalAddress)字典中不存在.
我相信堆栈跟踪的其他部分是一个抱怨InMemoryPersistence的红鲱鱼.然而,有一个谷歌小组也在谈论这个问题,他们遇到了同样的问题,这让我觉得它更像是一个NServiceBus问题,而不是编码错误.
Google群组链接https://groups.google.com/forum/m/#!topic/particularsoftware/424_6KCv6oI
应该提一下这些帖子.
https://github.com/Particular/NServiceBus.Testing/issues/20 https://github.com/Particular/NServiceBus.Testing/commit/f761c5391b03b05d967f2e368248c72522051d59
public static class CustomInit
{
public static void Init()
{
//Previous versions of NBUS, specifically 4.6.5
//MessageConventionExtensions.IsEventTypeAction = MessageConfiguration.ForEvents();
//MessageConventionExtensions.IsCommandTypeAction = MessageConfiguration.ForCommands();
//New 5.2.0 how to setup tests
Test.Initialize(x => x.AssembliesToScan(GetAssembliesToScan()));
Test.Initialize(
x =>
{
x.Conventions().DefiningCommandsAs([my namespace]);
x.Conventions().DefiningEventsAs([my namespace]);
x.AssembliesToScan(GetAssembliesToScan());
});
}
private static IEnumerable<Assembly> GetAssembliesToScan()
{
return new[]
{
AssemblyFromType<ISomeInterface>()
};
}
}
Run Code Online (Sandbox Code Playgroud)
在GitHub上提出问题后发现需要包含NServiceBus.Testing作为程序集扫描的一部分.例如:
还应该指出,有关更多信息,我将访问GitHub链接.关于这个问题和解释的更多细节可以在那里找到.
public static void Init()
{
Test.Initialize(
x =>
{
x.Conventions().DefiningCommandsAs(x => x.Namespace.Contains("Commands"));
x.Conventions().DefiningEventsAs(x => x.Namespace.Contains("Events"));
x.AssembliesToScan(GetAssembliesToScan());
});
}
private static IEnumerable<Assembly> GetAssembliesToScan()
{
return new[]
{
AssemblyFromType<ISomeInterface>(),
Assembly.LoadFrom("NServiceBus.Testing.dll")
};
}
Run Code Online (Sandbox Code Playgroud)
关键在于此 Assembly.LoadFrom("NServiceBus.Testing.dll")
干杯,DS.
归档时间: |
|
查看次数: |
1122 次 |
最近记录: |