예제 #1
0
 public void TestToString() {
   const string mbox =
           "Me <@example.org,@example.net,@example.com:[email protected]>";
   var result = new NamedAddress(mbox);
   {
     string stringTemp = result.ToString();
     Assert.AreEqual(
       "Me <*****@*****.**>",
       stringTemp);
   }
 }
예제 #2
0
    public void TestNamedAddressParse() {
      NamedAddress na;
      IList<NamedAddress> groupAddr;
      na = new NamedAddress("*****@*****.**");
      Assert.AreEqual("*****@*****.**", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      {
string stringTemp = na.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      na = new NamedAddress("John's Office <*****@*****.**>");
      Assert.AreEqual("John's Office", na.Name);
      na = new NamedAddress("Me <*****@*****.**>");
      Assert.AreEqual("Me", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
    na = new NamedAddress("(comment) Me (comment) <*****@*****.**> (comment)");
      Assert.AreEqual("Me", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      na = new NamedAddress("=?utf-8?q?Me?= <*****@*****.**>");
      Assert.AreEqual("Me", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      {
string stringTemp = na.ToString();
Assert.AreEqual(
"Me <*****@*****.**>",
stringTemp);
}
   na = new NamedAddress("=?utf-8?q?John=27s_Office?= <" +
                  "*****@*****.**>");
      Assert.AreEqual("John's Office", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      {
string stringTemp = na.ToString();
Assert.AreEqual(
"John's Office <*****@*****.**>",
stringTemp);
}
      na = new NamedAddress("\"Me\" <*****@*****.**>");
      Assert.AreEqual("Me", na.Name);
      Assert.IsFalse(na.IsGroup);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      {
string stringTemp = na.ToString();
Assert.AreEqual(
"Me <*****@*****.**>",
stringTemp);
}
      //------------
      na = new NamedAddress("Group: \"Me\" <*****@*****.**>;");
      Assert.IsTrue(na.IsGroup);
      groupAddr = na.GroupAddresses;
      Assert.AreEqual(1, groupAddr.Count);
      na = groupAddr[0];
      Assert.AreEqual("Me", na.Name);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      na = new
  NamedAddress("Group: \"Me\" <*****@*****.**>, Fred <*****@*****.**>;");
      Assert.IsTrue(na.IsGroup);
      {
string stringTemp = na.ToString();
      const string s1 = "Group: Me <*****@*****.**>, Fred <*****@*****.**>;" ;
        Assert.AreEqual(s1, stringTemp);
}
      groupAddr = na.GroupAddresses;
      Assert.AreEqual(2, groupAddr.Count);
      na = groupAddr[0];
      Assert.AreEqual("Me", na.Name);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      na = groupAddr[1];
      Assert.AreEqual("Fred", na.Name);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      //------------
na = new
        NamedAddress("Group: \"Me\" <*****@*****.**>, [email protected];");
      Assert.AreEqual("Group", na.Name);
      Assert.IsTrue(na.IsGroup);
      {
string stringTemp = na.ToString();
        const string s1 = "Group: Me <*****@*****.**>, [email protected];";
        Assert.AreEqual(s1, stringTemp);
}
      groupAddr = na.GroupAddresses;
      Assert.AreEqual(2, groupAddr.Count);
      na = groupAddr[0];
      Assert.AreEqual("Me", na.Name);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
      na = groupAddr[1];
      Assert.AreEqual("*****@*****.**", na.Name);
      {
string stringTemp = na.Address.ToString();
Assert.AreEqual(
"*****@*****.**",
stringTemp);
}
    }