Exemplo n.º 1
0
 public void JoinRoom()
 {
     if (Session["UserAccountName"] != null)
     {
         UserInfo userInfo = (UserInfo)HttpRuntime.Cache[Session["UserAccountName"].ToString()];
         _chatHub.JoinRoom(userInfo.DisplayName);
     }
 }
Exemplo n.º 2
0
        public void JoinRoom_ShouldNot_ErrorOnBlankNullRoomName()
        {
            var repo       = new Mock <IMessageRepository>();
            var mockGroups = new Mock <IGroupManager>();
            var target     = new ChatHub(repo.Object)
            {
                Groups = mockGroups.Object
            };

            try
            {
                target.JoinRoom(null);
                target.JoinRoom("");
            }
            catch
            {
                Assert.Fail("Null/empty string should be ignored");
            }
        }
Exemplo n.º 3
0
        public void JoinRoom_Should_CallAddToGroup()
        {
            const string roomname     = "let_me_in";
            const string connectionId = "LeaveRoomTestConnection";

            var repo        = new Mock <IMessageRepository>();
            var mockGroups  = new Mock <IGroupManager>();
            var mockContext = new Mock <HubCallerContext>();

            mockContext.SetupGet(c => c.ConnectionId).Returns(connectionId);

            var target = new ChatHub(repo.Object)
            {
                Groups = mockGroups.Object, Context = mockContext.Object
            };

            //Calling this should invoke the AddToGroupAsync method only once, and for the room name we send in
            target.JoinRoom(roomname);
            mockGroups.Verify(g => g.AddToGroupAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Once);
            mockGroups.Verify(g => g.AddToGroupAsync(It.Is <string>(i => i == connectionId), It.Is <string>(r => r == roomname), It.IsAny <CancellationToken>()), Times.Once);
        }