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