public void TestContactIndexerFindsExistingContacts() { List<IContact> contacts = new List<IContact>(); contacts.Add(new Contact("John Doe")); contacts.Add(new Contact("Another contact")); contacts.Add(new Contact("", "*****@*****.**")); contacts.Add(new Contact("", "*****@*****.**")); contacts.Add(new Contact((string)null)); IContact c = new Contact("MultiMail"); c.addMail("*****@*****.**"); c.addMail("*****@*****.**"); contacts.Add(c); ContactIndexer indexer = new ContactIndexer(contacts); Assert.AreEqual(1, indexer.GetContactsFor("John Doe").Count()); Assert.AreEqual(0, indexer.GetContactsFor("Foo Bar").Count()); Assert.AreEqual(2, indexer.GetContactsFor("*****@*****.**").Count()); Assert.AreEqual(1, indexer.GetContactsFor("MultiMail").Count()); Assert.AreEqual(1, indexer.GetContactsFor("*****@*****.**").Count()); Assert.AreEqual(1, indexer.GetContactsFor("*****@*****.**").Count()); Assert.AreEqual(0, indexer.GetContactsFor(null).Count()); Assert.AreEqual(1, indexer.GetSameContactsAs(new Contact("MultiMail")).Count()); // Can match Name to email... Assert.AreEqual(2, indexer.GetSameContactsAs(new Contact("*****@*****.**")).Count()); }
public static void Merge(IContactManager m1, IContactManager m2, IEnumerable <IContact> l1, IEnumerable <IContact> l2) { var l2Index = new ContactIndexer(l2); foreach (IContact c in l1) { bool foundMerge = false; foreach (IContact oc in l2Index.GetSameContactsAs(c)) { if (!c.IsSameAs(oc)) { continue; } foundMerge = true; if (c.MergeFrom(oc)) { //System.Windows.Forms.MessageBox.Show("Updating Google information for " + c.ToString()); c.Update(); } if (oc.MergeFrom(c)) { //System.Windows.Forms.MessageBox.Show("Updating Outlook information for " + c.ToString()); oc.Update(); } } if (!foundMerge) { //System.Windows.Forms.MessageBox.Show("Copy information from Google to Outlook for " + c.ToString()); IContact newContact = m2.NewContact(c); newContact.Update(); } } var l1Index = new ContactIndexer(l1); foreach (IContact oc in l2) { bool foundMerge = false; foreach (IContact c in l1Index.GetSameContactsAs(oc)) { if (!c.IsSameAs(oc)) { continue; } foundMerge = true; } if (!foundMerge) { //System.Windows.Forms.MessageBox.Show("Copy information from Outlook to Google for " + oc.ToString()); IContact newContact = m1.NewContact(oc); newContact.Update(); } } }
public static void Merge(IContactManager m1, IContactManager m2, IEnumerable<IContact> l1, IEnumerable<IContact> l2) { var l2Index = new ContactIndexer(l2); foreach (IContact c in l1) { bool foundMerge = false; foreach (IContact oc in l2Index.GetSameContactsAs(c)) { if (!c.IsSameAs(oc)) continue; foundMerge = true; if (c.MergeFrom(oc)) { //System.Windows.Forms.MessageBox.Show("Updating Google information for " + c.ToString()); c.Update(); } if (oc.MergeFrom(c)) { //System.Windows.Forms.MessageBox.Show("Updating Outlook information for " + c.ToString()); oc.Update(); } } if (!foundMerge) { //System.Windows.Forms.MessageBox.Show("Copy information from Google to Outlook for " + c.ToString()); IContact newContact = m2.NewContact(c); newContact.Update(); } } var l1Index = new ContactIndexer(l1); foreach (IContact oc in l2) { bool foundMerge = false; foreach (IContact c in l1Index.GetSameContactsAs(oc)) { if (!c.IsSameAs(oc)) continue; foundMerge = true; } if (!foundMerge) { //System.Windows.Forms.MessageBox.Show("Copy information from Outlook to Google for " + oc.ToString()); IContact newContact = m1.NewContact(oc); newContact.Update(); } } }