本文整理匯總了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");
}
示例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.");
}