示例#1
0
        public TestableDebugHub(Mock<IContext> mockDbContext)
            : base(mockDbContext.Object)
        {
            const string connectionId = "1234";
            const string hubName = "debug";

            var mockConn = new Mock<IConnection>();
            var mockUser = new Mock<IPrincipal>();
            var mockCookies = new Mock<IRequestCookieCollection>();

            var mockRequest = new Mock<IRequest>();
            mockRequest.Setup(r => r.User).Returns(mockUser.Object);
            mockRequest.Setup(r => r.Cookies).Returns(mockCookies.Object);

            Clients = new ClientProxy(mockConn.Object, hubName);
            Groups = new GroupManager(mockConn.Object, hubName);
            Context = new HubCallerContext(mockRequest.Object, connectionId);

            var trackingDict = new TrackingDictionary();
            Caller = new StatefulSignalProxy(mockConn.Object, connectionId, hubName, trackingDict);
        }
 public string GetId(dynamic caller, HubCallerContext context)
 {
     var userId = caller.userId;
     return context.User.Identity.Name;
 }