mercredi 29 juillet 2015

Writing tests for private SignalR hub

I'm building an API project based on Brad Wilson's WebStackOfLove. It is very important that my project have unit testing. SignalR's documentation suggests writing tests that directly instantiate a hub and insert a mock Clients into it. This is not possible with this model (at least to my knowledge) since the hub is a private member of a parent class. I've tried to create a new class that inherits from my controller and override various fields and methods, and it looks like if I override my server side communication function, it works, but that kind of defeats the point of unit testing. I've tried to override hub and Hub from the base class, but that has not worked either. I have a feeling that's bad form also.

What can I do to properly unit test my controller?

Aucun commentaire:

Enregistrer un commentaire