I'm new to TDD and I'm trying to apply Single Responsibility Principle to an API.
I'm using an API that returns multiple feed subscriptions in a single event. Each subscription can be differentiated from another because the Event Handler contains an id field. what I want to do is make a wrapper to the API which can manage the subscription updates such that a Subscription class only receives event updates relevant to it as determined by the id field of the event fired by the API.
Now I have wrapper to the API where I implemented the Subscribe() method such that it returns a Subscription class where it contains a Subscription.Updated() event. I keep a record of the Subscription s in a Dictionary so I can notify each Subscription based on their id.
My problem is how do I pass the Subscription Updated event parameters from the API to a particular Subscription and raise the Subscription.Updated() event? I've read that I can make a public OnUpdate method (which i've done in previous projects) but they say that this breaks encapsulation and SRP.
Or am I approaching this incorrectly? Is there a more elegant way to do it?
Additional info:
Request a feed from the API:
void Feed.Subscribe(id, SubscriptionParamaters)
Where id will be used to identify which response belongs to which subscription.
You can get subscription updates by
Feed.Update(id,UpdateValueArgs)