Ejemplo n.º 1
0
        public void TestSendInvitationsViaGmail()
        {
            bool isCompleted = false;
            var  invitations = new List <MeetingInvitation>();
            var  mc          = new MergedContact();

            mc.FullName = "Merged Contact";
            mc.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.EmailGmail1,
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });
            mc.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.EmailGmail2,
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });
            invitations.Add(new MeetingInvitation(mc, mc.ContactPoints[0]));
            invitations.Add(new MeetingInvitation(mc, mc.ContactPoints[1]));
            string body = "TestSendInvitaionsViaGmail() " + DateTime.Now.ToString();

            invitations.ForEach(i => { i.Body = body; i.Subject = "Test"; });
            roomController.ContactController.SendInvitations(invitations, (err, resultInvitations, resString) =>
            {
                Assert.IsNull(err);
                Assert.IsNotNull(resultInvitations);
                Assert.IsTrue(resultInvitations.Count == 2);
                Assert.IsTrue(resString == ContactDeliveries.Gmail);
                isCompleted = true;
            }, roomController.AllContactAccessors);
            EnqueueConditional(() => isCompleted);
            EnqueueTestComplete();
        }
Ejemplo n.º 2
0
        public void CreateTripleNumberContactTest()
        {
            const string firstName = "Ben";
            const string lastName  = "Stiller";

            IPhoneNumber phoneNumberA = new PhoneNumber("212-845-0923");
            IPhoneNumber phoneNumberB = new PhoneNumber("212-845-0924");
            IPhoneNumber phoneNumberC = new PhoneNumber("212-845-0925");

            IContact contactA = new MockContact(firstName, lastName, phoneNumberA);
            IContact contactB = new MockContact(firstName, lastName, phoneNumberB);
            IContact contactC = new MockContact(firstName, lastName, phoneNumberC);

            MergedContact contactMergedAB = new MergedContact(contactA, contactB);

            Assert.AreEqual(2, contactMergedAB.PhoneNumbers.Count);
            Assert.IsTrue(contactMergedAB.PhoneNumbers.Contains(phoneNumberA));
            Assert.IsTrue(contactMergedAB.PhoneNumbers.Contains(phoneNumberB));

            MergedContact contactMergedABC = new MergedContact(contactMergedAB, contactC);

            Assert.AreEqual(3, contactMergedABC.PhoneNumbers.Count);
            Assert.IsTrue(contactMergedABC.PhoneNumbers.Contains(phoneNumberA));
            Assert.IsTrue(contactMergedABC.PhoneNumbers.Contains(phoneNumberB));
            Assert.IsTrue(contactMergedABC.PhoneNumbers.Contains(phoneNumberC));
        }
Ejemplo n.º 3
0
        public void TestMergingByCPointsAndAddr()
        {
            roomController.InitializeContactAccessors();
            var contactController = roomController.ContactController;

            contactController.MergedContacts.Clear();
            var mc11 = new MergedContact();

            mc11.FullName      = "Merged Contact1";
            mc11.ContactPoints = new ObservableCollection <ContactPoint>();
            mc11.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Email
            });
            mc11.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });
            mc11.ContactPhysicalAddresses = new ObservableCollection <ContactPhysicalAddress>();
            mc11.ContactPhysicalAddresses.Add(new ContactPhysicalAddress
            {
                Address1 = "Address share"
            });

            var mc12 = new MergedContact();

            mc12.FullName      = "Merged Contact2";
            mc12.ContactPoints = new ObservableCollection <ContactPoint>();
            mc12.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Email
            });
            mc12.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });
            mc12.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "contact_skype",
                ContactPointTypeId = (byte)ContactPointTypes.Skype
            });
            mc12.ContactPhysicalAddresses = new ObservableCollection <ContactPhysicalAddress>();
            mc12.ContactPhysicalAddresses.Add(new ContactPhysicalAddress
            {
                Address1 = "Address share"
            });

            contactController.MergedContacts.Add(mc11);
            contactController.MergeContact(mc12);
            Assert.IsTrue(contactController.MergedContacts.Count == 1);
        }
