public static IControllerBuilder <T> WithTestRig <T>(this IControllerBuilder <T> obj, TestRig rig) where T : ApiController { return(obj .WithResolvedDependencies(rig.PlayersService) .WithSetup(c => { var oc = new OwinContext(); var auth = new GunchoResourceAuthorization(rig.PlayersService, rig.RealmsService); oc.Set(ResourceAuthorizationManagerMiddleware.Key, auth); c.Request.SetOwinContext(oc); })); }