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) { } }