예제 #1
0
 public void HeaderConstrcutor()
 {
     var pair = new KeyValuePair<string, string>("key", "value");
     var header = new Header(pair);
     Assert.Equal("key", header.Name);
     Assert.Equal("value", header.Value);
 }
예제 #2
0
 void CheckHeaderRaw(Header header, int addressCount)
 {
     Assert.True(header != null);
     
     string foldedText = header.SourceText.ToString();
     string[] foldedParts = foldedText.Split(new string[] { MailStandard.CRLF }, StringSplitOptions.None);
     Assert.True(foldedParts.Length == addressCount);
 }
예제 #3
0
파일: MimeWriter.cs 프로젝트: DM-TOR/nhin-d
 /// <summary>
 /// Writes a header
 /// </summary>
 /// <param name="header">The header to write.</param>
 public void Write(Header header)
 {
     if (header == null)
     {
         throw new ArgumentNullException("header");
     }
     
     WriteLine(header.SourceText);
 }
예제 #4
0
        public void CloneHeader()
        {
            var pair = new KeyValuePair<string, string>("key", "value");
            var header = new Header(pair);

            var clone = header.Clone();

            Assert.Equal(header.Name, clone.Name);
            Assert.Equal(header.Value, clone.Value);
        }
예제 #5
0
 void CheckCollection(Header header, string[] contains, string[] doesNotContain)
 {
     Assert.True(header != null);
     
     DirectAddressCollection collection = null;
     Assert.DoesNotThrow(() => collection= DirectAddressCollection.Parse(header.Value));
     if (!contains.IsNullOrEmpty())
     {
         foreach(string addr in contains)
         {
             Assert.True(collection.Contains(addr));
         }
     }
     if (!doesNotContain.IsNullOrEmpty())
     {
         foreach (string addr in doesNotContain)
         {
             Assert.True(!collection.Contains(addr));
         }
     }
 }
예제 #6
0
 public void IsHeaderNameAnyOfWIthNullArray()
 {
     var pair = new KeyValuePair<string, string>("key", "value");
     var header = new Header(pair);
     Assert.False(header.IsHeaderNameOneOf(null));
 }
예제 #7
0
 public void IsHeaderNameAnyOf(string name, bool expected)
 {
     var pair = new KeyValuePair<string, string>(name, "value");
     var header = new Header(pair);
     Assert.Equal(expected, header.IsHeaderNameOneOf(new[] {"to", "from", "cc", "subject"}));
 }
예제 #8
0
 public void IsHeaderName(string name, bool expected)
 {
     var pair = new KeyValuePair<string, string>("key", "value");
     var header = new Header(pair);
     Assert.Equal(expected, header.IsNamed(name));
 }
예제 #9
0
        public void StringArrayFilteredVersionOfAdd()
        {
            var a = new Header("a", "a");
            var b = new Header("b", "b");
            var aa = new Header("aa", "c");
            var headers = new Header[] { a, b, aa };
            HeaderCollection coll = new HeaderCollection();

            coll.Add(headers, new string[] { "a", "aa" });
            Assert.True(coll.Contains(a));
            Assert.True(coll.Contains(aa));
            Assert.False(coll.Contains(b));
        }
예제 #10
0
        public void FilteredVersionOfAdd()
        {
            var a = new Header("a", "a");
            var b = new Header("b", "b");
            var aa = new Header("aa", "c");
            Header[] headers =  new Header[] { a, b, aa };
            HeaderCollection coll = new HeaderCollection();

            coll.Add(headers, h => h.Name.StartsWith("a"));

            Assert.True(coll.Contains(a));
            Assert.True(coll.Contains(aa));
            Assert.False(coll.Contains(b));
        }