Exemple #1
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);
        }
Exemple #2
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());
        }
Exemple #3
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);
        }
Exemple #4
0
        public void Add_addUsersInThread_addTwoUsers()
        {
            var    roleManager = new HubGroupManager <string>();
            Thread t1          = new Thread(() => AddInThread(roleManager, 0, 1000));
            Thread t2          = new Thread(() => AddInThread(roleManager, 1000, 1500));

            t1.Start();
            t2.Start();
            t2.Join();
            t1.Join();

            var users = roleManager.GetUsersFromGroup("User");

            Assert.AreEqual(1500, users.Count());
        }
Exemple #5
0
        public void AddandRemove_addUsersInThread_addTwoUsers()
        {
            var    roleManager = new HubGroupManager <string>();
            Thread t1          = new Thread(() => AddInThread(roleManager, 0, 1000));
            Thread t2          = new Thread(() => RemoveInThread(roleManager, 0, 500));

            t1.Start();
            t2.Start();
            t1.Join();
            t2.Join();

            var users = roleManager.GetUsersFromGroup("User");

            Assert.That(users.Count(), Is.LessThan(1000));
        }
Exemple #6
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);
        }