3

更新はGoogleグループをより詳細に読むだけで、明らかにアプリの構成の問題です。試した後、投稿を更新します。

NServiceBus の単体テストを試みるときに、この問題を知っている人がいるかどうか疑問に思っていました。

以下に 2 つの初期化メソッドがあることを認識してください。ただし、これは私がやろうとしていることを説明するためのものです。リクエストに基づくスタック トレース。

(NServiceBus.LocalAddress) が辞書にありませんでした。(NServiceBus.LocalAddress) が辞書にありませんでした。

私が信じているスタック トレースの他の部分は、InMemoryPersistence について不平を言っている赤いニシンです。ただし、この問題について話している Google グループもあり、同じ問題を経験したため、コーディングの間違いではなく、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>()
            };
        }
}
4

2 に答える 2

6

After raising the issue on GitHub found that need to include NServiceBus.Testing as part of the assembly scanning. For example:

Should point out also, for further information I would visit the GitHub link. Further detail about the issue and an explanation can be found there.

    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")
        };
    }

The key point being this Assembly.LoadFrom("NServiceBus.Testing.dll")

Cheers, DS.

于 2015-03-02T10:17:54.157 に答える