Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 /// <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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
         }
     }
 }
Ejemplo n.º 6
0
 public void IsHeaderNameAnyOfWIthNullArray()
 {
     var pair = new KeyValuePair<string, string>("key", "value");
     var header = new Header(pair);
     Assert.False(header.IsHeaderNameOneOf(null));
 }
Ejemplo n.º 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"}));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }