A summary of a message.
A MessageSummary is returned by IMailFolder.Fetch(System.Collections.Generic.IList<UniqueId>, MessageSummaryItems, System.Threading.CancellationToken). The properties of the MessageSummary that will be available depend on the MessageSummaryItems passed to the aformentioned method.
Inheritance: IMessageSummary
        public void TestNotification()
        {
            var testSummary = new MessageSummary(0);
            var env = new Envelope();
            env.Subject = "testNotificationSubject";
            env.From.Add(new MailboxAddress("testNotificationName", "TestNotificationAddress"));
            env.MessageId = "123TestAbc";
            env.Date = DateTime.Now;
            testSummary.Envelope = env;

            Notify(testSummary, NotificationType.Received, "testNotification");
        }
示例#2
0
		void MakeThreadable (string subject, string msgid, string date, string refs)
		{
			DateTimeOffset value;

			DateUtils.TryParse (date, out value);

			var summary = new MessageSummary (msgIndex++);
			summary.UniqueId = new UniqueId ((uint) summary.Index);
			summary.Envelope = new Envelope ();
			summary.References = new MessageIdList ();
			if (refs != null) {
				foreach (var id in refs.Split (new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
					summary.References.Add (id);
			}
			summary.Envelope.MessageId = MimeUtils.EnumerateReferences (msgid).FirstOrDefault ();
			summary.Envelope.Subject = subject;
			summary.Envelope.Date = value;
			summary.MessageSize = 0;

			summaries.Add (summary);
		}
示例#3
0
        public void TestSorting()
        {
            var messages = new List<MessageSummary> ();
            IList<MessageSummary> sorted;
            MessageSummary summary;

            summary = new MessageSummary (0);
            summary.Envelope = new Envelope ();
            summary.Envelope.Date = DateTimeOffset.Now;
            summary.Envelope.Subject = "aaaa";
            summary.Envelope.From.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.Envelope.To.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.MessageSize = 520;
            messages.Add (summary);

            summary = new MessageSummary (1);
            summary.Envelope = new Envelope ();
            summary.Envelope.Date = DateTimeOffset.Now;
            summary.Envelope.Subject = "bbbb";
            summary.Envelope.From.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.Envelope.To.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.MessageSize = 265;
            messages.Add (summary);

            summary = new MessageSummary (2);
            summary.Envelope = new Envelope ();
            summary.Envelope.Date = DateTimeOffset.Now;
            summary.Envelope.Subject = "cccc";
            summary.Envelope.From.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.Envelope.To.Add (new MailboxAddress ("Jeffrey Stedfast", "*****@*****.**"));
            summary.MessageSize = 520;
            messages.Add (summary);

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.Arrival });
            Assert.AreEqual (0, sorted[0].Index, "Sorting by arrival failed.");
            Assert.AreEqual (1, sorted[1].Index, "Sorting by arrival failed.");
            Assert.AreEqual (2, sorted[2].Index, "Sorting by arrival failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.ReverseArrival });
            Assert.AreEqual (2, sorted[0].Index, "Sorting by reverse arrival failed.");
            Assert.AreEqual (1, sorted[1].Index, "Sorting by reverse arrival failed.");
            Assert.AreEqual (0, sorted[2].Index, "Sorting by reverse arrival failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.Subject });
            Assert.AreEqual (0, sorted[0].Index, "Sorting by subject failed.");
            Assert.AreEqual (1, sorted[1].Index, "Sorting by subject failed.");
            Assert.AreEqual (2, sorted[2].Index, "Sorting by subject failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.ReverseSubject });
            Assert.AreEqual (2, sorted[0].Index, "Sorting by reverse subject failed.");
            Assert.AreEqual (1, sorted[1].Index, "Sorting by reverse subject failed.");
            Assert.AreEqual (0, sorted[2].Index, "Sorting by reverse subject failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.Size });
            Assert.AreEqual (1, sorted[0].Index, "Sorting by size failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.Size, OrderBy.Subject });
            Assert.AreEqual (1, sorted[0].Index, "Sorting by size+subject failed.");
            Assert.AreEqual (0, sorted[1].Index, "Sorting by size+subject failed.");
            Assert.AreEqual (2, sorted[2].Index, "Sorting by size+subject failed.");

            sorted = MessageSorter.Sort (messages, new [] { OrderBy.ReverseSize, OrderBy.ReverseSubject });
            Assert.AreEqual (2, sorted[0].Index, "Sorting by size+subject failed.");
            Assert.AreEqual (0, sorted[1].Index, "Sorting by size+subject failed.");
            Assert.AreEqual (1, sorted[2].Index, "Sorting by size+subject failed.");
        }
示例#4
0
		public void TestSorting ()
		{
			var messages = new List<MessageSummary> ();
			MessageSummary summary;

			summary = new MessageSummary (0);
			summary.Fields = MessageSummaryItems.Envelope | MessageSummaryItems.MessageSize;
			summary.Envelope = new Envelope ();
			summary.Envelope.Date = DateTimeOffset.Now.AddSeconds (-2);
			summary.Envelope.Subject = "aaaa";
			summary.Envelope.From.Add (new MailboxAddress ("A", "*****@*****.**"));
			summary.Envelope.To.Add (new MailboxAddress ("A", "*****@*****.**"));
			summary.Envelope.Cc.Add (new MailboxAddress ("A", "*****@*****.**"));
			summary.Size = 520;
			messages.Add (summary);

			summary = new MessageSummary (1);
			summary.Fields = MessageSummaryItems.Envelope | MessageSummaryItems.MessageSize;
			summary.Envelope = new Envelope ();
			summary.Envelope.Date = DateTimeOffset.Now.AddSeconds (-1);
			summary.Envelope.Subject = "bbbb";
			summary.Envelope.From.Add (new MailboxAddress ("B", "*****@*****.**"));
			summary.Envelope.To.Add (new MailboxAddress ("B", "*****@*****.**"));
			summary.Envelope.Cc.Add (new MailboxAddress ("B", "*****@*****.**"));
			summary.Size = 265;
			messages.Add (summary);

			summary = new MessageSummary (2);
			summary.Fields = MessageSummaryItems.Envelope | MessageSummaryItems.MessageSize;
			summary.Envelope = new Envelope ();
			summary.Envelope.Date = DateTimeOffset.Now;
			summary.Envelope.Subject = "cccc";
			summary.Envelope.From.Add (new MailboxAddress ("C", "*****@*****.**"));
			summary.Envelope.To.Add (new MailboxAddress ("C", "*****@*****.**"));
			summary.Envelope.Cc.Add (new MailboxAddress ("C", "*****@*****.**"));
			summary.Size = 520;
			messages.Add (summary);

			messages.Sort (new[] { OrderBy.Arrival });
			Assert.AreEqual (0, messages[0].Index, "Sorting by arrival failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by arrival failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by arrival failed.");

			messages.Sort (new [] { OrderBy.ReverseArrival });
			Assert.AreEqual (2, messages[0].Index, "Sorting by reverse arrival failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by reverse arrival failed.");
			Assert.AreEqual (0, messages[2].Index, "Sorting by reverse arrival failed.");

			messages.Sort (new [] { OrderBy.Subject });
			Assert.AreEqual (0, messages[0].Index, "Sorting by subject failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by subject failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by subject failed.");

			messages.Sort (new [] { OrderBy.ReverseSubject });
			Assert.AreEqual (2, messages[0].Index, "Sorting by reverse subject failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by reverse subject failed.");
			Assert.AreEqual (0, messages[2].Index, "Sorting by reverse subject failed.");

			messages.Sort (new [] { OrderBy.Size, OrderBy.Arrival });
			Assert.AreEqual (1, messages[0].Index, "Sorting by size failed.");
			Assert.AreEqual (0, messages[1].Index, "Sorting by size failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by size failed.");

			messages.Sort (new [] { OrderBy.Date });
			Assert.AreEqual (0, messages[0].Index, "Sorting by date failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by date failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by date failed.");

			messages.Sort (new [] { OrderBy.Size, OrderBy.Subject });
			Assert.AreEqual (1, messages[0].Index, "Sorting by size+subject failed.");
			Assert.AreEqual (0, messages[1].Index, "Sorting by size+subject failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by size+subject failed.");

			messages.Sort (new [] { OrderBy.ReverseSize, OrderBy.ReverseSubject });
			Assert.AreEqual (2, messages[0].Index, "Sorting by reversed size+subject failed.");
			Assert.AreEqual (0, messages[1].Index, "Sorting by reversed size+subject failed.");
			Assert.AreEqual (1, messages[2].Index, "Sorting by reversed size+subject failed.");

			messages.Sort (new[] { OrderBy.DisplayFrom });
			Assert.AreEqual (0, messages[0].Index, "Sorting by display-from failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by display-from failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by display-from failed.");

			messages.Sort (new[] { OrderBy.From });
			Assert.AreEqual (0, messages[0].Index, "Sorting by from failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by from failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by from failed.");

			messages.Sort (new[] { OrderBy.DisplayTo });
			Assert.AreEqual (0, messages[0].Index, "Sorting by display-to failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by display-to failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by display-to failed.");

			messages.Sort (new[] { OrderBy.To });
			Assert.AreEqual (0, messages[0].Index, "Sorting by to failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by to failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by to failed.");

			messages.Sort (new[] { OrderBy.Cc });
			Assert.AreEqual (0, messages[0].Index, "Sorting by cc failed.");
			Assert.AreEqual (1, messages[1].Index, "Sorting by cc failed.");
			Assert.AreEqual (2, messages[2].Index, "Sorting by cc failed.");
		}
示例#5
-1
		public void TestArgumentExceptions ()
		{
			var orderBy = new OrderBy[] { OrderBy.Arrival };
			var messagesMissingInfo = new [] { new MessageSummary (0) };
			var emptyOrderBy = new OrderBy[0];
			int depth;

			var summary = new MessageSummary (0);
			summary.UniqueId = UniqueId.MinValue;
			summary.Envelope = new Envelope ();
			summary.References = new MessageIdList ();
			summary.Envelope.MessageId = "*****@*****.**";
			summary.Envelope.Subject = "This is the subject";
			summary.Envelope.Date = DateTimeOffset.Now;
			summary.Size = 0;

			var messages = new MessageSummary[] { summary };

			Assert.Throws<ArgumentNullException> (() => MessageThreader.GetThreadableSubject (null, out depth));
			Assert.Throws<ArgumentNullException> (() => MessageThreader.Thread ((IEnumerable<MessageSummary>) null, ThreadingAlgorithm.References));
			Assert.Throws<ArgumentNullException> (() => MessageThreader.Thread ((IEnumerable<MessageSummary>) null, ThreadingAlgorithm.References, orderBy));
			Assert.Throws<ArgumentException> (() => MessageThreader.Thread (messagesMissingInfo, ThreadingAlgorithm.References));
			Assert.Throws<ArgumentNullException> (() => MessageThreader.Thread (messages, ThreadingAlgorithm.References, null));
			Assert.Throws<ArgumentException> (() => MessageThreader.Thread (messages, ThreadingAlgorithm.References, emptyOrderBy));
		}