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