Beispiel #1
0
        [Test] public void Parsing2Or3Names()
        {
            string senderName = "Michael McNaman";
            string mail       = "";

            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "Michael");
            Assert.IsTrue(LastName == "McNaman");

            senderName = "Michael A. McNaman";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "Michael");
            Assert.IsTrue(MiddleName == "A.");
            Assert.IsTrue(LastName == "McNaman");

            senderName = "McNaman, Michael";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "Michael");
            Assert.IsTrue(LastName == "McNaman");

            senderName = "McNaman, Michael A.";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "Michael");
            Assert.IsTrue(MiddleName == "A.");
            Assert.IsTrue(LastName == "McNaman");
        }
Beispiel #2
0
        public override void Save()
        {
            if (_hasChanged)
            {
                string title, fn, mn, ln, suffix, addspec;
                ContactResolver.ResolveName(_boxFullName.Text, null, out title, out fn, out mn, out ln, out suffix, out addspec);

                SaveProp(ContactManager._propTitle, title);
                SaveProp(ContactManager._propFirstName, fn);
                SaveProp(ContactManager._propMiddleName, mn);
                SaveProp(ContactManager._propLastName, ln);
                SaveProp(ContactManager._propSuffix, suffix);
            }

            if (IsOptionDiffer())
            {
                if (_checkShowOrigNames.Checked)
                {
                    _resource.SetProp(Core.ContactManager.Props.ShowOriginalNames, true);
                }
                else
                {
                    _resource.DeleteProp(Core.ContactManager.Props.ShowOriginalNames);
                }
            }
        }
Beispiel #3
0
 public void DisplayNameIsCleanableGarbageTest()
 {
     _name = "\\";
     ContactResolver.ResolveName(_name, null, out Title, out FirstName, out MiddleName,
                                 out LastName, out Suffix, out AddSpec);
     Assert.AreEqual(_name, LastName, "Wrong last name");
 }
Beispiel #4
0
        public void FirstNameDotLastNameExcludeExtraPrefixTest( )
        {
            _name  = "From: [email protected]";
            _email = "From: [email protected]";
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsTrue(!bResolved);
        }
