Ejemplo n.º 1
0
        public void TestBasicListFunctionality()
        {
            var list = new MessageIdList();

            Assert.IsFalse(list.IsReadOnly);
            Assert.AreEqual(0, list.Count, "Initial count");

            list.Add("id2@localhost");

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("id2@localhost", list[0]);

            list.Insert(0, "id0@localhost");
            list.Insert(1, "id1@localhost");

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual("id0@localhost", list[0]);
            Assert.AreEqual("id1@localhost", list[1]);
            Assert.AreEqual("id2@localhost", list[2]);

            var clone = list.Clone();

            Assert.AreEqual(3, clone.Count);
            Assert.AreEqual("id0@localhost", clone[0]);
            Assert.AreEqual("id1@localhost", clone[1]);
            Assert.AreEqual("id2@localhost", clone[2]);

            Assert.IsTrue(list.Contains("id1@localhost"), "Contains");
            Assert.AreEqual(1, list.IndexOf("id1@localhost"), "IndexOf");

            var array = new string[list.Count];

            list.CopyTo(array, 0);
            list.Clear();

            Assert.AreEqual(0, list.Count);

            list.AddRange(array);

            Assert.AreEqual(array.Length, list.Count);

            Assert.IsTrue(list.Remove("id2@localhost"));
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("id0@localhost", list[0]);
            Assert.AreEqual("id1@localhost", list[1]);

            list.RemoveAt(0);

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("id1@localhost", list[0]);

            list[0] = "id@localhost";

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("id@localhost", list[0]);
        }
Ejemplo n.º 2
0
		public void TestBasicListFunctionality ()
		{
			var list = new MessageIdList ();

			Assert.IsFalse (list.IsReadOnly);
			Assert.AreEqual (0, list.Count, "Initial count");

			list.Add ("id2@localhost");

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("id2@localhost", list[0]);

			list.Insert (0, "id0@localhost");
			list.Insert (1, "id1@localhost");

			Assert.AreEqual (3, list.Count);
			Assert.AreEqual ("id0@localhost", list[0]);
			Assert.AreEqual ("id1@localhost", list[1]);
			Assert.AreEqual ("id2@localhost", list[2]);

			var clone = list.Clone ();

			Assert.AreEqual (3, clone.Count);
			Assert.AreEqual ("id0@localhost", clone[0]);
			Assert.AreEqual ("id1@localhost", clone[1]);
			Assert.AreEqual ("id2@localhost", clone[2]);

			Assert.IsTrue (list.Contains ("id1@localhost"), "Contains");
			Assert.AreEqual (1, list.IndexOf ("id1@localhost"), "IndexOf");

			var array = new string[list.Count];
			list.CopyTo (array, 0);
			list.Clear ();

			Assert.AreEqual (0, list.Count);

			list.AddRange (array);

			Assert.AreEqual (array.Length, list.Count);

			Assert.IsTrue (list.Remove ("id2@localhost"));
			Assert.AreEqual (2, list.Count);
			Assert.AreEqual ("id0@localhost", list[0]);
			Assert.AreEqual ("id1@localhost", list[1]);

			list.RemoveAt (0);

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("id1@localhost", list[0]);

			list[0] = "id@localhost";

			Assert.AreEqual (1, list.Count);
			Assert.AreEqual ("id@localhost", list[0]);
		}
Ejemplo n.º 3
0
        public void TestArgumentExceptions()
        {
            var list = new MessageIdList();

            Assert.Throws <ArgumentNullException> (() => list.Add(null));
            Assert.Throws <ArgumentNullException> (() => list.AddRange(null));
            Assert.Throws <ArgumentNullException> (() => list.Contains(null));
            Assert.Throws <ArgumentNullException> (() => list.CopyTo(null, 0));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.CopyTo(new string[0], -1));
            Assert.Throws <ArgumentNullException> (() => list.IndexOf(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.Insert(-1, "item"));
            Assert.Throws <ArgumentNullException> (() => list.Insert(0, null));
            Assert.Throws <ArgumentNullException> (() => list[0] = null);
            Assert.Throws <ArgumentNullException> (() => list.Remove(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.RemoveAt(-1));
        }
Ejemplo n.º 4
0
		public void TestArgumentExceptions ()
		{
			var list = new MessageIdList ();

			Assert.Throws<ArgumentNullException> (() => list.Add (null));
			Assert.Throws<ArgumentNullException> (() => list.AddRange (null));
			Assert.Throws<ArgumentNullException> (() => list.Contains (null));
			Assert.Throws<ArgumentNullException> (() => list.CopyTo (null, 0));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.CopyTo (new string[0], -1));
			Assert.Throws<ArgumentNullException> (() => list.IndexOf (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.Insert (-1, "item"));
			Assert.Throws<ArgumentNullException> (() => list.Insert (0, null));
			Assert.Throws<ArgumentNullException> (() => list[0] = null);
			Assert.Throws<ArgumentNullException> (() => list.Remove (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.RemoveAt (-1));
		}
Ejemplo n.º 5
0
		internal MimeMessage (ParserOptions options, IEnumerable<Header> headers)
		{
			addresses = new Dictionary<string, InternetAddressList> (StringComparer.OrdinalIgnoreCase);
			Headers = new HeaderList (options);

			// initialize our address lists
			foreach (var name in StandardAddressHeaders) {
				var list = new InternetAddressList ();
				list.Changed += InternetAddressListChanged;
				addresses.Add (name, list);
			}

			references = new MessageIdList ();
			references.Changed += ReferencesChanged;
			inreplyto = null;

			Headers.Changed += HeadersChanged;

			// add all of our message headers...
			foreach (var header in headers) {
				if (header.Field.StartsWith ("Content-", StringComparison.OrdinalIgnoreCase))
					continue;

				Headers.Add (header);
			}
		}
Ejemplo n.º 6
0
		internal MimeMessage (ParserOptions options)
		{
			addresses = new Dictionary<string, InternetAddressList> (StringComparer.OrdinalIgnoreCase);
			Headers = new HeaderList (options);

			// initialize our address lists
			foreach (var name in StandardAddressHeaders) {
				var list = new InternetAddressList ();
				list.Changed += InternetAddressListChanged;
				addresses.Add (name, list);
			}

			references = new MessageIdList ();
			references.Changed += ReferencesChanged;
			inreplyto = null;

			Headers.Changed += HeadersChanged;
		}