Mocking IEndpointInstance with NSubstitute

Hi, Ivan,

The exception comes from an extension method that provides the send functionality https://github.com/Particular/NServiceBus/blob/develop/src/NServiceBus.Core/IMessageSessionExtensions.cs#L16

Based on that it looks like your service passes null to the endpoint instance. Maybe one of your substitutes returns null that is then passed into the endpoint instance send method?

Maybe it is a bit simpler to use our NServiceBus.Testing package? Have a look at some of the examples here Unit Testing NServiceBus • Testing Samples • Particular Docs. The library provides a TestableMessageSession that could fulfill your needs

Regards
daniel