public void TestAsReadOnly() { var list = new ImapMessageFlagList(new[] { ImapMessageFlag.Recent, ImapMessageFlag.Answered, new ImapMessageFlag("$label1"), }); var readOnlyList = list.AsReadOnly(); Assert.AreNotSame(list, readOnlyList); Assert.AreEqual(3, readOnlyList.Count); Assert.IsTrue(readOnlyList.Has(ImapMessageFlag.Recent)); Assert.IsTrue(readOnlyList.Has("\\Answered")); Assert.IsTrue(readOnlyList.Has("$label1")); try { var collection = readOnlyList as System.Collections.Generic.ICollection<ImapMessageFlag>; collection.Add(ImapMessageFlag.Seen); Assert.Fail("NotSupportedException not thrown"); } catch (NotSupportedException) { } }
static ImapMessageFlag() { AllFlags = new ImapMessageFlagList(true, GetDefinedConstants<ImapMessageFlag>()); FetchFlags = new ImapMessageFlagList(true, new[] { ImapMessageFlag.Answered, ImapMessageFlag.Flagged, ImapMessageFlag.Deleted, ImapMessageFlag.Seen, ImapMessageFlag.Draft, ImapMessageFlag.Recent, }); PermittedFlags = new ImapMessageFlagList(true, new[] { ImapMessageFlag.Answered, ImapMessageFlag.Flagged, ImapMessageFlag.Deleted, ImapMessageFlag.Seen, ImapMessageFlag.Draft, ImapMessageFlag.AllowedCreateKeywords, }); }