本文整理匯總了C#中NUnit.Framework.TestContext.Invoke方法的典型用法代碼示例。如果您正苦於以下問題:C# TestContext.Invoke方法的具體用法?C# TestContext.Invoke怎麽用?C# TestContext.Invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NUnit.Framework.TestContext
的用法示例。
在下文中一共展示了TestContext.Invoke方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExpectingException
async Task<TestResult> ExpectingException (TestContext context, Type type,
CancellationToken cancellationToken)
{
try {
await context.Invoke (this, cancellationToken);
var message = string.Format ("Expected an exception of type {0}", type);
return new TestError (Name, message, new AssertionException (message));
} catch (Exception ex) {
if (ex is TargetInvocationException)
ex = ((TargetInvocationException)ex).InnerException;
if (type.IsAssignableFrom (ex.GetType ()))
return new TestSuccess (Name);
var message = string.Format ("Expected an exception of type {0}, but got {1}",
type, ex.GetType ());
return new TestError (Name, message, new AssertionException (message, ex));
}
}
示例2: ExpectingSuccess
async Task<TestResult> ExpectingSuccess (TestContext context,
CancellationToken cancellationToken)
{
await context.Invoke (this, cancellationToken);
return new TestSuccess (Name);
}