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);
            }
        }
        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);
            }
        }
Beispiel #3
0
        protected override void OnResume()
        {
            base.OnResume();

            FakeSessionDelete = new FakeSessionDelete();
            database          = new SQLiteRepository();
            userRepo          = new UserRepository(database);
            contactRepo       = new ContactRepository(database);
            configRepo        = new ConfigRepository(database);
            database.CreateDatabase();

            loginService   = new LoginService();
            contactService = new ContactService();
            errorText      = new ErrorText();

            if (_continue)
            {
                speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext);
                speechReco.SetRecognitionListener(this);
                intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es");
                intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName);
                intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch);
                intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                toSpeech = new TextToSpeech(this, this);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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]);
            }
        }
        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]);
            }
        }
        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");
            }
        }