Inheritance: IClientUserManager
        public void DepartNonJoined()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();

            Assert.IsFalse (manager.GetIsJoined (user));
            Assert.IsFalse (manager.Depart (user));
        }
        public void Depart()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();
            manager.Join (user);

            Assert.IsTrue (manager.GetIsJoined (user));
            Assert.IsTrue (((IEnumerable<IUserInfo>)manager).Contains (user));
            Assert.AreEqual (user, manager[user.UserId]);

            Assert.IsTrue (manager.Depart (user));

            Assert.IsFalse (manager.GetIsJoined (user));
            Assert.IsFalse (((IEnumerable<IUserInfo>)manager).Contains (user));
            Assert.AreEqual (null, manager[user.UserId]);
        }
        public void ExtensionGetIsJoinedId()
        {
            var user = new UserInfo ("Nickname", "Username", 1, 2, true);
            var user2 = new UserInfo ("Nickname2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();
            manager.Join (user);

            Assert.IsTrue (manager.GetIsJoined (user));
            Assert.IsFalse (manager.GetIsJoined (user2));

            manager.Join (user2);
            Assert.IsTrue (manager.GetIsJoined (user2));

            manager.Depart (user);
            Assert.IsFalse (manager.GetIsJoined (user));
        }
 public void DepartNullUser()
 {
     var manager = new ClientUserManager();
     Assert.Throws<ArgumentNullException> (() => manager.Depart (null));
 }
 public void UpdateNullUsers()
 {
     var manager = new ClientUserManager();
     Assert.Throws<ArgumentNullException> (() => manager.Update ((IEnumerable<IUserInfo>)null));
 }
        public void UpdateUser()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo ("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();
            manager.Join (user);

            user = new UserInfo ("NicknameU", "PhoneticU", "Username2", 1, 2, false);
            user2 = new UserInfo ("Nickname2U", "Phonetic2U", "Username2", 2, 3, false);

            manager.Update (user);

            Assert.IsTrue (manager.GetIsJoined (user));
            Assert.AreEqual (user, manager[user.UserId]);
            Assert.AreEqual (user.Nickname, manager[user.UserId].Nickname);
            Assert.AreEqual (user.Phonetic, manager[user.UserId].Phonetic);
            Assert.AreEqual (user.Username, manager[user.UserId].Username);
            Assert.AreEqual (user.UserId, manager[user.UserId].UserId);
            Assert.AreEqual (user.CurrentChannelId, manager[user.UserId].CurrentChannelId);
            Assert.AreEqual (user.IsMuted, manager[user.UserId].IsMuted);

            manager.Update (user2);

            Assert.IsTrue (manager.GetIsJoined (user2));
            Assert.AreEqual (user2, manager[user2.UserId]);
            Assert.AreEqual (user2.Nickname, manager[user2.UserId].Nickname);
            Assert.AreEqual (user2.Phonetic, manager[user2.UserId].Phonetic);
            Assert.AreEqual (user2.Username, manager[user2.UserId].Username);
            Assert.AreEqual (user2.UserId, manager[user2.UserId].UserId);
            Assert.AreEqual (user2.CurrentChannelId, manager[user2.UserId].CurrentChannelId);
            Assert.AreEqual (user2.IsMuted, manager[user2.UserId].IsMuted);
        }
        public void ToggleMuteNullUser()
        {
            var manager = new ClientUserManager();

            Assert.Throws<ArgumentNullException> (() => manager.ToggleMute (null));
        }
        public void UpdateEmpty()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo ("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();

            manager.Update (new [] { user, user2 });

            Assert.IsTrue (manager.GetIsJoined (user));
            Assert.IsTrue (manager.GetIsJoined (user2));
        }
        public void IndexerPresent()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);

            var manager = new ClientUserManager();
            manager.Join (user);

            Assert.AreEqual (user, manager[user.UserId]);
        }
        public void IndexerNotPresent()
        {
            var user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);
            var user2 = new UserInfo ("Nickname2", "Phonetic2", "Username2", 2, 3, false);

            var manager = new ClientUserManager();
            manager.Join (user);

            Assert.AreEqual (null, manager[user2.UserId]);
        }
 public void GetIsJoinedNullUser()
 {
     var manager = new ClientUserManager ();
     Assert.Throws<ArgumentNullException> (() => manager.GetIsJoined ((IUserInfo)null));
 }
 public void ManagerTearDown()
 {
     this.userProvider = null;
     this.server = null;
     this.handler = null;
     this.userManager = null;
     this.provider = null;
     this.context = null;
 }
        public void ManagerSetup()
        {
            this.provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            this.provider.Start (MessageTypes.All);

            var connections = this.provider.GetConnections (GablarskiProtocol.Instance);

            this.server = new ConnectionBuffer (connections.Item2);
            this.client = connections.Item1;

            userProvider = new MockUserProvider();
            context = new MockClientContext (client) { ServerInfo = new ServerInfo (new ServerSettings(), userProvider) };

            var channels = new ClientChannelManager (context);
            ClientChannelManagerTests.PopulateChannels (channels, this.server);

            this.userManager = new ClientUserManager();
            this.handler = new ClientUserHandler (context, userManager);
            context.Users = this.handler;
            context.Channels = channels;
        }