Пример #1
0
        public void CheckExistFromContact()
        {
            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"
            };
            Chat m = new Chat
            {
                Mensaje = "hola",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now,
                Seen    = true
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                messageRepository.InsertMessage(m);
                var result = messageRepository.CheckExistFromContact("34666666666");
                Assert.IsFalse(result);
            }
        }
Пример #2
0
        public void GetContactC2()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            ContactRepository contactRepository = new ContactRepository(con);
            Contact           contact           = new Contact
            {
                Id        = 1,
                FirstName = "Pablo",
                LastName  = "Corral",
                Phone     = "34676681420"
            };
            Contact contact1 = new Contact
            {
                Id        = 2,
                FirstName = "Aa",
                LastName  = "Mama",
                Phone     = "34692511479"
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(contact1);
                var result = contactRepository.GetContacts().Count;
                Assert.AreNotEqual(1, result);
            }
        }
Пример #3
0
        public void GetMessageC1()
        {
            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"
            };
            Chat m = new Chat
            {
                Id      = 0,
                Mensaje = "hola",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                messageRepository.InsertMessage(m);
                var result = messageRepository.GetMessages().Count;
                Assert.AreEqual(1, result);
            }
        }
Пример #4
0
        public void DeleteContact()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            ContactRepository contactRepository = new ContactRepository(con);
            Contact           contact           = new Contact
            {
                Id        = 1,
                FirstName = "Pablo",
                LastName  = "Corral",
                Phone     = "34676681420",
                Status    = "Offline",
                Blocked   = false
            };
            Contact contact1 = new Contact
            {
                Id        = 1,
                FirstName = "Pableras",
                LastName  = "Corral",
                Phone     = "34666666666",
                Status    = "Offline",
                Blocked   = true
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(contact1);
                var result = contactRepository.DeleteContact(contact1);
                var list   = contactRepository.GetContacts();
                Assert.AreEqual(1, list.Count);
            }
        }
Пример #5
0
        public void GetMessageC3()
        {
            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    = true,
                Created = DateTime.Now
            };
            Chat m1 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34676681420",
                Send    = false,
                Created = DateTime.Now.AddSeconds(10)
            };
            Chat m2 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34666666666",
                Send    = false,
                Created = DateTime.Now.AddSeconds(10)
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(c);
                messageRepository.InsertMessage(m);
                messageRepository.InsertMessage(m1);
                messageRepository.InsertMessage(m2);
                var result = messageRepository.GetMessagesByPhone("34676681420").Count;
                Assert.AreEqual(2, result);
            }
        }
Пример #6
0
        public void GetMessagesByPhoneAndDate()
        {
            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"
            };
            Chat m = new Chat
            {
                Mensaje = "hola",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now.AddDays(-4),
                Seen    = true
            };
            Chat m1 = new Chat
            {
                Mensaje = "que tal estas",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now.AddDays(-3),
                Seen    = true
            };
            Chat m2 = new Chat
            {
                Mensaje = "donde vamos",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now,
                Seen    = true
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                messageRepository.InsertChat(m);
                messageRepository.InsertChat(m1);
                messageRepository.InsertChat(m2);
                var result = messageRepository.GetMessagesByPhoneAndDate("34676681420", DateTime.Now.AddDays(-1));
                Assert.AreEqual(1, result.Count);
            }
        }
Пример #7
0
        public void GetContactsByNameWithChat()
        {
            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    = true,
                Created = DateTime.Now,
                Seen    = true
            };
            Chat m1 = new Chat
            {
                Mensaje = "hola",
                FromTo  = "34666666666",
                Send    = true,
                Created = DateTime.Now,
                Seen    = true
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(c);
                messageRepository.InsertMessage(m);
                messageRepository.InsertMessage(m1);
                var result = contactRepository.GetContactsByNameWithChat("Pablo");
                Assert.AreEqual(1, result.Count);
            }
        }
Пример #8
0
        public void GetUser()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            UserRepository userRepo = new UserRepository(con);
            User           user     = new User
            {
                Phone = "34655095818"
            };

            using (var connection = con.GetConnection())
            {
                userRepo.InsertUser(user);
                var result = userRepo.GetUser();
                Assert.AreEqual("34655095818", result.Phone);
            }
        }
