Exemplo n.º 1
0
        public void Add_whenCalled_addTwoUsers()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "thirdConnection");
            roleManager.AddToGroup("User", "User1", "firstConnection");
            roleManager.AddToGroup("User", "User2", "secondConnection");

            Assert.AreEqual(2, roleManager.GetUsersFromGroup("User").Count());
        }
Exemplo n.º 2
0
        public void Add_WhenCalled_CountUsersWithThreeConnectionId()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "firstConnection");
            roleManager.AddToGroup("User", "User1", "secondConnection");
            roleManager.AddToGroup("User", "User1", "thirdConnection");

            Assert.AreEqual(1, roleManager?.GetUsersFromGroup("User").Count());
            Assert.AreEqual(3, roleManager.GetUsersFromGroup("User")
                            .FirstOrDefault().ConnectionIds.Count);
        }
Exemplo n.º 3
0
        public void GetUserGroupById_WhenCalled_ReturnEnumerableOfUsersGroup()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "firstConnection");
            roleManager.AddToGroup("Admin", "User1", "firstConnection");
            roleManager.AddToGroup("Coach", "User2", "secondConnection");
            roleManager.AddToGroup("User", "User2", "secondConnection");

            var groups = roleManager.GetUserGroupsById("User2").ToList();

            Assert.IsTrue(groups.Contains("Coach") && groups.Contains("User"));
        }
Exemplo n.º 4
0
        public void GetUserFromGroup_WhenCalled_ReturnEnumerableOfUsers()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "firstConnection");
            roleManager.AddToGroup("Admin", "User1", "firstConnection");
            roleManager.AddToGroup("Coach", "User2", "secondConnection");
            roleManager.AddToGroup("User", "User2", "secondConnection");

            var groups = roleManager.GetUsersFromGroup("User");
            var test   = roleManager.GetUsersFromGroup("NotExist");

            Assert.IsEmpty(test);
            Assert.IsTrue(groups.Count() == 2);
        }
Exemplo n.º 5
0
        public void Remove_RemoveAllUsersFromGroup_GroupIsDeleted_AssertFalse()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "thirdConnection");
            roleManager.AddToGroup("Admin", "User1", "firstConnection");
            roleManager.AddToGroup("Coach", "User2", "secondConnection");
            roleManager.AddToGroup("User", "User2", "secondConnection");

            roleManager.RemoveFromGroup("User1", "thirdConnection");
            roleManager.RemoveFromGroup("User2", "secondConnection");

            var result = roleManager.IsGroupExist("User");

            Assert.IsFalse(result);
        }
Exemplo n.º 6
0
 private void AddInThread(HubGroupManager <string> roleManager, int from, int to)
 {
     for (int i = from; i < to; i++)
     {
         roleManager.AddToGroup("User", $"User{i}", "Connection");
     }
 }
Exemplo n.º 7
0
        public void Remove_RemoveUserConnection_UserIsNotDeleteIfConnectionExsist()
        {
            var roleManager = new HubGroupManager <string>();

            roleManager.AddToGroup("User", "User1", "thirdConnection");
            roleManager.AddToGroup("User", "User1", "firstConnection");
            roleManager.AddToGroup("User", "User2", "secondConnection");

            roleManager.RemoveFromGroup("User1", "thirdConnection");

            var user = roleManager.GetUsersFromGroup("User")
                       .FirstOrDefault(x => x.UserId == "User1");

            bool result = user != null;

            Assert.IsTrue(result);
        }