Example #1
0
        public void TestResetMatches()
        {
            sync.SyncOption = SyncOption.MergeOutlookWins;

            string groupName = "A_TEST_GROUP";
            string timestamp = DateTime.Now.Ticks.ToString();
            string name      = "AN OUTLOOK TEST CONTACT";
            string email     = "*****@*****.**";

            name = name.Replace(" ", "_");

            // delete previously failed test contacts
            DeleteExistingTestContacts(name, email);

            sync.Load();
            ContactsMatcher.SyncContacts(sync);

            // create new contact to sync
            Outlook.ContactItem outlookContact = sync.OutlookApplication.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
            outlookContact.FullName               = name;
            outlookContact.FileAs                 = name;
            outlookContact.Email1Address          = email;
            outlookContact.Email2Address          = email.Replace("00", "01");
            outlookContact.Email3Address          = email.Replace("00", "02");
            outlookContact.HomeAddress            = "10 Parades";
            outlookContact.PrimaryTelephoneNumber = "123";
            outlookContact.Save();

            ContactEntry googleContact = new ContactEntry();

            ContactSync.UpdateContact(outlookContact, googleContact);
            ContactMatch match = new ContactMatch(outlookContact, googleContact);

            //save contact to google.
            sync.SaveContact(match);

            //load the same contact from google.
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // delete outlook contact
            match.OutlookContact.Delete();
            match.OutlookContact = null;

            //load the same contact from google.
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // reset matches
            sync.ResetMatch(match);

            // load same contact match
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // google contact should still be present
            Assert.IsNotNull(match.GoogleContact);

            //delete test contacts
            match.Delete();

            // create new contact to sync
            outlookContact                        = sync.OutlookApplication.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
            outlookContact.FullName               = name;
            outlookContact.FileAs                 = name;
            outlookContact.Email1Address          = email;
            outlookContact.Email2Address          = email.Replace("00", "01");
            outlookContact.Email3Address          = email.Replace("00", "02");
            outlookContact.HomeAddress            = "10 Parades";
            outlookContact.PrimaryTelephoneNumber = "123";
            outlookContact.Save();

            // same test for delete google contact...
            googleContact = new ContactEntry();
            ContactSync.UpdateContact(outlookContact, googleContact);
            match = new ContactMatch(outlookContact, googleContact);

            //save contact to google.
            sync.SaveContact(match);

            //load the same contact from google.
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // delete google contact
            match.GoogleContact.Delete();
            match.GoogleContact = null;

            //load the same contact from google.
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // reset matches
            sync.ResetMatch(match);

            // load same contact match
            sync.Load();
            ContactsMatcher.SyncContacts(sync);
            match = sync.ContactByProperty(name, email);

            // google contact should still be present
            Assert.IsNotNull(match.OutlookContact);

            //delete test contacts
            match.Delete();
        }