MarkMessageUnreadBy() public method

Označí zprávu jako nepřečtenou daným uživatelem
public MarkMessageUnreadBy ( Message msg, User reader ) : void
msg Message zpráva, která má být označena jako nepřečtená
reader User uživatel, který označil zprávu jako nepřečtenou
return void
Example #1
0
        public void MarkMessageUnreadByTest()
        {
            FelBookDBEntities DbEntities = new FelBookDBEntities();
            MessageService target = new MessageService(DbEntities);

            User mockSender = User.CreateUser(0, "test", "test",
                DateTime.Now, "mail", "sender", "");
            DbEntities.UserSet.AddObject(mockSender);
            User mockReciever = User.CreateUser(0, "test", "test",
                DateTime.Now, "mail", "reciever", "");
            DbEntities.UserSet.AddObject(mockReciever);
            DbEntities.SaveChanges();

            Message msg1 = Message.CreateMessage(0, "Text", DateTime.Now);
            msg1.Sender = mockSender;
            msg1.Recievers.Add(mockReciever);
            msg1.Readers.Add(mockReciever);
            DbEntities.MessageSet.AddObject(msg1);
            DbEntities.SaveChanges();

            Assert.IsTrue(mockReciever.ReadMessages.Contains(msg1));
            Assert.IsTrue(msg1.Readers.Contains(mockReciever));

            target.MarkMessageUnreadBy(msg1, mockReciever);

            Assert.IsFalse(mockReciever.ReadMessages.Contains(msg1));
            Assert.IsFalse(msg1.Readers.Contains(mockReciever));

            target.MarkMessageUnreadBy(msg1, mockReciever);

            Assert.IsFalse(mockReciever.ReadMessages.Contains(msg1));
            Assert.IsFalse(msg1.Readers.Contains(mockReciever));

            DbEntities.MessageSet.DeleteObject(msg1);
            DbEntities.UserSet.DeleteObject(mockReciever);
            DbEntities.UserSet.DeleteObject(mockSender);
            DbEntities.SaveChanges();
        }