本文整理汇总了C#中System.Exception.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.Equals方法的具体用法?C# Exception.Equals怎么用?C# Exception.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.Equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
public IEnumerable<ExceptionComparisonDifference> Compare(Exception expected, Exception actual)
{
if (!expected.Equals(actual))
yield return new ExceptionComparisonDifference(expected, actual, "-");
}
示例2: ShowErrorWasCalledWith
public virtual bool ShowErrorWasCalledWith(Exception e){
return (
e.Equals(ShowErrorParameter_e_LastCalledWith) );
}
示例3: Good5
public static bool Good5(Exception x, DivideByZeroException y)
{
return x.Equals(y);
}
示例4: CreateExceptionWithInnerReturnsCorrectResult
public void CreateExceptionWithInnerReturnsCorrectResult()
{
// Fixture setup
var value = Guid.NewGuid().ToString();
var inner = new Exception();
var expected = new Exception();
var cmd = new DelegatingGuardClauseCommand { OnCreateExceptionWithInner = (v, e) => value == v && inner.Equals(e) ? expected : new Exception() };
var sut = new ReflectionExceptionUnwrappingCommand(cmd);
// Exercise system
var result = sut.CreateException(value, inner);
// Verify outcome
Assert.Equal(expected, result);
// Teardown
}
示例5: VerifyThrowsWhenCommandThrowsUnexpectedException
public void VerifyThrowsWhenCommandThrowsUnexpectedException()
{
// Fixture setup
var expectedInner = new Exception();
var expected = new Exception();
var cmd = new DelegatingGuardClauseCommand
{
OnExecute = v => { throw expectedInner; },
OnCreateExceptionWithInner = (v, e) => v == "\"Guid.Empty\"" && expectedInner.Equals(e) ? expected : new Exception(),
RequestedType = typeof(Guid)
};
var sut = new EmptyGuidBehaviorExpectation();
// Exercise system and verify outcome
var result = Assert.Throws<Exception>(() =>
sut.Verify(cmd));
Assert.Equal(expected, result);
// Teardown
}