Exemple #1
0
        public void GetAddresses_WithThreeAddresses_ParsesCorrectAddressesAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "To", new HeaderValue(@"<*****@*****.**>,   <*****@*****.**>,   <*****@*****.**>") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("To");

            Assert.Equal(3, mailAddresses.Length);

            var firstMailAddress = mailAddresses.ElementAt(0);

            Assert.Equal("*****@*****.**", firstMailAddress.Address);
            Assert.Equal("", firstMailAddress.DisplayName);

            var secondMailAddress = mailAddresses.ElementAt(1);

            Assert.Equal("*****@*****.**", secondMailAddress.Address);
            Assert.Equal("", secondMailAddress.DisplayName);

            var thirdMailAddress = mailAddresses.ElementAt(2);

            Assert.Equal("*****@*****.**", thirdMailAddress.Address);
            Assert.Equal("", thirdMailAddress.DisplayName);
        }
        public void GetAddresses_Rubbish_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
                {
                    { "From", new HeaderValue(@"<<<<,783459@")}
                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(0, mailAddresses.Length);
        }
        public void GetAddresses_EmptyHeader_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
                {
                    { "From", new HeaderValue(@"")}
                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(0, mailAddresses.Length);
        }
Exemple #4
0
        public void GetAddresses_FiveCommasOnly_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@",,,,,") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(0, mailAddresses.Length);
        }
        public void GetAddresses_FiveCommasOnly_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "From", new HeaderValue(@",,,,,")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(0, mailAddresses.Length);
        }
Exemple #6
0
        public void GetAddresses_EmptyHeader_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(0, mailAddresses.Length);
        }
        public void GetAddresses_OnlyOneSemicolon_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "From", new HeaderValue(@";")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(0, mailAddresses.Length);
        }
Exemple #8
0
        public void GetAddresses_Rubbish_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"<<<<,783459@") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(0, mailAddresses.Length);
        }
Exemple #9
0
        public void GetAddresses_OnlyOneSemicolon_ReturnsNoEmailAddresses()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@";") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(0, mailAddresses.Length);
        }
        public void GetAddresses_PipelineInDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "From", new HeaderValue(@"Test | Testenstein <*****@*****.**>")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();
            Assert.AreEqual("*****@*****.**", mailAddress.Address);
            Assert.AreEqual("Test | Testenstein", mailAddress.DisplayName);
        }
Exemple #11
0
        public void GetAddresses_SimpleWithoutQuotesAroundDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"Test van Testenstein <*****@*****.**>") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();

            Assert.AreEqual("*****@*****.**", mailAddress.Address);
            Assert.AreEqual("Test van Testenstein", mailAddress.DisplayName);
        }
Exemple #12
0
        public void GetAddresses_SimpleWithQuotesAroundDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"""name"" <*****@*****.**>") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();

            Assert.Equal("*****@*****.**", mailAddress.Address);
            Assert.Equal("name", mailAddress.DisplayName);
        }
Exemple #13
0
        public void GetAddresses_WithCommaInDispayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"""lastname, firstname"" <*****@*****.**>") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();

            Assert.Equal("*****@*****.**", mailAddress.Address);
            Assert.Equal("lastname, firstname", mailAddress.DisplayName);
        }
Exemple #14
0
        public void GetAddresses_PipelineInDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "From", new HeaderValue(@"Test | Testenstein <*****@*****.**>") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();

            Assert.Equal("*****@*****.**", mailAddress.Address);
            Assert.Equal("Test | Testenstein", mailAddress.DisplayName);
        }
Exemple #15
0
        public void GetAddresses_WithTwoAddressesWithCommaInSecondEmailAndTrailingComma_ParsesCorrectAddressesAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
            {
                { "To", new HeaderValue(@"Firstname Lastname <*****@*****.**>, ""Test, 2"" <*****@*****.**>, ") }
            };

            var mailAddresses = headerDictionary.GetMailAddresses("To");

            Assert.Equal(2, mailAddresses.Length);

            var firstMailAddress = mailAddresses.First();

            Assert.Equal("*****@*****.**", firstMailAddress.Address);
            Assert.Equal("Firstname Lastname", firstMailAddress.DisplayName);

            var secondMailAddress = mailAddresses.Last();

            Assert.Equal("*****@*****.**", secondMailAddress.Address);
            Assert.Equal("Test, 2", secondMailAddress.DisplayName);
        }
        public void GetAddresses_SimpleWithoutQuotesAroundDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                {
                    { "From", new HeaderValue(@"Test van Testenstein <*****@*****.**>")}
                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.Equal(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();
            Assert.Equal("*****@*****.**", mailAddress.Address);
            Assert.Equal("Test van Testenstein", mailAddress.DisplayName);
        }
        public void GetAddresses_WithTwoAddresses_ParsesCorrectAddressesAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "To", new HeaderValue(@"Firstname Lastname <*****@*****.**>, [email protected]")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("To");

            Assert.AreEqual(2, mailAddresses.Length);

            var firstMailAddress = mailAddresses.First();
            Assert.AreEqual("*****@*****.**", firstMailAddress.Address);
            Assert.AreEqual("Firstname Lastname", firstMailAddress.DisplayName);

            var secondMailAddress = mailAddresses.Last();
            Assert.AreEqual("*****@*****.**", secondMailAddress.Address);
            Assert.AreEqual("", secondMailAddress.DisplayName);
        }
        public void GetAddresses_WithThreeAddresses_ParsesCorrectAddressesAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "To", new HeaderValue(@"<*****@*****.**>,   <*****@*****.**>,   <*****@*****.**>")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("To");

            Assert.AreEqual(3, mailAddresses.Length);

            var firstMailAddress = mailAddresses.ElementAt(0);
            Assert.AreEqual("*****@*****.**", firstMailAddress.Address);
            Assert.AreEqual("", firstMailAddress.DisplayName);

            var secondMailAddress = mailAddresses.ElementAt(1);
            Assert.AreEqual("*****@*****.**", secondMailAddress.Address);
            Assert.AreEqual("", secondMailAddress.DisplayName);

            var thirdMailAddress = mailAddresses.ElementAt(2);
            Assert.AreEqual("*****@*****.**", thirdMailAddress.Address);
            Assert.AreEqual("", thirdMailAddress.DisplayName);
        }
        public void GetAddresses_WithCommaInDispayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "From", new HeaderValue(@"""lastname, firstname"" <*****@*****.**>")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();
            Assert.AreEqual("*****@*****.**", mailAddress.Address);
            Assert.AreEqual("lastname, firstname", mailAddress.DisplayName);
        }
        public void GetAddresses_SimpleWithQuotesAroundDisplayName_ParsesCorrectAddressAndDisplayName()
        {
            var headerDictionary = new HeaderDictionary
                                {
                                        { "From", new HeaderValue(@"""name"" <*****@*****.**>")}
                                };

            var mailAddresses = headerDictionary.GetMailAddresses("From");

            Assert.AreEqual(1, mailAddresses.Length);

            var mailAddress = mailAddresses.First();
            Assert.AreEqual("*****@*****.**", mailAddress.Address);
            Assert.AreEqual("name", mailAddress.DisplayName);
        }