本文整理汇总了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.");
}