Ejemplo n.º 1
0
        public void CountMessagesNotReaded()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            MessageRepository messageRepository = new MessageRepository(con);
            ContactRepository contactRepository = new ContactRepository(con);
            Contact           contact           = new Contact
            {
                Id        = 1,
                FirstName = "Pablo",
                LastName  = "Corral",
                Phone     = "34676681420"
            };
            Contact c = new Contact
            {
                Id        = 2,
                FirstName = "Cristina",
                LastName  = "Gambin",
                Phone     = "34666666666"
            };
            Chat m = new Chat
            {
                Mensaje = "hola",
                FromTo  = "34676681420",
                Send    = false,
                Created = DateTime.Now,
                Seen    = false
            };
            Chat m1 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34676681420",
                Send    = false,
                Created = DateTime.Now.AddSeconds(10),
                Seen    = false
            };
            Chat m2 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34666666666",
                Send    = false,
                Created = DateTime.Now.AddSeconds(-60),
                Seen    = false
            };
            Chat m3 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34666666666",
                Send    = false,
                Created = DateTime.Now.AddSeconds(-120),
                Seen    = false
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(c);
                messageRepository.InsertMessage(m);
                messageRepository.InsertMessage(m1);
                messageRepository.InsertMessage(m2);
                messageRepository.InsertMessage(m2);
                var result = messageRepository.CountMessagesNotReaded();
                Assert.AreEqual(2, result[0].Counter);
            }
        }