当前位置: 首页>>代码示例>>C#>>正文


C# AccessRights.AddRange方法代码示例

本文整理汇总了C#中AccessRights.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# AccessRights.AddRange方法的具体用法?C# AccessRights.AddRange怎么用?C# AccessRights.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AccessRights的用法示例。


在下文中一共展示了AccessRights.AddRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestArgumentExceptions

		public void TestArgumentExceptions ()
		{
			var enumeratedRights = new [] { AccessRight.OpenFolder, AccessRight.CreateFolder };

			Assert.Throws<ArgumentNullException> (() => new AccessControl (null));
			Assert.Throws<ArgumentNullException> (() => new AccessControl (null, "rk"));
			Assert.Throws<ArgumentNullException> (() => new AccessControl (null, enumeratedRights));
			Assert.Throws<ArgumentNullException> (() => new AccessControl ("name", (string) null));
			Assert.Throws<ArgumentNullException> (() => new AccessControl ("name", (IEnumerable<AccessRight>) null));

			Assert.Throws<ArgumentNullException> (() => new AccessControlList (null));

			Assert.Throws<ArgumentNullException> (() => new AccessRights ((IEnumerable<AccessRight>) null));
			Assert.Throws<ArgumentNullException> (() => new AccessRights ((string) null));

			var rights = new AccessRights ();
			Assert.Throws<ArgumentNullException> (() => rights.AddRange ((string) null));
			Assert.Throws<ArgumentNullException> (() => rights.AddRange ((IEnumerable<AccessRight>) null));

			Assert.Throws<ArgumentNullException> (() => new AlertEventArgs (null));

			Assert.Throws<ArgumentNullException> (() => new FolderNamespace ('.', null));

			var namespaces = new FolderNamespaceCollection ();
			FolderNamespace ns;

			Assert.Throws<ArgumentNullException> (() => namespaces.Add (null));
			Assert.Throws<ArgumentNullException> (() => namespaces.Contains (null));
			Assert.Throws<ArgumentNullException> (() => namespaces.Remove (null));
			Assert.Throws<ArgumentOutOfRangeException> (() => ns = namespaces[-1]);
			Assert.Throws<ArgumentOutOfRangeException> (() => namespaces[-1] = new FolderNamespace ('.', ""));

			namespaces.Add (new FolderNamespace ('.', ""));
			Assert.Throws<ArgumentNullException> (() => namespaces[0] = null);

			Assert.Throws<ArgumentNullException> (() => new FolderNotFoundException (null));
			Assert.Throws<ArgumentNullException> (() => new FolderNotFoundException ("message", null));
			Assert.Throws<ArgumentNullException> (() => new FolderNotFoundException ("message", null, new Exception ("message")));

			Assert.Throws<ArgumentNullException> (() => new FolderNotOpenException (null, FolderAccess.ReadOnly));
			Assert.Throws<ArgumentNullException> (() => new FolderNotOpenException (null, FolderAccess.ReadOnly, "message"));
			Assert.Throws<ArgumentNullException> (() => new FolderNotOpenException (null, FolderAccess.ReadOnly, "message", new Exception ("message")));

			Assert.Throws<ArgumentNullException> (() => new FolderRenamedEventArgs (null, "name"));
			Assert.Throws<ArgumentNullException> (() => new FolderRenamedEventArgs ("name", null));

			Assert.Throws<ArgumentOutOfRangeException> (() => new MessageEventArgs (-1));

			Assert.Throws<ArgumentNullException> (() => new MessageFlagsChangedEventArgs (0, MessageFlags.Answered, null));
			Assert.Throws<ArgumentNullException> (() => new MessageFlagsChangedEventArgs (0, MessageFlags.Answered, null, 1));
			Assert.Throws<ArgumentNullException> (() => new MessageFlagsChangedEventArgs (0, UniqueId.MinValue, MessageFlags.Answered, null));
			Assert.Throws<ArgumentNullException> (() => new MessageFlagsChangedEventArgs (0, UniqueId.MinValue, MessageFlags.Answered, null, 1));

			Assert.Throws<ArgumentNullException> (() => new MessageLabelsChangedEventArgs (0, null));
			Assert.Throws<ArgumentNullException> (() => new MessageLabelsChangedEventArgs (0, null, 1));
			Assert.Throws<ArgumentNullException> (() => new MessageLabelsChangedEventArgs (0, UniqueId.MinValue, null));
			Assert.Throws<ArgumentNullException> (() => new MessageLabelsChangedEventArgs (0, UniqueId.MinValue, null, 1));

			Assert.Throws<ArgumentNullException> (() => new MessageSentEventArgs (null, "response"));
			Assert.Throws<ArgumentNullException> (() => new MessageSentEventArgs (new MimeMessage (), null));

			Assert.Throws<ArgumentNullException> (() => new MessageSummaryFetchedEventArgs (null));

			Assert.Throws<ArgumentNullException> (() => new MessagesVanishedEventArgs (null, false));

			Assert.Throws<ArgumentNullException> (() => new MetadataCollection (null));

			var metadataOptions = new MetadataOptions ();
			Assert.Throws<ArgumentOutOfRangeException> (() => metadataOptions.Depth = 500);

			Assert.Throws<ArgumentOutOfRangeException> (() => new ModSeqChangedEventArgs (-1));
			Assert.Throws<ArgumentOutOfRangeException> (() => new ModSeqChangedEventArgs (-1, 1));
			Assert.Throws<ArgumentOutOfRangeException> (() => new ModSeqChangedEventArgs (-1, UniqueId.MinValue, 1));

			Assert.Throws<ArgumentOutOfRangeException> (() => new OrderBy (OrderByType.To, SortOrder.None));

			Assert.Throws<ArgumentNullException> (() => new ProtocolLogger ((string) null));
			Assert.Throws<ArgumentNullException> (() => new ProtocolLogger ((Stream) null));
			using (var logger = new ProtocolLogger (new MemoryStream ())) {
				var buffer = new byte[1024];

				Assert.Throws<ArgumentNullException> (() => logger.LogConnect (null));
				Assert.Throws<ArgumentNullException> (() => logger.LogClient (null, 0, 0));
				Assert.Throws<ArgumentNullException> (() => logger.LogServer (null, 0, 0));
				Assert.Throws<ArgumentOutOfRangeException> (() => logger.LogClient (buffer, -1, 0));
				Assert.Throws<ArgumentOutOfRangeException> (() => logger.LogServer (buffer, -1, 0));
				Assert.Throws<ArgumentOutOfRangeException> (() => logger.LogClient (buffer, 0, -1));
				Assert.Throws<ArgumentOutOfRangeException> (() => logger.LogServer (buffer, 0, -1));
			}

			Assert.Throws<ArgumentNullException> (() => new UniqueIdMap (null, new [] { UniqueId.MinValue }));
			Assert.Throws<ArgumentNullException> (() => new UniqueIdMap (new [] { UniqueId.MinValue }, null));
		}
开发者ID:jstedfast,项目名称:MailKit,代码行数:93,代码来源:ArgumentExceptionTests.cs


注:本文中的AccessRights.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。