Ejemplo n.º 4
0
        public void DuplicateNumberChangedTypeTest()
        {
            IPhoneNumber duplicatedNumber     = new PhoneNumber("646-123-4567");
            IPhoneNumber duplicatedNumberCell = new PhoneNumber("646-123-4567");

            IContact      contact          = new MockContact("Johnny", "DoubleNumber", duplicatedNumber);
            IContact      contactDuplicate = new MockContact("Johnny", "DoubleNumber", duplicatedNumberCell);
            MergedContact mergedContact    = new MergedContact(contact, contactDuplicate);

            Assert.AreEqual(1, mergedContact.PhoneNumbers.Count);
        }
Ejemplo n.º 5
0
        public void TestEquals()
        {
            IContact davolaCell   = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaCell);
            IContact davolaiPhone = DummyConversationDataGenerator.GetContact(DummyPhoneNumberId.DavolaiPhone);

            MergedContact mergedContact             = new MergedContact(davolaCell, davolaiPhone);
            MergedContact mergedContactCopy         = new MergedContact(davolaCell, davolaiPhone);
            MergedContact mergedContactReverseOrder = new MergedContact(davolaiPhone, davolaCell);

            Assert.AreEqual(mergedContact, mergedContact);
            Assert.AreEqual(mergedContact, mergedContactCopy);
            Assert.AreEqual(mergedContact, mergedContactReverseOrder);
        }
Ejemplo n.º 6
0
        public void TestContactPointsMerging()
        {
            roomController.InitializeContactAccessors();
            var    contactController = roomController.ContactController;
            string fullnameMCShare   = "Merged Contact Share";

            contactController.MergedContacts.Clear();
            var mc11 = new MergedContact();

            mc11.FullName      = fullnameMCShare;
            mc11.ContactPoints = new ObservableCollection <ContactPoint>();
            mc11.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Email
            });
            mc11.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });

            var mc12 = new MergedContact();

            mc12.FullName      = fullnameMCShare;
            mc12.ContactPoints = new ObservableCollection <ContactPoint>();
            mc12.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactPointTypes.Gmail
            });
            mc12.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "contact_skype",
                ContactPointTypeId = (byte)ContactPointTypes.Skype
            });
            mc12.MergedContactId = Guid.NewGuid();
            mc12.AvatarUrl       = "/avatarurl/image.png";
            contactController.MergedContacts.Add(mc11);
            contactController.MergeContact(mc12);
            Assert.IsTrue(contactController.MergedContacts.Count == 1);
            MergedContact mc = contactController.MergedContacts.First();

            //    Assert.IsTrue(mc.ContactPoints.Count == 3);
            Assert.IsTrue(mc.FullName == fullnameMCShare);
        }
Ejemplo n.º 7
0
        private ContactList CoalesceContactLists(IContactList contactListA, IContactList contactListB)
        {
            Dictionary <long, IContactList> hashByContactId = new Dictionary <long, IContactList>();

            HashByContactId(hashByContactId, contactListA);
            HashByContactId(hashByContactId, contactListB);

            ContactList mergedContacts = new ContactList();

            foreach (IContactList contactListById in hashByContactId.Values)
            {
                IContact contactMerged = contactListById[0];
                for (int contactIndex = 1; contactIndex < contactListById.Count; contactIndex++)
                {
                    IContact contactCurrent = contactListById[contactIndex];
                    contactMerged = new MergedContact(contactMerged, contactCurrent);
                }
                mergedContacts.Add(contactMerged);
            }

            return(mergedContacts);
        }
