Make it easier (or possible) to mock Clients.Group, Clients.OthersInGroup, etc #1899

Closed
upta opened this Issue Apr 17, 2013 · 1 comment

Comments

Projects
None yet
3 participants

upta commented Apr 17, 2013

I've been able to mock client method calls that use Clients.All because it's a dynamic property by assigning it an ExpandoObject something like such:

var hub = new InstanceOfMyTestableHub();

dynamic all = new ExpandoObject();
all.gameCreated = new Action<object>( ( o) =>
{
// do something here to tell it was called
} );
hub.Clients.All = all;

However, trying to mock Clients.Group(...) in a similar way doesn't seem to be doable, as it is a method returning a dynamic vs a dynamic property.

Since Clients is a concrete HubConnectionContext, it would be theoretically possible to mock Groups, etc if they were virtual, but I really don't know if that's the right solution at all.

Thanks!

@ghost ghost assigned davidfowl May 6, 2013

davidfowl added a commit that referenced this issue Jun 27, 2013

Made Hubs more testable.
- Introduced new interface IHubCallerConnectionContext
- Changed IHub's Client property to that instead of the concrete class
- Added tests demonstrating how to use the new extensibility to mock method calls

#1899

davidfowl added a commit that referenced this issue Jun 27, 2013

Made Hubs more testable.
- Introduced new interface IHubCallerConnectionContext
- Changed IHub's Client property to that instead of the concrete class
- Added tests demonstrating how to use the new extensibility to mock method calls

#1899

@ghost ghost assigned Xiaohongt Jun 27, 2013

Contributor

Xiaohongt commented Jul 3, 2013

verified no regression

@Xiaohongt Xiaohongt closed this Jul 3, 2013

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