コード例 #1
0
        public void TestArgumentExceptions()
        {
            var mailbox = new MailboxAddress("MimeKit Unit Tests", "*****@*****.**");
            var list    = new InternetAddressList();

            list.Add(new MailboxAddress("Example User", "*****@*****.**"));

            Assert.Throws <ArgumentNullException> (() => new InternetAddressList(null));
            Assert.Throws <ArgumentNullException> (() => list.Add(null));
            Assert.Throws <ArgumentNullException> (() => list.AddRange(null));
            Assert.Throws <ArgumentNullException> (() => list.CompareTo(null));
            Assert.Throws <ArgumentNullException> (() => list.Contains(null));
            Assert.Throws <ArgumentNullException> (() => list.CopyTo(null, 0));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.CopyTo(new InternetAddress[0], -1));
            Assert.Throws <ArgumentNullException> (() => list.IndexOf(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.Insert(-1, mailbox));
            Assert.Throws <ArgumentNullException> (() => list.Insert(0, null));
            Assert.Throws <ArgumentNullException> (() => list.Remove(null));
            Assert.Throws <ArgumentOutOfRangeException> (() => list.RemoveAt(-1));
            Assert.Throws <ArgumentOutOfRangeException> (() => list[-1] = mailbox);
            Assert.Throws <ArgumentNullException> (() => list[0]        = null);
        }
コード例 #2
0
		public void TestArgumentExceptions ()
		{
			var mailbox = new MailboxAddress ("MimeKit Unit Tests", "*****@*****.**");
			var list = new InternetAddressList ();

			list.Add (new MailboxAddress ("Example User", "*****@*****.**"));

			Assert.Throws<ArgumentNullException> (() => new InternetAddressList (null));
			Assert.Throws<ArgumentNullException> (() => list.Add (null));
			Assert.Throws<ArgumentNullException> (() => list.AddRange (null));
			Assert.Throws<ArgumentNullException> (() => list.CompareTo (null));
			Assert.Throws<ArgumentNullException> (() => list.Contains (null));
			Assert.Throws<ArgumentNullException> (() => list.CopyTo (null, 0));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.CopyTo (new InternetAddress[0], -1));
			Assert.Throws<ArgumentNullException> (() => list.IndexOf (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.Insert (-1, mailbox));
			Assert.Throws<ArgumentNullException> (() => list.Insert (0, null));
			Assert.Throws<ArgumentNullException> (() => list.Remove (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => list.RemoveAt (-1));
			Assert.Throws<ArgumentOutOfRangeException> (() => list[-1] = mailbox);
			Assert.Throws<ArgumentNullException> (() => list[0] = null);
		}