本文整理匯總了C#中System.Exception.ShouldNotBeNull方法的典型用法代碼示例。如果您正苦於以下問題:C# Exception.ShouldNotBeNull方法的具體用法?C# Exception.ShouldNotBeNull怎麽用?C# Exception.ShouldNotBeNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Exception
的用法示例。
在下文中一共展示了Exception.ShouldNotBeNull方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ScriptThrowsAnException
public static void ScriptThrowsAnException(ScriptFile script, Exception ex)
{
var scenario = MethodBase.GetCurrentMethod().GetFullName();
"Given a script which throws an exception"
.f(() => script = ScriptFile.Create(scenario).WriteLine(@"throw new Exception(""BOOM!"");"));
"When I execute the script"
.f(() => ex = Record.Exception(() => script.Execute()));
"Then the script fails"
.f(() => ex.ShouldNotBeNull());
"And I see the exception message"
.f(() => ex.Message.ShouldContain("BOOM!"));
}
示例2: ShouldNotBeNull_returns_the_value_for_further_expectations
public void ShouldNotBeNull_returns_the_value_for_further_expectations()
{
var value = new Exception();
var returnedValue = value.ShouldNotBeNull();
Assert.IsNotNull(returnedValue);
}
示例3: ShouldNotBeNull_does_nothing_for_none_values
public void ShouldNotBeNull_does_nothing_for_none_values()
{
var value = new Exception();
value.ShouldNotBeNull();
}