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()); }
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); }
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")); }
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); }
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); }
private void AddInThread(HubGroupManager <string> roleManager, int from, int to) { for (int i = from; i < to; i++) { roleManager.AddToGroup("User", $"User{i}", "Connection"); } }
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); }