コード例 #1
0
        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);
            }
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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));
            }
        }
コード例 #8
0
        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));
            }
        }
コード例 #9
0
        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);
            }
        }