public void testMergeWithGoogle() { try { GoogleContactDownloader gcd = new GoogleContactDownloader(GoogleContactDownloader.TestUser, GoogleContactDownloader.TestPass); IContact c1 = new GContactSync.Contact("John Doe", "*****@*****.**"); IContactManager m1 = new MockContactManager { GetContactsImpl = () => { var l = new List <IContact>(); l.Add(c1); return(l); } }; IEnumerable <IContact> googleContacts = gcd.GetContacts(); googleContacts = googleContacts.Where(c => c.FullName != null && c.FullName.Contains("Doe")); ContactMerger.Merge(gcd, m1, googleContacts, m1.GetContacts()); } catch (System.Exception ex) { throw ex; } }
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 void TestCanCopyContact() { string mail = "*****@*****.**"; IContact c1 = new Contact("J. Doe", mail); IContact c2 = new Contact(c1); Assert.IsTrue(c1.IsSameAs(c2)); IEnumerable<string> A = c1.Emails; IEnumerable<string> B = c2.Emails; Assert.IsTrue(A.Count() == B.Count() && A.Intersect(B).Count() == B.Count()); }
public void TestCreateAGoogleContact() { GContactSync.Contact c = new GContactSync.Contact("John Doe"); c.addMail("*****@*****.**"); GoogleContactDownloader gcd = new GoogleContactDownloader(GoogleContactDownloader.TestUser, GoogleContactDownloader.TestPass); int oldCount = gcd.GetContacts().Count(); IContact gc = gcd.NewContact(c); gc.Update(); Assert.AreEqual(gcd.GetContacts().Count(), oldCount + 1); }
public void TestCreateAGoogleContact() { GContactSync.Contact c = new GContactSync.Contact("John Doe"); c.addMail("*****@*****.**"); GoogleContactDownloader gcd = new GoogleContactDownloader(GoogleContactDownloader.TestUser, GoogleContactDownloader.TestPass); int oldCount = gcd.GetContacts().Count(); IContact gc = gcd.NewContact(c); gc.Update(); Assert.AreEqual(gcd.GetContacts().Count(), oldCount + 1); }
public void TestWithNullNameAndSameMailIsNoop() { Contact c1 = new Contact("", "*****@*****.**"); Contact c2 = new Contact(null, "*****@*****.**"); Assert.IsFalse(c1.MergeFrom(c2)); Assert.IsFalse(c2.MergeFrom(c1)); }
public void TestMergeTheOtherWay() { List<IContact> l1 = new List<IContact>(); List<IContact> l2 = new List<IContact>(); Contact c2 = new Contact("John Doe", "*****@*****.**"); l2.Add(c2); IContactManager m1 = new MockContactManager { GetContactsImpl = () => { return l1; } }; IContactManager m2 = new MockContactManager { GetContactsImpl = () => { return l2; } }; ContactMerger.Merge(m1, m2, m1.GetContacts(), m2.GetContacts()); Assert.AreEqual(l1.Count(), 1); IContact c1 = l1.ElementAt(0); Assert.AreEqual(c1.FullName, "John Doe"); Assert.IsTrue(c1.Emails.Contains("*****@*****.**")); }
public void TestMergerPerformance() { // Runtime should be pretty negligible, around 0.1s const int nb = 5000; List<IContact> l1 = new List<IContact>(); List<IContact> l2 = new List<IContact>(); for (int i = 0; i < nb; ++i) { string s1 = Guid.NewGuid().ToString(); string s2 = Guid.NewGuid().ToString(); string s3 = Guid.NewGuid().ToString(); IContact c1 = new Contact(s1); c1.addMail(s2); c1.addMail(s3); l1.Add(c1); IContact c2 = new Contact(s1); c2.addMail(s2); c2.addMail(s3); l2.Add(c2); } IContactManager m1 = new MockContactManager { GetContactsImpl = () => { return l1; } }; IContactManager m2 = new MockContactManager { GetContactsImpl = () => { return l2; } }; ContactMerger.Merge(m1, m2, m1.GetContacts(), m2.GetContacts()); }
public void TestMergingDoesNotDuplicateEmails() { IContact c1 = new Contact("J. Doe", "*****@*****.**"); IContact c2 = new Contact("John Doe", "*****@*****.**"); bool merged = c2.MergeFrom(c1); Assert.IsFalse(merged); Assert.AreEqual(c2.FullName, "John Doe"); Assert.AreEqual(c2.Emails.Count(), 1); Assert.IsTrue(c2.Emails.Contains("*****@*****.**")); }
public void testMergeWithGoogle() { try { GoogleContactDownloader gcd = new GoogleContactDownloader(GoogleContactDownloader.TestUser, GoogleContactDownloader.TestPass); IContact c1 = new GContactSync.Contact("John Doe", "*****@*****.**"); IContactManager m1 = new MockContactManager { GetContactsImpl = () => { var l = new List<IContact>(); l.Add(c1); return l; } }; IEnumerable<IContact> googleContacts = gcd.GetContacts(); googleContacts = googleContacts.Where(c => c.FullName != null && c.FullName.Contains("Doe")); ContactMerger.Merge(gcd, m1, googleContacts, m1.GetContacts()); } catch (System.Exception ex) { throw ex; } }
public void TestTwoContactsWithDifferentFullNamesAreNotEqual() { IContact c1 = new Contact("John Doe"); IContact c2 = new Contact("Nancy Botwin"); Assert.IsFalse(c1.IsSameAs(c2)); }
public void TestAnEmptyContactHasNoInformation() { IContact c1 = new Contact(""); Assert.IsFalse(c1.ContainsSomeInformation()); }
public void TestMergingCopiesFullNameIfDestNull() { string fn = "J. Doe"; IContact c1 = new Contact(fn); IContact c2 = new Contact(""); c2.MergeFrom(c1); Assert.AreEqual(c2.FullName, fn); }
public void TestAContactWithAMailHasSomeInformation() { IContact c1 = new Contact("", "*****@*****.**"); Assert.IsTrue(c1.ContainsSomeInformation()); }
public void TestAContactWithANameHasSomeInformation() { IContact c1 = new Contact("John Doe"); Assert.IsTrue(c1.ContainsSomeInformation()); }
public void TestTwoContactsWithSameFullNameAreEqual() { IContact c1 = new Contact("John Doe"); IContact c2 = new Contact("John Doe", "*****@*****.**"); Assert.IsTrue(c1.IsSameAs(c2)); }
public void TestTwoContactsWithSameEmailAreEqualEvenWithDifferentNames() { IContact c1 = new Contact("J. Doe", "*****@*****.**"); IContact c2 = new Contact("John Doe", "*****@*****.**"); Assert.IsTrue(c1.IsSameAs(c2)); }
public void TestTwoContactsWithSameEmailAreEqual() { string mail = "*****@*****.**"; IContact c1 = new Contact("", mail); IContact c2 = new Contact("", mail); Assert.IsTrue(c1.IsSameAs(c2)); }
public void TestMergingDoesNotCopyFullNameIfDestNotNull() { string fn = "J. Doe"; IContact c1 = new Contact(fn); IContact c2 = new Contact("John Doe"); c2.MergeFrom(c1); Assert.AreEqual(c2.FullName, "John Doe"); }
public void TestInsertingEmptyEmailAddressIsNoop() { IContact c1 = new Contact("John Doe"); Assert.IsFalse(c1.addMail("")); Assert.AreEqual(c1.Emails.Count(), 0); }
public void TestMergeBothWays() { Contact c1 = new Contact("John Doe", "*****@*****.**"); IContactManager m1 = new MockContactManager { GetContactsImpl = () => { var l = new List<IContact>(); l.Add(c1); return l; } }; Contact c2 = new Contact("John Doe", "*****@*****.**"); IContactManager m2 = new MockContactManager { GetContactsImpl = () => { var l = new List<IContact>(); l.Add(c2); return l; } }; Assert.IsTrue (c1.Emails.Contains("*****@*****.**")); Assert.IsFalse(c2.Emails.Contains("*****@*****.**")); Assert.IsFalse(c1.Emails.Contains("*****@*****.**")); Assert.IsTrue (c2.Emails.Contains("*****@*****.**")); ContactMerger.Merge(m1, m2, m1.GetContacts(), m2.GetContacts()); Assert.IsTrue(c1.Emails.Contains("*****@*****.**")); Assert.IsTrue(c2.Emails.Contains("*****@*****.**")); Assert.IsTrue(c1.Emails.Contains("*****@*****.**")); Assert.IsTrue(c2.Emails.Contains("*****@*****.**")); }
public IContact NewContact(IContact other) { IContact newC = new Contact(other); GetContactsImpl().Add(newC); return newC; }
public void TestMergingAddsEmailsFromOther() { IContact c1 = new Contact("J. Doe", "*****@*****.**"); IContact c2 = new Contact("John Doe", "*****@*****.**"); bool merged = c2.MergeFrom(c1); Assert.IsTrue(merged); Assert.AreEqual(c2.FullName, "John Doe"); Assert.AreEqual(c2.Emails.Count(), 2); Assert.IsTrue(c2.Emails.Contains("*****@*****.**")); Assert.IsTrue(c2.Emails.Contains("*****@*****.**")); }
public void TestTwoContactsWithCommonEmailAreEqualEvenWithDifferentNames() { string mail = "*****@*****.**"; IContact c1 = new Contact("J. Doe", mail); IContact c2 = new Contact("John Doe", "*****@*****.**"); Assert.IsFalse(c1.IsSameAs(c2)); c2.addMail(mail); Assert.IsTrue(c1.IsSameAs(c2)); }