开发者

Can't test NServicebus Message Handlers with Messages which implement generics

I'm using:

I'm using the nservicebus.Testing namespace which nservicebus provides for testing IMessage handlers.

My tests throw this error when invoking the IMessage handler:

System.InvalidOperationException : Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.

This error goes away and the tests run fine if I remove a reference in the test project to an assembly which contains IMessages which implement generics.

NOTE that the Handler I'm testing is not handling the generics messages, the mere presence of the generics message in the bin folder is causing the error.

I would like however to be able to test handlers for IMessages which implement generics, is this possible?

cheers


The issue is that the NServiceBus testing library makes use of the same assembly type scanning logic as NServiceBus in general. In order to prevent scanning the problematic assembly, call Test.Initialize(params Assembly[] assemblies);

All that being said, it isn't recommended to have messages that make use of generics.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