NServiceBus Test.Initialize() 给定键不存在
NServiceBus Test.Initialize() given key was not present
更新只是更详细地阅读了 Google 组,显然这是一个应用程序配置问题。尝试后会更新post。
我想知道在尝试对 NServiceBus 进行单元测试时是否有人知道这个问题。
意识到我在下面有两个初始化方法,但这是为了说明我正在尝试做什么。
基于请求的堆栈跟踪。
(NServiceBus.LocalAddress) was not present in the dictionary.
(NServiceBus.LocalAddress) was not present in the dictionary.
我认为堆栈跟踪的其他部分是在抱怨 InMemoryPersistence。但是,也有一个 Google 小组在讨论这个问题,他们遇到了同样的问题,这让我认为这更像是一个 NServiceBus 问题,而不是编码错误。
Google组linkhttps://groups.google.com/forum/m/#!topic/particularsoftware/424_6KCv6oI
应该提到看到这些 posts。
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>()
};
}
}
在 GitHub 上提出问题后发现需要将 NServiceBus.Testing 作为程序集扫描的一部分。例如:
也应该指出,更多信息我会访问GitHublink。可以在此处找到有关该问题的更多详细信息和解释。
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")
};
}
重点是这个Assembly.LoadFrom("NServiceBus.Testing.dll")
干杯,DS。
就我而言,测试失败并在 NCrunch 中显示此错误消息。
这可能是因为 NCrunch 运行 来自以下位置的测试:
C:\Users\[username]\AppData\Local\NCrunch\...
解决方案是:
NCrunch -> Configuration
Select 受影响的项目并将标志 'Copy referenced assemblies to workspace' 设置为 True.
更新只是更详细地阅读了 Google 组,显然这是一个应用程序配置问题。尝试后会更新post。
我想知道在尝试对 NServiceBus 进行单元测试时是否有人知道这个问题。
意识到我在下面有两个初始化方法,但这是为了说明我正在尝试做什么。 基于请求的堆栈跟踪。
(NServiceBus.LocalAddress) was not present in the dictionary. (NServiceBus.LocalAddress) was not present in the dictionary.
我认为堆栈跟踪的其他部分是在抱怨 InMemoryPersistence。但是,也有一个 Google 小组在讨论这个问题,他们遇到了同样的问题,这让我认为这更像是一个 NServiceBus 问题,而不是编码错误。
Google组linkhttps://groups.google.com/forum/m/#!topic/particularsoftware/424_6KCv6oI
应该提到看到这些 posts。
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>()
};
}
}
在 GitHub 上提出问题后发现需要将 NServiceBus.Testing 作为程序集扫描的一部分。例如:
也应该指出,更多信息我会访问GitHublink。可以在此处找到有关该问题的更多详细信息和解释。
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")
};
}
重点是这个Assembly.LoadFrom("NServiceBus.Testing.dll")
干杯,DS。
就我而言,测试失败并在 NCrunch 中显示此错误消息。
这可能是因为 NCrunch 运行 来自以下位置的测试:
C:\Users\[username]\AppData\Local\NCrunch\...
解决方案是:
NCrunch -> Configuration
Select 受影响的项目并将标志 'Copy referenced assemblies to workspace' 设置为 True.