Ejemplo n.º 8
0
        public void TestSendInvitationsViaFacebook()
        {
            bool isCompleted = false;
            var  invitations = new List <MeetingInvitation>();
            var  mc          = new MergedContact();

            mc.FullName = "Merged ContactLinkedIn";
            mc.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.Facebook2UserId,
                ContactPointTypeId = (byte)ContactPointTypes.Facebook
            });
            invitations.Add(new MeetingInvitation(mc, mc.ContactPoints[0]));
            string body = "TestSendInvitaionsViaFacebook() " + DateTime.Now;

            invitations.ForEach(i => { i.Body = body; i.Subject = "Test"; });
            var facebookAccess = roomController.ContactAccessors.FirstOrDefault(ca => ca.ContactDelivery == ContactDeliveries.Facebook) as FacebookAccess;

            Assert.IsNotNull(facebookAccess);
            Debug.Assert(facebookAccess != null);
            facebookAccess.Login(err1 =>
            {
                Assert.IsNull(err1);
                roomController.ContactController.SendInvitations(invitations, (err, resultInvitations, resString) =>
                {
                    Assert.IsNull(err);
                    Assert.IsNotNull(resultInvitations);
                    resultInvitations.ForEach(i => Assert.AreEqual(ResultState.Success, i.Result));
                    Assert.IsTrue(resultInvitations.Count == 1);
                    Assert.IsTrue(resString == ContactDeliveries.Facebook);
                    isCompleted = true;
                }, roomController.AllContactAccessors);
            });
            EnqueueConditional(() => isCompleted);
            EnqueueTestComplete();
        }
Ejemplo n.º 9
0
        public void RichInvitationBox_ParsingEmails()
        {
            var invitationBox = new RichInvitationBox();

            invitationBox.Initialize(roomController);

            // simple email 1
            var simpleEmail1 = new RichItemText {
                Text = "*****@*****.**"
            };

            // group 1
            var group1Part1 = new RichItemText {
                Text = "User1 Name1"
            };
            var group1Part2 = new RichItemText {
                Text = "<*****@*****.**>"
            };
            var group1Part3 = new RichItemText {
                Text = ",[email protected];"
            };

            // simple email 2
            var simpleEmail2 = new RichItemText {
                Text = "*****@*****.**"
            };

            // wrong email 1
            var wrongEmail1 = new RichItemText {
                Text = "_asdf...b.com,"
            };

            // group 2
            var group2Part1 = new RichItemText {
                Text = "User2"
            };
            var group2Part2 = new RichItemText {
                Text = "Name2"
            };
            var group2Part3 = new RichItemText {
                Text = "<testgroup2@"
            };
            var group2Part4 = new RichItemText {
                Text = "hotmail.zzz>"
            };


            var itemContact1 = new RichItemContact();
            var mc1          = new MergedContact();

            mc1.FullName      = "Full Name111";
            mc1.ContactPoints = new ObservableCollection <ContactPoint>();
            mc1.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "*****@*****.**",
                ContactPointTypeId = (byte)ContactDeliveries.Gmail
            });
            var invitation1 = new MeetingInvitation(mc1, mc1.ContactPoints.First());

            itemContact1.Invitation = invitation1;

            var richRows = new List <RichInvitationBox.RichRow>();

            richRows.Add(new RichInvitationBox.RichRow());
            richRows.Add(new RichInvitationBox.RichRow());
            richRows[0].Items.Add(simpleEmail1);
            richRows[0].Items.Add(itemContact1);

            richRows[0].Items.Add(group1Part1);
            richRows[0].Items.Add(new RichItemSpace());
            richRows[1].Items.Add(group1Part2);
            richRows[1].Items.Add(group1Part3);

            richRows[1].Items.Add(simpleEmail2);

            richRows[1].Items.Add(wrongEmail1);

            richRows[1].Items.Add(group2Part1);
            richRows[1].Items.Add(new RichItemSpace());
            richRows[1].Items.Add(new RichItemSpace());
            richRows[1].Items.Add(new RichItemSpace());
            richRows[1].Items.Add(group2Part2);
            richRows[1].Items.Add(new RichItemSpace());
            richRows[1].Items.Add(group2Part3);
            richRows[1].Items.Add(group2Part4);

            bool isItemsValid = false;
            var  invitations  = new List <MeetingInvitation>();

            //Grouped list of texts which separeted by Controls or "," or "." or ";"
            List <List <IRichItem> > listTextItems;
            List <MeetingInvitation> contactInvitations;

            invitationBox.GetContactInvitationsFromRows(richRows, out listTextItems, out contactInvitations);
            invitations.AddRange(contactInvitations);

            Assert.IsTrue(contactInvitations.Count == 1, "should be one Contact");

            // Parsing (concatenate) texts for getting email addresses
            List <List <RichItemText> > itemsNotRecognized;
            List <MeetingInvitation>    textEmailsInvitations;

            invitationBox.GetEmailInvitationsFromText(listTextItems, out textEmailsInvitations, out itemsNotRecognized);
            invitations.AddRange(textEmailsInvitations);

            Assert.IsTrue(textEmailsInvitations.Count == 5, "should be 5 'direct' email contacts");
            Assert.IsTrue(invitations.Count == 6, "count of invitations is wrong");
            Assert.IsTrue(invitations.Contains(itemContact1.Invitation), "GmailContact is not added to invitations");
            Assert.IsTrue(itemsNotRecognized.Sum(group => group.Count) == 1, "should be one wrong text element");
            Assert.IsFalse(isItemsValid, "expected that not all texts is valid");
            if (itemsNotRecognized.Sum(group => group.Count) > 0)
            {
                Assert.IsTrue(wrongEmail1.Text == itemsNotRecognized[0][0].Text, "wrong expected error");
                Assert.IsTrue(!itemsNotRecognized[0][0].IsEmail);
            }

            EnqueueTestComplete();
        }
