本文整理汇总了C#中System.Exception.ShouldBeNull方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.ShouldBeNull方法的具体用法?C# Exception.ShouldBeNull怎么用?C# Exception.ShouldBeNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.ShouldBeNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldBeNull_throws_exception_for_none_null_values
public void ShouldBeNull_throws_exception_for_none_null_values()
{
var value = new Exception();
bool threwException = false;
try
{
value.ShouldBeNull();
}
catch (AssertionException)
{
threwException = true;
}
Assert.IsTrue(threwException, "Should have triggered an assertion.");
}
示例2: PackageContainsAFrameworkAssemblyReference
public static void PackageContainsAFrameworkAssemblyReference(ScenarioDirectory directory, Exception exception)
{
var scenario = MethodBase.GetCurrentMethod().GetFullName();
"Given a simple script"
.f(() => directory = ScenarioDirectory.Create(scenario)
.WriteLine("foo.csx", "Console.WriteLine();"));
"When I install a package which contains a framework assembly reference"
.f(() => ScriptCsExe.Install("FrameworkAssemblyReferencer", directory));
"And I execute the script"
.f(() => exception = Record.Exception(() => ScriptCsExe.Run("foo.csx", directory)));
"Then there should be no errors"
.f(() => exception.ShouldBeNull());
}
示例3: PackagesWithDuplicateAssemblies
public static void PackagesWithDuplicateAssemblies(ScenarioDirectory directory, Exception exception)
{
var scenario = MethodBase.GetCurrentMethod().GetFullName();
"Given a simple script"
.f(() => directory = ScenarioDirectory.Create(scenario)
.WriteLine("foo.csx", "Console.WriteLine();"));
"When I install a package"
.f(() => ScriptCsExe.Install("Duplicate.A", directory));
"And I install another package containing the same assembly"
.f(() => ScriptCsExe.Install("Duplicate.B", directory));
"And I execute the script"
.f(() => exception = Record.Exception(() => ScriptCsExe.Run("foo.csx", directory)));
"Then there should be no errors"
.f(() => exception.ShouldBeNull());
}