public void AddMessageByNotAdmin_returnException()
        {
            StubUser admin = new StubUser(Guid.NewGuid());

            StubUser[] admins = new StubUser[] { admin };
            StubUser   user   = new StubUser(Guid.NewGuid());

            StubUser[] users = new StubUser[] { user };
            GroupChat  chat  = new GroupChat(
                Guid.NewGuid(),
                new List <Message>(),
                new List <IUser>(users),
                new List <IUser>(admins));
            Message message = new Message(Guid.NewGuid(), user, "hello");

            try
            {
                chat.AddMessage(message);
                Assert.Fail();
            }
            catch (Exception e)
            {
                string exceptMessage = "Try to send a message by not a Admin";
                Assert.IsTrue(e.Message == exceptMessage);
            }
        }
Ejemplo n.º 2
0
        public void CallContainsWhenRepaContainsUser_returnTrue()
        {
            StubUser       user         = new StubUser(Guid.NewGuid());
            UserRepository repa         = new UserRepository(new List <IUser>(new IUser[] { user }));
            bool           expectedAnsw = true;

            bool answ = repa.Contains(user.Id);

            Assert.IsTrue(answ == expectedAnsw);
        }
Ejemplo n.º 3
0
        public void AddUserInRepa_UserWillBeAdded()
        {
            StubUser       user = new StubUser(Guid.NewGuid());
            UserRepository repa = new UserRepository(new List <IUser>());

            repa.AddUser(user);

            foreach (IUser UserInRepa in repa.Users)
            {
                Assert.IsTrue(user.Id == UserInRepa.Id);
            }
        }
        public void DeleteMessage_MessageWillBeRemoved()
        {
            StubUser user = new StubUser(Guid.NewGuid());

            StubUser[]  users   = new StubUser[] { user };
            Message     message = new Message(Guid.NewGuid(), user, "hello");
            PrivateChat chat    = new PrivateChat(
                Guid.NewGuid(),
                new List <Message>(new Message[] { message }),
                new List <IUser>(users));

            chat.DeleteMessage(message.Id, user);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsFalse(mes.Equals(message));
            }
        }
        public void AddMessage_MessageWillBeAppend()
        {
            StubUser user = new StubUser(Guid.NewGuid());

            StubUser[]  users = new StubUser[] { user };
            PrivateChat chat  = new PrivateChat(
                Guid.NewGuid(),
                new List <Message>(),
                new List <IUser>(users));
            Message message = new Message(Guid.NewGuid(), user, "hello");

            chat.AddMessage(message);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsTrue(mes.Equals(message));
            }
        }
        public void EditMessage_MessageChangeText()
        {
            StubUser user = new StubUser(Guid.NewGuid());

            StubUser[]  users   = new StubUser[] { user };
            Message     message = new Message(Guid.NewGuid(), user, "hello");
            PrivateChat chat    = new PrivateChat(
                Guid.NewGuid(),
                new List <Message>(new Message[] { message }),
                new List <IUser>(users));
            string newText = "NewHello";

            chat.EditMessage(message.Id, user, newText);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsTrue(mes.Text == newText);
            }
        }
        public void DeleteMessageByAdmin_MessageRemove()
        {
            StubUser admin   = new StubUser(Guid.NewGuid());
            Message  message = new Message(Guid.NewGuid(), admin, "hello");
            StubUser user    = new StubUser(Guid.NewGuid());

            StubUser[] users = new StubUser[] { user };
            ChanelChat chat  = new ChanelChat(
                Guid.NewGuid(),
                new List <Message>(new Message[] { message }),
                new List <IUser>(users),
                admin);

            chat.DeleteMessage(message.Id, admin);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsFalse(mes.Equals(message));
            }
        }
        public void AddMessageByAdmin_MessageWillAppend()
        {
            StubUser admin = new StubUser(Guid.NewGuid());
            StubUser user  = new StubUser(Guid.NewGuid());

            StubUser[] users = new StubUser[] { user };
            ChanelChat chat  = new ChanelChat(
                Guid.NewGuid(),
                new List <Message>(),
                new List <IUser>(users),
                admin);
            Message message = new Message(Guid.NewGuid(), admin, "hello");

            chat.AddMessage(message);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsTrue(mes.Equals(message));
            }
        }
        public void EditMessageByAdmin_MessageChangeText()
        {
            StubUser admin   = new StubUser(Guid.NewGuid());
            Message  message = new Message(Guid.NewGuid(), admin, "hello");
            StubUser user    = new StubUser(Guid.NewGuid());

            StubUser[] users = new StubUser[] { user };
            ChanelChat chat  = new ChanelChat(
                Guid.NewGuid(),
                new List <Message>(new Message[] { message }),
                new List <IUser>(users),
                admin);
            string newText = "NewHello";

            chat.EditMessage(message.Id, admin, newText);

            foreach (Message mes in chat.Messages)
            {
                Assert.IsTrue(mes.Text == newText);
            }
        }