Пример #9
0
        public void GetConfig()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            ConfigRepository configRepository = new ConfigRepository(con);
            Config           c = new Config()
            {
                Phone     = "34676681420",
                Voz       = false,
                Velocidad = (float)0.5
            };

            using (var connection = con.GetConnection())
            {
                configRepository.InsertConfig(c);
                var result = configRepository.GetConfig();
                Assert.AreEqual(false, result.Voz);
            }
        }
Пример #10
0
        public void GetContactsStatus()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            ContactRepository contactRepository = new ContactRepository(con);
            Contact           contact           = new Contact
            {
                Id        = 1,
                FirstName = "Pablo",
                LastName  = "Corral",
                Phone     = "34676681420",
                Status    = "Offline"
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                var result = contactRepository.GetContactsStatus();
                Assert.AreEqual("Pablo Corral - Offline", result[0]);
            }
        }
Пример #11
0
        public void GetContactsName()
        {
            SQLiteRepository con = new SQLiteRepository();

            con.CreateDatabase();
            ContactRepository contactRepository = new ContactRepository(con);
            Contact           contact           = new Contact
            {
                Id        = 1,
                FirstName = "Pablo",
                LastName  = "Corral",
                Phone     = "34676681420"
            };
            Contact contact1 = new Contact
            {
                Id        = 2,
                FirstName = "Aa",
                LastName  = "Mama",
                Phone     = "34692511479"
            };
            Contact contact2 = new Contact
            {
                Id        = 3,
                FirstName = "Pablo",
                LastName  = "No existe",
                Phone     = "34666666666"
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(contact1);
                contactRepository.InsertContact(contact2);
                var result = contactRepository.GetContactsName();

                Assert.AreEqual("Aa Mama", result[0]);
            }
        }
Пример #12
0
        public void GetMessagesOrdered()
        {
            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"
            };
            Contact c1 = new Contact
            {
                Id        = 3,
                FirstName = "Zoe",
                LastName  = "",
                Phone     = "34677777777"
            };
            Chat m = new Chat
            {
                Mensaje = "hola",
                FromTo  = "34676681420",
                Send    = true,
                Created = DateTime.Now.AddDays(-4).AddHours(-5),
                Seen    = false
            };
            Chat m1 = new Chat
            {
                Mensaje = "hola, que tal?",
                FromTo  = "34676681420",
                Send    = false,
                Created = DateTime.Now.AddDays(-3).AddHours(-4),
                Seen    = false
            };
            Chat m2 = new Chat
            {
                Mensaje = "soy pablo",
                FromTo  = "34676681420",
                Send    = false,
                Created = DateTime.Now.AddDays(-3).AddHours(-2),
                Seen    = false
            };
            Chat m3 = new Chat
            {
                Mensaje = "hola, que tal pau?",
                FromTo  = "34666666666",
                Send    = false,
                Created = DateTime.Now.AddDays(-3),
                Seen    = false
            };
            Chat m4 = new Chat
            {
                Mensaje = "soy cristina",
                FromTo  = "34666666666",
                Send    = false,
                Created = DateTime.Now.AddDays(-2),
                Seen    = false
            };
            Chat m5 = new Chat
            {
                Mensaje = "soy zoe",
                FromTo  = "34677777777",
                Send    = false,
                Created = DateTime.Now.AddDays(-2),
                Seen    = false
            };
            Chat m6 = new Chat
            {
                Mensaje = "holii",
                FromTo  = "34677777777",
                Send    = false,
                Created = DateTime.Now.AddDays(-1),
                Seen    = false
            };

            using (var connection = con.GetConnection())
            {
                contactRepository.InsertContact(contact);
                contactRepository.InsertContact(c);
                contactRepository.InsertContact(c1);
                messageRepository.InsertChat(m);
                messageRepository.InsertChat(m1);
                messageRepository.InsertChat(m2);
                messageRepository.InsertChat(m3);
                messageRepository.InsertChat(m4);
                messageRepository.InsertChat(m5);
                messageRepository.InsertChat(m6);
                var result = messageRepository.GetMessagesOrdered();
                Assert.AreEqual(result[0].Mensaje, "holii");
            }
        }