當前位置: 首頁>>代碼示例>>C#>>正文


C# Win32Exception.GetType方法代碼示例

本文整理匯總了C#中System.ComponentModel.Win32Exception.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# Win32Exception.GetType方法的具體用法?C# Win32Exception.GetType怎麽用?C# Win32Exception.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.Win32Exception的用法示例。


在下文中一共展示了Win32Exception.GetType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ctor

		[Test] // ctor (int)
		public void Constructor1 ()
		{
			Win32Exception ex;

			ex = new Win32Exception (0);
			Assert.AreEqual (-2147467259, ex.ErrorCode, "#A1");
			Assert.IsNull (ex.InnerException, "#A2");
			Assert.IsNotNull (ex.Message, "#A3");
			Assert.IsFalse (ex.Message.IndexOf (ex.GetType ().FullName) != -1, "#A4");
			Assert.AreEqual (0, ex.NativeErrorCode, "#A5");

			ex = new Win32Exception (int.MinValue);
			Assert.AreEqual (-2147467259, ex.ErrorCode, "#B1");
			Assert.IsNull (ex.InnerException, "#B2");
			Assert.IsNotNull (ex.Message, "#B3");
			Assert.IsFalse (ex.Message.IndexOf (ex.GetType ().FullName) != -1, "#B4");
			Assert.AreEqual (int.MinValue, ex.NativeErrorCode, "#B5");

			ex = new Win32Exception (int.MaxValue);
			Assert.AreEqual (-2147467259, ex.ErrorCode, "#C1");
			Assert.IsNull (ex.InnerException, "#C2");
			Assert.IsNotNull (ex.Message, "#C3");
			Assert.IsFalse (ex.Message.IndexOf (ex.GetType ().FullName) != -1, "#C4");
			Assert.AreEqual (int.MaxValue, ex.NativeErrorCode, "#C5");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:26,代碼來源:Win32ExceptionTest.cs

示例2: ShouldSetInnerException

 public void ShouldSetInnerException()
 {
     var result = Result.RzSuccess;
     var expected = new Win32Exception(result);
     var actual = new NativeCallException("TestFunc", result).InnerException;
     Assert.AreEqual(expected.GetType(), actual.GetType(), "Expected types to be equal.");
     Assert.AreEqual(expected.HResult, actual.HResult, "Expected HResults to be equal.");
     Assert.AreEqual(expected.Message, actual.Message, "Expected message to be equal.");
     Assert.AreEqual(
         expected.NativeErrorCode,
         ((Win32Exception)actual).NativeErrorCode,
         "Expected native error codes to be equal.");
 }
開發者ID:WolfspiritM,項目名稱:Colore,代碼行數:13,代碼來源:NativeCallExceptionTests.cs


注:本文中的System.ComponentModel.Win32Exception.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。