Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        private static void DeleteContact(ContactRepository repository)
        {
            Console.Write("Enter the id which you want to delete ==> ");
            int     id      = int.Parse(Console.ReadLine());
            Contact contact = repository.GetContactByID(id);

            if (contact == null)
            {
                Console.WriteLine("Invalid ID!");
                return;
            }
            repository.DeleteContact(id);
            Console.WriteLine("Contact deleted sucessfully...");
        }
Ejemplo n.º 3
0
        private async void DeleteClick(object sender, EventArgs e)
        {
            if (lv_contacts.SelectedItems.Count > 0)
            {
                Contact      contact      = (Contact)lv_contacts.SelectedItems[0].Tag;
                DialogResult dialogResult = MessageBox.Show("Are you sure?", "Confirmation", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    bool i = await Task.Run(() => contactRepository.DeleteContact(contact));

                    MessageBox.Show(i ? "Deleted" : "Error");
                }
            }
        }
        public void DeleteContact_Calls_IRepository_Delete_On_Valid_Contact()
        {
            //Arrange
            var portalId = PORTAL_ValidId;

            var repository = new ContactRepository();
            var contact = new Contact { PortalId = portalId };

            //Act
            repository.DeleteContact(contact);

            //Assert
            _mockRepository.Verify(r => r.Delete(contact));
        }
        public void DeleteContact_Throws_On_InValid_ContactId()
        {
            //Arrange
            var repository = new ContactRepository();
            var contact = new Contact { ContactId = CONTACT_InValidId };

            //Act

            //Assert
            Assert.Throws<ArgumentOutOfRangeException>(() => repository.DeleteContact(contact));
        }
        public void DeleteContact_Throws_On_Null_Contact()
        {
            //Arrange
            var repository = new ContactRepository();

            //Act

            //Assert
            Assert.Throws<ArgumentNullException>(() => repository.DeleteContact(null));
        }