Skip to content

[Messaging] Advanced sample for mocking processor types #35696

Open
@jsquire

Description

@jsquire

Summary

Unlike other client types in the Event Hubs and Service Bus client libraries, the processor types are not deeply integrated into the application code. Rather than the application invoking operations on the client and using the results, the processors work in a push-based model where application code is registered as a .NET event handler and the processor invokes it when data is available.

In mainstream scenarios for the processor, testing/mocking should be focused on the application-provided code in the event handlers and confirming that the processor is started/stopped as intended. This is where our samples are focused - trying to guide developers towards testing their application code directly rather than indirectly by asserting control over the processor infrastructure.

There are some minority scenarios for testing - such as an application validating that the correct handler has been assigned - that doesn't lend itself well to the mocking/testing guidance for the mainstream scenarios. Generally, these require use of a custom test shim that extends the processor type rather than a stub mock created by Moq or another testing library. While we certainly want to ensure that this style of tests are possible, they requires a non-trivial amount of complexity that isn't needed for the majority case.

It would be helpful to have some kind of documentation or sample that discusses creating a mock-by-extension but including it in our mainstream sample does not seem to be the right place for it. A different approach is needed, whether that be an "advanced mocking" sample or a stand-alone sample application.

Scope of Work

  • Collaborate to determine the form that this documentation/sample should take, considering both Event Hubs and for Service Bus processor types.

  • Implement the sample for the Event Hubs and Service Bus processor types.

Success Criteria

  • The sample(s) have been created, with a clear approach for using a mock-by-extension to simulate processor operation.

  • The sample(s) follow the patterns local to the Event Hubs or Service Bus library, even if they differ between them.

References and Resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Event HubsService Busauto-close-exemptPrevents the auto-close from closing based on max lifetimehelp wantedThis issue is tracking work for which community contributions would be welcomed and appreciated

    Type

    No type

    Projects

    Status

    Done

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions