Пример #1
0
 public void TestMailbox()
 {
     Parser p = new Parser("*****@*****.**");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual(theaddr.name, "*****@*****.**");
 }
Пример #2
0
 public void TestMailboxWithAtomsName()
 {
     Parser p = new Parser("Mary Smith <*****@*****.**>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("Mary Smith <*****@*****.**>", theaddr.name);
 }
Пример #3
0
 public void TestMailboxWithBigGroup()
 {
     Parser p = new Parser("A Group(Some people)\r\n" +
         "     :Chris Jones <c@(Chris's host.)public.example>,\r\n" +
         "            [email protected],\r\n" +
         "     John <*****@*****.**> (my dear friend); (the end of the group)");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(3, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("Chris Jones <*****@*****.**>", theaddr.name);
     addresses.MoveNext();
     theaddr = addresses.Current;
     Assert.AreEqual(" [email protected]", theaddr.name);
     addresses.MoveNext();
     theaddr = addresses.Current;
     Assert.AreEqual(" John <*****@*****.**>", theaddr.name);
 }
Пример #4
0
 public void TestObsoleteMailboxWithCommentsInAddress()
 {
     Parser p = new Parser("John Doe <jdoe@machine(comment).  example>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("John Doe <jdoe@machine. example>", theaddr.name);
 }
Пример #5
0
 public void TestObsoleteMailboxWithoutQuotesAroundDot()
 {
     Parser p = new Parser("Joe Q. Public <*****@*****.**>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("Joe Q. Public <*****@*****.**>", theaddr.name);
 }
Пример #6
0
 public void TestMailboxWithSmallgGroup()
 {
     Parser p = new Parser("(Empty list)(start)Hidden recipients  :(nobody(that I know))  ;");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual(null, theaddr.name);
 }
Пример #7
0
 public void TestMailboxWithQuotedStringAddr()
 {
     Parser p = new Parser("\"Giant; \\\"Big\\\" Box\" <*****@*****.**>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("\"Giant; \"Big\" Box\" <*****@*****.**>", theaddr.name);
 }
Пример #8
0
 public void TestMailboxWithQuotedName1()
 {
     Parser p = new Parser("\"Mary Smith: Personal Account\" <*****@*****.**>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("\"Mary Smith: Personal Account\" <*****@*****.**>", theaddr.name);
 }
Пример #9
0
 public void TestMailboxWithQuestionMarkAddr()
 {
     Parser p = new Parser("Who? <*****@*****.**>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("Who? <*****@*****.**>", theaddr.name);
 }
Пример #10
0
 public void TestMailboxWithCommentsInDisplayNameAndAngleAddr()
 {
     Parser p = new Parser("Pete(A nice \\) chap) <pete(his account)@silly.test(his host)>");
     Parser.Addresses addrs = p.parseMailboxOrGroup();
     int cnt = 0;
     foreach (Parser.Address addr in addrs.addresses())
         cnt++;
     Assert.AreEqual(1, cnt, "Expected one address");
     IEnumerator<Parser.Address> addresses = addrs.addresses().GetEnumerator();
     addresses.MoveNext();
     Parser.Address theaddr = addresses.Current;
     Assert.AreEqual("Pete <*****@*****.**>", theaddr.name);
 }