Beispiel #5
0
        public void Null_DisplayName_Test( )
        {
            _name = null;
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsFalse(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual(string.Empty, FirstName);
            Assert.AreEqual(string.Empty, LastName);
        }
Beispiel #6
0
        public void Long_DisplayName_Test( )
        {
            _name = "Vasiliy Pupkin vperedi ";
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsTrue(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual(FirstName, "Vasiliy");
            Assert.AreEqual(LastName, "vperedi");
        }
Beispiel #7
0
        public void LastName_FirstName_Test( )
        {
            _name = "Zhulin,   Sergey ";
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsTrue(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual("Sergey", FirstName, "Wrong first name");
            Assert.AreEqual("Zhulin", LastName, "Wrong last name");
        }
Beispiel #8
0
        public void FirstNameDotLastName_DisplayNameEmpty_Test( )
        {
            _name  = string.Empty;
            _email = "*****@*****.**";
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsFalse(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual(string.Empty, FirstName);
            Assert.AreEqual(string.Empty, LastName);
        }
Beispiel #9
0
        public void FirstNameDotLastName_Test( )
        {
            _name  = "*****@*****.**";
            _email = "*****@*****.**";
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsTrue(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual("sergey", FirstName);
            Assert.AreEqual("zhulin", LastName);
        }
Beispiel #10
0
        public void DisplayNameIsEqualToEmail_Test( )
        {
            _name  = "*****@*****.**";
            _email = _name;
            bool bResolved = ContactResolver.ResolveName(_name, _email, out Title, out FirstName, out MiddleName,
                                                         out LastName, out Suffix, out AddSpec);

            Assert.IsFalse(bResolved, "'" + _name + "' resolution");
            Assert.AreEqual(string.Empty, FirstName);
            Assert.AreEqual(string.Empty, LastName);
        }
Beispiel #11
0
        [Test] public void CheckNameSuffixes()
        {
            string senderName = "Michael McNaman, Jr.";
            string mail       = "";

            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("Jr.") == -1);
            Assert.IsTrue(LastName.IndexOf("Jr.") == -1);
            Console.WriteLine("1. - [" + senderName + "]: " + FirstName + "|" + LastName + " | " + Suffix);

            senderName = "Michael L. McNaman, Sr.";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("Jr.") == -1);
            Assert.IsTrue(LastName.IndexOf("Jr.") == -1);
            Console.WriteLine("2. - [" + senderName + "]: " + FirstName + " | " + LastName + " | " + Suffix);

            senderName = "Michael L. McNaman,  I";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf(" I") == -1);
            Assert.IsTrue(LastName.IndexOf(" I") == -1);
            Console.WriteLine("3. - [" + senderName + "]: " + FirstName + " | " + LastName + " | " + Suffix);

            senderName = "Michael L. McNaman II ";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("II") == -1);
            Assert.IsTrue(LastName.IndexOf("II") == -1);
            Console.WriteLine("4. - [" + senderName + "]: " + FirstName + " | " + LastName + " | " + Suffix);

            senderName = "Michael L. McNaman  III  ";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("III") == -1);
            Assert.IsTrue(LastName.IndexOf("III") == -1);
            Console.WriteLine("5. - [" + senderName + "]: " + FirstName + " | " + LastName + " | " + Suffix);

            senderName = "Prof. Michael L. McNaman  III  ";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("Prof") == -1);
            Assert.IsTrue(LastName.IndexOf("Prof") == -1);
            Console.WriteLine("5. - [" + senderName + "]: " + Title + " | " + FirstName + " | " + LastName + " | " + Suffix);

            senderName = "Dr   Michael L. McNaman  III  ";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName.IndexOf("Prof") == -1);
            Assert.IsTrue(LastName.IndexOf("Prof") == -1);
            Console.WriteLine("6. - [" + senderName + "]: " + Title + " | " + FirstName + " | " + LastName + " | " + Suffix);
        }
Beispiel #12
0
        [Test] public void ParsingFullName()
        {
            string senderName = "dr. Michael A. McNaman, Jr (Email)";
            string mail       = "";

            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(Title == "dr.");
            Assert.IsTrue(FirstName == "Michael");
            Assert.IsTrue(MiddleName == "A.");
            Assert.IsTrue(LastName == "McNaman");
            Assert.IsTrue(Suffix == "Jr");
            Assert.IsTrue(AddSpec == "(Email)");
        }
Beispiel #13
0
        private void InitializeFields()
        {
            string title, fn, mn, ln, suffix, addspec;

            ContactResolver.ResolveName(_fullName, null, out title, out fn, out mn, out ln, out suffix, out addspec);

            _boxTitle.Text     = title;
            _boxFirstName.Text = fn;
            _boxMidName.Text   = mn;
            _boxLastName.Text  = ln;
            _boxSuffix.Text    = suffix;

            _boxTitle.TextChanged     += OnNameTextChanged;
            _boxFirstName.TextChanged += OnNameTextChanged;
            _boxMidName.TextChanged   += OnNameTextChanged;
            _boxLastName.TextChanged  += OnNameTextChanged;
            _boxSuffix.TextChanged    += OnNameTextChanged;
        }
Beispiel #14
0
        [Test] public void ParsingFnLnWithAddSpec()
        {
            string senderName = "FirstName LastName (JetBrains)";
            string mail       = "";

            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "FirstName");
            Assert.IsTrue(MiddleName == string.Empty);
            Assert.IsTrue(LastName == "LastName");
            Assert.IsTrue(AddSpec == "(JetBrains)");

            senderName = "FirstName MiddleName LastName (JetBrains)";
            ContactResolver.ResolveName(senderName, mail, out Title, out FirstName, out MiddleName,
                                        out LastName, out Suffix, out AddSpec);
            Assert.IsTrue(FirstName == "FirstName");
            Assert.IsTrue(MiddleName == "MiddleName");
            Assert.IsTrue(LastName == "LastName");
            Assert.IsTrue(AddSpec == "(JetBrains)");
        }