Ejemplo n.º 10
0
        private static List <MergedContact> CreateTestContacts()
        {
            var mc1 = new MergedContact();

            mc1.MergedContactId = Guid.NewGuid();
            mc1.FullName        = "Merged Contact1";
            mc1.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = "skype_contact1",
                ContactPointTypeId = (byte)ContactPointTypes.Skype
            });
            mc1.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.EmailGmail1,
                ContactPointTypeId = (byte)ContactPointTypes.Skype
            });
            mc1.LinkedContacts.Add(new LinkedContact
            {
                SourceType = (byte)ContactPointTypes.Gmail
            });

            mc1.ContactPhysicalAddresses.Add(new ContactPhysicalAddress
            {
                Address1     = "Address1111111",
                Address2     = "Address1111112",
                City         = "City1",
                LocationType = (byte)LocationTypes.Home,
                IsManual     = true
            });
            mc1.ContactPhysicalAddresses.Add(new ContactPhysicalAddress
            {
                Address1     = "Address1111111bb",
                Address2     = "Address1111112bbb",
                City         = "City1bbb",
                LocationType = (byte)LocationTypes.Work,
                IsManual     = true
            });


            var mc2 = new MergedContact();

            mc2.MergedContactId = Guid.NewGuid();
            mc2.FullName        = "Merged Contact2";
            mc2.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.Facebook1UserId,
                ContactPointTypeId = (byte)ContactPointTypes.Facebook
            });
            mc2.ContactPoints.Add(new ContactPoint
            {
                ContactPointId     = TestConstants.LinkedIn1UserId,
                ContactPointTypeId = (byte)ContactPointTypes.Linkedin
            });
            mc2.LinkedContacts.Add(new LinkedContact
            {
                SourceType = (byte)ContactPointTypes.Facebook
            });
            mc2.LinkedContacts.Add(new LinkedContact
            {
                SourceType = (byte)ContactPointTypes.Linkedin
            });

            var contacts = new List <MergedContact>();

            contacts.Add(mc1);
            contacts.Add(mc2);
            return(contacts);
        }