Skip to content

ISubscriber no longer mockable #969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
BrennanConroy opened this issue Oct 8, 2018 · 9 comments
Open

ISubscriber no longer mockable #969

BrennanConroy opened this issue Oct 8, 2018 · 9 comments

Comments

@BrennanConroy
Copy link

With the introduction of ChannelMessageQueue Subscribe(...) and the async version, ISubscriber is no longer mockable (because of sealed class ChannelMessageQueue) so it's difficult/impossible to unit test code that uses Redis.

@mgravell
Copy link
Collaborator

mgravell commented Oct 8, 2018 via email

@analogrelay
Copy link

A really awesome way to expose this for testing would be if we could wrap a ChannelReader<RedisMessage> up into a ChannelMessageQueue

@analogrelay
Copy link

Any update here? We'd like to be able to restore our testing here :). We're happy to help contribute something if it makes sense. My initial design thought is to make it possible by having ChannelMessageQueue be constructable from a ChannelReader<ChannelMessage>

@NickCraver
Copy link
Collaborator

@anurse I'm not 100% sure I follow there - if you were able to PR what you mean, could be an instant win (as long as it's not breaking of course) - have time to by chance?

analogrelay added a commit to analogrelay/StackExchange.Redis that referenced this issue Nov 12, 2018
@analogrelay
Copy link

Opened PR #1000 (lucky me! do I get a prize?) with a sketch of my idea.

I realized it was a little more severe than just a "fix for testability" once I realized that ISubscriber is not implementable anymore because ChannelMessageQueue can only be constructed via an internal constructor. Since ISubscriber is public, this seems pretty bad.

@hansarnevartdal
Copy link

Would at least be beneficial to enable unit testing on the channel message handler called by the channel message queue, but this uses the ChannelMessage struct with internal ctor, so not really doable as is.

@viktors-telle
Copy link

Are there any plans to resolve this issue?

@kmcclellan
Copy link

Agreed. Is the problem with extracting an IChannelMessageQueue simply because it is breaking? I'd love to see that in v3.

@kmcclellan
Copy link

FWIW this isn't just about testing. I had wanted to implement an ISubscriber that wraps an inner subscriber using Polly retries, and was stymied by this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants