Stubbing Out IConnection

We have been looking at evolving our unit testing by stubbing IConnection so we can inject event history and action subscriptions etc on it, and then verify the results. It would be a really nice end to end verification mechanism.

I have implemented by own IConnection subscription

public EventStoreAllCatchUpSubscription SubscribeToAllFrom(Position? lastCheckpoint, CatchUpSubscriptionSettings settings,

Action<EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared, Action liveProcessingStarted = null, Action<EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null,

UserCredentials userCredentials = null)


// CreateInstance enabled to access protected methods

var subscription = (EventStoreAllCatchUpSubscription)Activator.CreateInstance(


BindingFlags.NonPublic | BindingFlags.Instance,


new object[]



new TestLogging(),


new UserCredentials(“user”, “pass”),







return subscription;


When I spin up the code that uses this (in an MSTest test), it runs ok, but just completes straight away, and none of the stream r/w methods are accessed (they should throw notImplemented if currently called).

Any advice you can give, or info you need to clarify

I dont understand what you are trying to ask.

You have not included anything about your read/write methods or how
you are calling them etc?

If you are expecting the CatchUpAllSubscription to start doing things
(it doesnt do writes)
you need to call the Start method.

This really feels like you are testing event store code though not
your code and probably is a code smell.

Fair enough. Would make more sense to do this at the level of our repository. Thanks for the nudge

Cheerz, Dave